1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. monitoring
  5. getNotificationChannel
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

gcp.monitoring.getNotificationChannel

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

    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

    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("alert_policy", {
        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",
                }],
            },
        }],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    basic = gcp.monitoring.get_notification_channel(display_name="Test Notification Channel")
    alert_policy = gcp.monitoring.AlertPolicy("alert_policy",
        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",
                )],
            ),
        )])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/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, "alert_policy", &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
    	})
    }
    
    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("alert_policy", 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 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());
    
        }
    }
    
    resources:
      alertPolicy:
        type: gcp:monitoring:AlertPolicy
        name: alert_policy
        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:

    DisplayName 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:

    UserLabels Dictionary<string, string>
    User-provided key-value labels to filter by.
    DisplayName 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:

    UserLabels map[string]string
    User-provided key-value labels to filter by.
    displayName 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:

    userLabels Map<String,String>
    User-provided key-value labels to filter by.
    displayName 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:

    userLabels {[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.
    displayName 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:

    userLabels 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.
    ForceDelete 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].
    SensitiveLabels List<GetNotificationChannelSensitiveLabel>
    VerificationStatus string
    Indicates whether this channel has been verified or not.
    DisplayName string
    Labels Dictionary<string, string>
    Configuration fields that define the channel and its behavior.
    Project string
    Type string
    UserLabels 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.
    ForceDelete 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].
    SensitiveLabels []GetNotificationChannelSensitiveLabel
    VerificationStatus string
    Indicates whether this channel has been verified or not.
    DisplayName string
    Labels map[string]string
    Configuration fields that define the channel and its behavior.
    Project string
    Type string
    UserLabels 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.
    forceDelete 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].
    sensitiveLabels List<GetNotificationChannelSensitiveLabel>
    verificationStatus String
    Indicates whether this channel has been verified or not.
    displayName String
    labels Map<String,String>
    Configuration fields that define the channel and its behavior.
    project String
    type String
    userLabels 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.
    forceDelete 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].
    sensitiveLabels GetNotificationChannelSensitiveLabel[]
    verificationStatus string
    Indicates whether this channel has been verified or not.
    displayName string
    labels {[key: string]: string}
    Configuration fields that define the channel and its behavior.
    project string
    type string
    userLabels {[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[GetNotificationChannelSensitiveLabel]
    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.
    forceDelete 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].
    sensitiveLabels List<Property Map>
    verificationStatus String
    Indicates whether this channel has been verified or not.
    displayName String
    labels Map<String>
    Configuration fields that define the channel and its behavior.
    project String
    type String
    userLabels 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

    AuthToken string
    An authorization token for a notification channel. Channel types that support this field include: slack
    Password string
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    ServiceKey string
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty
    AuthToken string
    An authorization token for a notification channel. Channel types that support this field include: slack
    Password string
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    ServiceKey string
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty
    authToken String
    An authorization token for a notification channel. Channel types that support this field include: slack
    password String
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    serviceKey String
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty
    authToken string
    An authorization token for a notification channel. Channel types that support this field include: slack
    password string
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    serviceKey string
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty
    auth_token str
    An authorization token for a notification channel. Channel types that support this field include: slack
    password str
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    service_key str
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty
    authToken String
    An authorization token for a notification channel. Channel types that support this field include: slack
    password String
    An password for a notification channel. Channel types that support this field include: webhook_basicauth
    serviceKey String
    An servicekey token for a notification channel. Channel types that support this field include: pagerduty

    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.
    gcp logo
    Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi