Google Cloud Classic v6.57.0, May 30 23
Google Cloud Classic v6.57.0, May 30 23
gcp.monitoring.getNotificationChannel
Explore with Pulumi AI
A NotificationChannel is a medium through which an alert is delivered when a policy violation is detected. Examples of channels include email, SMS, and third-party messaging applications. Fields containing sensitive information like authentication tokens or contact info are only partially populated on retrieval.
To get more information about NotificationChannel, see:
Example Usage
Notification Channel Basic
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var basic = Gcp.Monitoring.GetNotificationChannel.Invoke(new()
{
DisplayName = "Test Notification Channel",
});
var alertPolicy = new Gcp.Monitoring.AlertPolicy("alertPolicy", new()
{
DisplayName = "My Alert Policy",
NotificationChannels = new[]
{
basic.Apply(getNotificationChannelResult => getNotificationChannelResult.Name),
},
Combiner = "OR",
Conditions = new[]
{
new Gcp.Monitoring.Inputs.AlertPolicyConditionArgs
{
DisplayName = "test condition",
ConditionThreshold = new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdArgs
{
Filter = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
Duration = "60s",
Comparison = "COMPARISON_GT",
Aggregations = new[]
{
new Gcp.Monitoring.Inputs.AlertPolicyConditionConditionThresholdAggregationArgs
{
AlignmentPeriod = "60s",
PerSeriesAligner = "ALIGN_RATE",
},
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/monitoring"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
basic, err := monitoring.LookupNotificationChannel(ctx, &monitoring.LookupNotificationChannelArgs{
DisplayName: pulumi.StringRef("Test Notification Channel"),
}, nil)
if err != nil {
return err
}
_, err = monitoring.NewAlertPolicy(ctx, "alertPolicy", &monitoring.AlertPolicyArgs{
DisplayName: pulumi.String("My Alert Policy"),
NotificationChannels: pulumi.StringArray{
*pulumi.String(basic.Name),
},
Combiner: pulumi.String("OR"),
Conditions: monitoring.AlertPolicyConditionArray{
&monitoring.AlertPolicyConditionArgs{
DisplayName: pulumi.String("test condition"),
ConditionThreshold: &monitoring.AlertPolicyConditionConditionThresholdArgs{
Filter: pulumi.String("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""),
Duration: pulumi.String("60s"),
Comparison: pulumi.String("COMPARISON_GT"),
Aggregations: monitoring.AlertPolicyConditionConditionThresholdAggregationArray{
&monitoring.AlertPolicyConditionConditionThresholdAggregationArgs{
AlignmentPeriod: pulumi.String("60s"),
PerSeriesAligner: pulumi.String("ALIGN_RATE"),
},
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.monitoring.MonitoringFunctions;
import com.pulumi.gcp.monitoring.inputs.GetNotificationChannelArgs;
import com.pulumi.gcp.monitoring.AlertPolicy;
import com.pulumi.gcp.monitoring.AlertPolicyArgs;
import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionArgs;
import com.pulumi.gcp.monitoring.inputs.AlertPolicyConditionConditionThresholdArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var basic = MonitoringFunctions.getNotificationChannel(GetNotificationChannelArgs.builder()
.displayName("Test Notification Channel")
.build());
var alertPolicy = new AlertPolicy("alertPolicy", AlertPolicyArgs.builder()
.displayName("My Alert Policy")
.notificationChannels(basic.applyValue(getNotificationChannelResult -> getNotificationChannelResult.name()))
.combiner("OR")
.conditions(AlertPolicyConditionArgs.builder()
.displayName("test condition")
.conditionThreshold(AlertPolicyConditionConditionThresholdArgs.builder()
.filter("metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"")
.duration("60s")
.comparison("COMPARISON_GT")
.aggregations(AlertPolicyConditionConditionThresholdAggregationArgs.builder()
.alignmentPeriod("60s")
.perSeriesAligner("ALIGN_RATE")
.build())
.build())
.build())
.build());
}
}
import pulumi
import pulumi_gcp as gcp
basic = gcp.monitoring.get_notification_channel(display_name="Test Notification Channel")
alert_policy = gcp.monitoring.AlertPolicy("alertPolicy",
display_name="My Alert Policy",
notification_channels=[basic.name],
combiner="OR",
conditions=[gcp.monitoring.AlertPolicyConditionArgs(
display_name="test condition",
condition_threshold=gcp.monitoring.AlertPolicyConditionConditionThresholdArgs(
filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
duration="60s",
comparison="COMPARISON_GT",
aggregations=[gcp.monitoring.AlertPolicyConditionConditionThresholdAggregationArgs(
alignment_period="60s",
per_series_aligner="ALIGN_RATE",
)],
),
)])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const basic = gcp.monitoring.getNotificationChannel({
displayName: "Test Notification Channel",
});
const alertPolicy = new gcp.monitoring.AlertPolicy("alertPolicy", {
displayName: "My Alert Policy",
notificationChannels: [basic.then(basic => basic.name)],
combiner: "OR",
conditions: [{
displayName: "test condition",
conditionThreshold: {
filter: "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\"",
duration: "60s",
comparison: "COMPARISON_GT",
aggregations: [{
alignmentPeriod: "60s",
perSeriesAligner: "ALIGN_RATE",
}],
},
}],
});
resources:
alertPolicy:
type: gcp:monitoring:AlertPolicy
properties:
displayName: My Alert Policy
notificationChannels:
- ${basic.name}
combiner: OR
conditions:
- displayName: test condition
conditionThreshold:
filter: metric.type="compute.googleapis.com/instance/disk/write_bytes_count" AND resource.type="gce_instance"
duration: 60s
comparison: COMPARISON_GT
aggregations:
- alignmentPeriod: 60s
perSeriesAligner: ALIGN_RATE
variables:
basic:
fn::invoke:
Function: gcp:monitoring:getNotificationChannel
Arguments:
displayName: Test Notification Channel
Using getNotificationChannel
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getNotificationChannel(args: GetNotificationChannelArgs, opts?: InvokeOptions): Promise<GetNotificationChannelResult>
function getNotificationChannelOutput(args: GetNotificationChannelOutputArgs, opts?: InvokeOptions): Output<GetNotificationChannelResult>
def get_notification_channel(display_name: Optional[str] = None,
labels: Optional[Mapping[str, str]] = None,
project: Optional[str] = None,
type: Optional[str] = None,
user_labels: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetNotificationChannelResult
def get_notification_channel_output(display_name: Optional[pulumi.Input[str]] = None,
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
project: Optional[pulumi.Input[str]] = None,
type: Optional[pulumi.Input[str]] = None,
user_labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetNotificationChannelResult]
func LookupNotificationChannel(ctx *Context, args *LookupNotificationChannelArgs, opts ...InvokeOption) (*LookupNotificationChannelResult, error)
func LookupNotificationChannelOutput(ctx *Context, args *LookupNotificationChannelOutputArgs, opts ...InvokeOption) LookupNotificationChannelResultOutput
> Note: This function is named LookupNotificationChannel
in the Go SDK.
public static class GetNotificationChannel
{
public static Task<GetNotificationChannelResult> InvokeAsync(GetNotificationChannelArgs args, InvokeOptions? opts = null)
public static Output<GetNotificationChannelResult> Invoke(GetNotificationChannelInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetNotificationChannelResult> getNotificationChannel(GetNotificationChannelArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: gcp:monitoring/getNotificationChannel:getNotificationChannel
arguments:
# arguments dictionary
The following arguments are supported:
- Display
Name string The display name for this notification channel.
- Labels Dictionary<string, string>
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Type string
The type of the notification channel.
Other optional fields include:
- User
Labels Dictionary<string, string> User-provided key-value labels to filter by.
- Display
Name string The display name for this notification channel.
- Labels map[string]string
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Type string
The type of the notification channel.
Other optional fields include:
- User
Labels map[string]string User-provided key-value labels to filter by.
- display
Name String The display name for this notification channel.
- labels Map<String,String>
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- type String
The type of the notification channel.
Other optional fields include:
- user
Labels Map<String,String> User-provided key-value labels to filter by.
- display
Name string The display name for this notification channel.
- labels {[key: string]: string}
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- type string
The type of the notification channel.
Other optional fields include:
- user
Labels {[key: string]: string} User-provided key-value labels to filter by.
- display_
name str The display name for this notification channel.
- labels Mapping[str, str]
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- type str
The type of the notification channel.
Other optional fields include:
- user_
labels Mapping[str, str] User-provided key-value labels to filter by.
- display
Name String The display name for this notification channel.
- labels Map<String>
Labels (corresponding to the NotificationChannelDescriptor schema) to filter the notification channels by.
- project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- type String
The type of the notification channel.
Other optional fields include:
- user
Labels Map<String> User-provided key-value labels to filter by.
getNotificationChannel Result
The following output properties are available:
- Description string
An optional human-readable description of this notification channel.
- Enabled bool
Whether notifications are forwarded to the described channel.
- Force
Delete bool - Id string
The provider-assigned unique ID for this managed resource.
- Name string
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- Sensitive
Labels List<GetNotification Channel Sensitive Label> - Verification
Status string Indicates whether this channel has been verified or not.
- Display
Name string - Labels Dictionary<string, string>
Configuration fields that define the channel and its behavior.
- Project string
- Type string
- User
Labels Dictionary<string, string> User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
- Description string
An optional human-readable description of this notification channel.
- Enabled bool
Whether notifications are forwarded to the described channel.
- Force
Delete bool - Id string
The provider-assigned unique ID for this managed resource.
- Name string
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- Sensitive
Labels []GetNotification Channel Sensitive Label - Verification
Status string Indicates whether this channel has been verified or not.
- Display
Name string - Labels map[string]string
Configuration fields that define the channel and its behavior.
- Project string
- Type string
- User
Labels map[string]string User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
- description String
An optional human-readable description of this notification channel.
- enabled Boolean
Whether notifications are forwarded to the described channel.
- force
Delete Boolean - id String
The provider-assigned unique ID for this managed resource.
- name String
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- sensitive
Labels List<GetNotification Channel Sensitive Label> - verification
Status String Indicates whether this channel has been verified or not.
- display
Name String - labels Map<String,String>
Configuration fields that define the channel and its behavior.
- project String
- type String
- user
Labels Map<String,String> User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
- description string
An optional human-readable description of this notification channel.
- enabled boolean
Whether notifications are forwarded to the described channel.
- force
Delete boolean - id string
The provider-assigned unique ID for this managed resource.
- name string
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- sensitive
Labels GetNotification Channel Sensitive Label[] - verification
Status string Indicates whether this channel has been verified or not.
- display
Name string - labels {[key: string]: string}
Configuration fields that define the channel and its behavior.
- project string
- type string
- user
Labels {[key: string]: string} User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
- description str
An optional human-readable description of this notification channel.
- enabled bool
Whether notifications are forwarded to the described channel.
- force_
delete bool - id str
The provider-assigned unique ID for this managed resource.
- name str
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- sensitive_
labels Sequence[GetNotification Channel Sensitive Label] - verification_
status str Indicates whether this channel has been verified or not.
- display_
name str - labels Mapping[str, str]
Configuration fields that define the channel and its behavior.
- project str
- type str
- user_
labels Mapping[str, str] User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
- description String
An optional human-readable description of this notification channel.
- enabled Boolean
Whether notifications are forwarded to the described channel.
- force
Delete Boolean - id String
The provider-assigned unique ID for this managed resource.
- name String
The full REST resource name for this channel. The syntax is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.- sensitive
Labels List<Property Map> - verification
Status String Indicates whether this channel has been verified or not.
- display
Name String - labels Map<String>
Configuration fields that define the channel and its behavior.
- project String
- type String
- user
Labels Map<String> User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field.
Supporting Types
GetNotificationChannelSensitiveLabel
- Auth
Token string - Password string
- Service
Key string
- Auth
Token string - Password string
- Service
Key string
- auth
Token String - password String
- service
Key String
- auth
Token string - password string
- service
Key string
- auth_
token str - password str
- service_
key str
- auth
Token String - password String
- service
Key String
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
google-beta
Terraform Provider.