1. Packages
  2. Logdna Provider
  3. API Docs
  4. getAlert
logdna 1.16.0 published on Monday, Apr 14, 2025 by logdna

logdna.getAlert

Explore with Pulumi AI

logdna logo
logdna 1.16.0 published on Monday, Apr 14, 2025 by logdna

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as logdna from "@pulumi/logdna";
    
    const managed = new logdna.Alert("managed", {
        emailChannels: [{
            emails: ["test@logdna.com"],
            immediate: "false",
            operator: "presence",
            triggerlimit: 15,
            triggerinterval: "15m",
            terminal: "true",
            timezone: "Pacific/Samoa",
        }],
        pagerdutyChannels: [{
            immediate: "true",
            key: "Your PagerDuty API key goes here",
            terminal: "true",
            triggerinterval: "15m",
            triggerlimit: 15,
        }],
        slackChannels: [{
            immediate: "false",
            operator: "absence",
            terminal: "true",
            triggerinterval: "15m",
            triggerlimit: 15,
            url: "https://hooks.slack.com/services/identifier/secret",
        }],
        webhookChannels: [{
            bodytemplate: JSON.stringify({
                message: "Alerts from {{name}}",
            }),
            headers: {
                Authentication: "auth_header_value",
                HeaderTwo: "ValueTwo",
            },
            immediate: "false",
            method: "post",
            terminal: "true",
            triggerinterval: "15m",
            triggerlimit: 15,
            url: "https://yourwebhook/endpoint",
        }],
    });
    const managedRemote = logdna.getAlertOutput({
        presetid: managed.alertId,
    });
    const externalRemote = logdna.getAlert({
        presetid: "xxxxxxxxxx",
    });
    // pass in data source attributes as arguments for module(s) declared in the same config
    const test = new logdna.View("test", {
        query: "level:debug my query",
        emailChannels: managedRemote.apply(managedRemote => managedRemote.emailChannels),
        pagerdutyChannels: externalRemote.then(externalRemote => externalRemote.pagerdutyChannels),
        slackChannels: externalRemote.then(externalRemote => externalRemote.slackChannels),
        webhookChannels: externalRemote.then(externalRemote => externalRemote.webhookChannels),
    });
    
    import pulumi
    import json
    import pulumi_logdna as logdna
    
    managed = logdna.Alert("managed",
        email_channels=[{
            "emails": ["test@logdna.com"],
            "immediate": "false",
            "operator": "presence",
            "triggerlimit": 15,
            "triggerinterval": "15m",
            "terminal": "true",
            "timezone": "Pacific/Samoa",
        }],
        pagerduty_channels=[{
            "immediate": "true",
            "key": "Your PagerDuty API key goes here",
            "terminal": "true",
            "triggerinterval": "15m",
            "triggerlimit": 15,
        }],
        slack_channels=[{
            "immediate": "false",
            "operator": "absence",
            "terminal": "true",
            "triggerinterval": "15m",
            "triggerlimit": 15,
            "url": "https://hooks.slack.com/services/identifier/secret",
        }],
        webhook_channels=[{
            "bodytemplate": json.dumps({
                "message": "Alerts from {{name}}",
            }),
            "headers": {
                "Authentication": "auth_header_value",
                "HeaderTwo": "ValueTwo",
            },
            "immediate": "false",
            "method": "post",
            "terminal": "true",
            "triggerinterval": "15m",
            "triggerlimit": 15,
            "url": "https://yourwebhook/endpoint",
        }])
    managed_remote = logdna.get_alert_output(presetid=managed.alert_id)
    external_remote = logdna.get_alert(presetid="xxxxxxxxxx")
    # pass in data source attributes as arguments for module(s) declared in the same config
    test = logdna.View("test",
        query="level:debug my query",
        email_channels=managed_remote.email_channels,
        pagerduty_channels=external_remote.pagerduty_channels,
        slack_channels=external_remote.slack_channels,
        webhook_channels=external_remote.webhook_channels)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/logdna/logdna"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"message": "Alerts from {{name}}",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		managed, err := logdna.NewAlert(ctx, "managed", &logdna.AlertArgs{
    			EmailChannels: logdna.AlertEmailChannelArray{
    				&logdna.AlertEmailChannelArgs{
    					Emails: pulumi.StringArray{
    						pulumi.String("test@logdna.com"),
    					},
    					Immediate:       pulumi.String("false"),
    					Operator:        pulumi.String("presence"),
    					Triggerlimit:    pulumi.Float64(15),
    					Triggerinterval: pulumi.String("15m"),
    					Terminal:        pulumi.String("true"),
    					Timezone:        pulumi.String("Pacific/Samoa"),
    				},
    			},
    			PagerdutyChannels: logdna.AlertPagerdutyChannelArray{
    				&logdna.AlertPagerdutyChannelArgs{
    					Immediate:       pulumi.String("true"),
    					Key:             pulumi.String("Your PagerDuty API key goes here"),
    					Terminal:        pulumi.String("true"),
    					Triggerinterval: pulumi.String("15m"),
    					Triggerlimit:    pulumi.Float64(15),
    				},
    			},
    			SlackChannels: logdna.AlertSlackChannelArray{
    				&logdna.AlertSlackChannelArgs{
    					Immediate:       pulumi.String("false"),
    					Operator:        pulumi.String("absence"),
    					Terminal:        pulumi.String("true"),
    					Triggerinterval: pulumi.String("15m"),
    					Triggerlimit:    pulumi.Float64(15),
    					Url:             pulumi.String("https://hooks.slack.com/services/identifier/secret"),
    				},
    			},
    			WebhookChannels: logdna.AlertWebhookChannelArray{
    				&logdna.AlertWebhookChannelArgs{
    					Bodytemplate: pulumi.String(json0),
    					Headers: pulumi.StringMap{
    						"Authentication": pulumi.String("auth_header_value"),
    						"HeaderTwo":      pulumi.String("ValueTwo"),
    					},
    					Immediate:       pulumi.String("false"),
    					Method:          pulumi.String("post"),
    					Terminal:        pulumi.String("true"),
    					Triggerinterval: pulumi.String("15m"),
    					Triggerlimit:    pulumi.Float64(15),
    					Url:             pulumi.String("https://yourwebhook/endpoint"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		managedRemote := logdna.LookupAlertOutput(ctx, logdna.GetAlertOutputArgs{
    			Presetid: managed.AlertId,
    		}, nil)
    		externalRemote, err := logdna.LookupAlert(ctx, &logdna.LookupAlertArgs{
    			Presetid: "xxxxxxxxxx",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// pass in data source attributes as arguments for module(s) declared in the same config
    		_, err = logdna.NewView(ctx, "test", &logdna.ViewArgs{
    			Query: pulumi.String("level:debug my query"),
    			EmailChannels: []logdna.ViewEmailChannel(managedRemote.ApplyT(func(managedRemote logdna.GetAlertResult) ([]logdna.GetAlertEmailChannel, error) {
    				return []logdna.GetAlertEmailChannel(managedRemote.EmailChannels), nil
    			}).([]logdna.GetAlertEmailChannelOutput)),
    			PagerdutyChannels: []logdna.GetAlertPagerdutyChannel(externalRemote.PagerdutyChannels),
    			SlackChannels:     []logdna.GetAlertSlackChannel(externalRemote.SlackChannels),
    			WebhookChannels:   []logdna.GetAlertWebhookChannel(externalRemote.WebhookChannels),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Logdna = Pulumi.Logdna;
    
    return await Deployment.RunAsync(() => 
    {
        var managed = new Logdna.Alert("managed", new()
        {
            EmailChannels = new[]
            {
                new Logdna.Inputs.AlertEmailChannelArgs
                {
                    Emails = new[]
                    {
                        "test@logdna.com",
                    },
                    Immediate = "false",
                    Operator = "presence",
                    Triggerlimit = 15,
                    Triggerinterval = "15m",
                    Terminal = "true",
                    Timezone = "Pacific/Samoa",
                },
            },
            PagerdutyChannels = new[]
            {
                new Logdna.Inputs.AlertPagerdutyChannelArgs
                {
                    Immediate = "true",
                    Key = "Your PagerDuty API key goes here",
                    Terminal = "true",
                    Triggerinterval = "15m",
                    Triggerlimit = 15,
                },
            },
            SlackChannels = new[]
            {
                new Logdna.Inputs.AlertSlackChannelArgs
                {
                    Immediate = "false",
                    Operator = "absence",
                    Terminal = "true",
                    Triggerinterval = "15m",
                    Triggerlimit = 15,
                    Url = "https://hooks.slack.com/services/identifier/secret",
                },
            },
            WebhookChannels = new[]
            {
                new Logdna.Inputs.AlertWebhookChannelArgs
                {
                    Bodytemplate = JsonSerializer.Serialize(new Dictionary<string, object?>
                    {
                        ["message"] = "Alerts from {{name}}",
                    }),
                    Headers = 
                    {
                        { "Authentication", "auth_header_value" },
                        { "HeaderTwo", "ValueTwo" },
                    },
                    Immediate = "false",
                    Method = "post",
                    Terminal = "true",
                    Triggerinterval = "15m",
                    Triggerlimit = 15,
                    Url = "https://yourwebhook/endpoint",
                },
            },
        });
    
        var managedRemote = Logdna.GetAlert.Invoke(new()
        {
            Presetid = managed.AlertId,
        });
    
        var externalRemote = Logdna.GetAlert.Invoke(new()
        {
            Presetid = "xxxxxxxxxx",
        });
    
        // pass in data source attributes as arguments for module(s) declared in the same config
        var test = new Logdna.View("test", new()
        {
            Query = "level:debug my query",
            EmailChannels = managedRemote.Apply(getAlertResult => getAlertResult.EmailChannels),
            PagerdutyChannels = externalRemote.Apply(getAlertResult => getAlertResult.PagerdutyChannels),
            SlackChannels = externalRemote.Apply(getAlertResult => getAlertResult.SlackChannels),
            WebhookChannels = externalRemote.Apply(getAlertResult => getAlertResult.WebhookChannels),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.logdna.Alert;
    import com.pulumi.logdna.AlertArgs;
    import com.pulumi.logdna.inputs.AlertEmailChannelArgs;
    import com.pulumi.logdna.inputs.AlertPagerdutyChannelArgs;
    import com.pulumi.logdna.inputs.AlertSlackChannelArgs;
    import com.pulumi.logdna.inputs.AlertWebhookChannelArgs;
    import com.pulumi.logdna.LogdnaFunctions;
    import com.pulumi.logdna.inputs.GetAlertArgs;
    import com.pulumi.logdna.View;
    import com.pulumi.logdna.ViewArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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) {
            var managed = new Alert("managed", AlertArgs.builder()
                .emailChannels(AlertEmailChannelArgs.builder()
                    .emails("test@logdna.com")
                    .immediate("false")
                    .operator("presence")
                    .triggerlimit(15)
                    .triggerinterval("15m")
                    .terminal("true")
                    .timezone("Pacific/Samoa")
                    .build())
                .pagerdutyChannels(AlertPagerdutyChannelArgs.builder()
                    .immediate("true")
                    .key("Your PagerDuty API key goes here")
                    .terminal("true")
                    .triggerinterval("15m")
                    .triggerlimit(15)
                    .build())
                .slackChannels(AlertSlackChannelArgs.builder()
                    .immediate("false")
                    .operator("absence")
                    .terminal("true")
                    .triggerinterval("15m")
                    .triggerlimit(15)
                    .url("https://hooks.slack.com/services/identifier/secret")
                    .build())
                .webhookChannels(AlertWebhookChannelArgs.builder()
                    .bodytemplate(serializeJson(
                        jsonObject(
                            jsonProperty("message", "Alerts from {{name}}")
                        )))
                    .headers(Map.ofEntries(
                        Map.entry("Authentication", "auth_header_value"),
                        Map.entry("HeaderTwo", "ValueTwo")
                    ))
                    .immediate("false")
                    .method("post")
                    .terminal("true")
                    .triggerinterval("15m")
                    .triggerlimit(15)
                    .url("https://yourwebhook/endpoint")
                    .build())
                .build());
    
            final var managedRemote = LogdnaFunctions.getAlert(GetAlertArgs.builder()
                .presetid(managed.alertId())
                .build());
    
            final var externalRemote = LogdnaFunctions.getAlert(GetAlertArgs.builder()
                .presetid("xxxxxxxxxx")
                .build());
    
            // pass in data source attributes as arguments for module(s) declared in the same config
            var test = new View("test", ViewArgs.builder()
                .query("level:debug my query")
                .emailChannels(managedRemote.applyValue(getAlertResult -> getAlertResult).applyValue(managedRemote -> managedRemote.applyValue(getAlertResult -> getAlertResult.emailChannels())))
                .pagerdutyChannels(externalRemote.applyValue(getAlertResult -> getAlertResult.pagerdutyChannels()))
                .slackChannels(externalRemote.applyValue(getAlertResult -> getAlertResult.slackChannels()))
                .webhookChannels(externalRemote.applyValue(getAlertResult -> getAlertResult.webhookChannels()))
                .build());
    
        }
    }
    
    resources:
      managed:
        type: logdna:Alert
        properties:
          emailChannels:
            - emails:
                - test@logdna.com
              immediate: 'false'
              operator: presence
              triggerlimit: 15
              triggerinterval: 15m
              terminal: 'true'
              timezone: Pacific/Samoa
          pagerdutyChannels:
            - immediate: 'true'
              key: Your PagerDuty API key goes here
              terminal: 'true'
              triggerinterval: 15m
              triggerlimit: 15
          slackChannels:
            - immediate: 'false'
              operator: absence
              terminal: 'true'
              triggerinterval: 15m
              triggerlimit: 15
              url: https://hooks.slack.com/services/identifier/secret
          webhookChannels:
            - bodytemplate:
                fn::toJSON:
                  message: Alerts from {{name}}
              headers:
                Authentication: auth_header_value
                HeaderTwo: ValueTwo
              immediate: 'false'
              method: post
              terminal: 'true'
              triggerinterval: 15m
              triggerlimit: 15
              url: https://yourwebhook/endpoint
      # pass in data source attributes as arguments for module(s) declared in the same config
      test:
        type: logdna:View
        properties:
          query: level:debug my query
          emailChannels: ${managedRemote.emailChannels}
          pagerdutyChannels: ${externalRemote.pagerdutyChannels}
          slackChannels: ${externalRemote.slackChannels}
          webhookChannels: ${externalRemote.webhookChannels}
    variables:
      managedRemote:
        fn::invoke:
          function: logdna:getAlert
          arguments:
            presetid: ${managed.alertId}
      externalRemote:
        fn::invoke:
          function: logdna:getAlert
          arguments:
            presetid: xxxxxxxxxx
    

    Using getAlert

    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 getAlert(args: GetAlertArgs, opts?: InvokeOptions): Promise<GetAlertResult>
    function getAlertOutput(args: GetAlertOutputArgs, opts?: InvokeOptions): Output<GetAlertResult>
    def get_alert(id: Optional[str] = None,
                  presetid: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetAlertResult
    def get_alert_output(id: Optional[pulumi.Input[str]] = None,
                  presetid: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetAlertResult]
    func LookupAlert(ctx *Context, args *LookupAlertArgs, opts ...InvokeOption) (*LookupAlertResult, error)
    func LookupAlertOutput(ctx *Context, args *LookupAlertOutputArgs, opts ...InvokeOption) LookupAlertResultOutput

    > Note: This function is named LookupAlert in the Go SDK.

    public static class GetAlert 
    {
        public static Task<GetAlertResult> InvokeAsync(GetAlertArgs args, InvokeOptions? opts = null)
        public static Output<GetAlertResult> Invoke(GetAlertInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetAlertResult> getAlert(GetAlertArgs args, InvokeOptions options)
    public static Output<GetAlertResult> getAlert(GetAlertArgs args, InvokeOptions options)
    
    fn::invoke:
      function: logdna:index/getAlert:getAlert
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Presetid string
    Id string
    Presetid string
    Id string
    presetid String
    id String
    presetid string
    id string
    presetid str
    id str
    presetid String
    id String

    getAlert Result

    The following output properties are available:

    EmailChannels List<GetAlertEmailChannel>
    List of notifications configured via email in the given preset alert
    Id string
    Name string
    Name of the given preset alert
    PagerdutyChannels List<GetAlertPagerdutyChannel>
    List of notifications configured via PagerDuty in the given preset alert
    Presetid string
    SlackChannels List<GetAlertSlackChannel>
    List of notifications configured via Slack in the given preset alert
    WebhookChannels List<GetAlertWebhookChannel>
    List of notifications configured via webhook(s) in the given preset alert
    EmailChannels []GetAlertEmailChannel
    List of notifications configured via email in the given preset alert
    Id string
    Name string
    Name of the given preset alert
    PagerdutyChannels []GetAlertPagerdutyChannel
    List of notifications configured via PagerDuty in the given preset alert
    Presetid string
    SlackChannels []GetAlertSlackChannel
    List of notifications configured via Slack in the given preset alert
    WebhookChannels []GetAlertWebhookChannel
    List of notifications configured via webhook(s) in the given preset alert
    emailChannels List<GetAlertEmailChannel>
    List of notifications configured via email in the given preset alert
    id String
    name String
    Name of the given preset alert
    pagerdutyChannels List<GetAlertPagerdutyChannel>
    List of notifications configured via PagerDuty in the given preset alert
    presetid String
    slackChannels List<GetAlertSlackChannel>
    List of notifications configured via Slack in the given preset alert
    webhookChannels List<GetAlertWebhookChannel>
    List of notifications configured via webhook(s) in the given preset alert
    emailChannels GetAlertEmailChannel[]
    List of notifications configured via email in the given preset alert
    id string
    name string
    Name of the given preset alert
    pagerdutyChannels GetAlertPagerdutyChannel[]
    List of notifications configured via PagerDuty in the given preset alert
    presetid string
    slackChannels GetAlertSlackChannel[]
    List of notifications configured via Slack in the given preset alert
    webhookChannels GetAlertWebhookChannel[]
    List of notifications configured via webhook(s) in the given preset alert
    email_channels Sequence[GetAlertEmailChannel]
    List of notifications configured via email in the given preset alert
    id str
    name str
    Name of the given preset alert
    pagerduty_channels Sequence[GetAlertPagerdutyChannel]
    List of notifications configured via PagerDuty in the given preset alert
    presetid str
    slack_channels Sequence[GetAlertSlackChannel]
    List of notifications configured via Slack in the given preset alert
    webhook_channels Sequence[GetAlertWebhookChannel]
    List of notifications configured via webhook(s) in the given preset alert
    emailChannels List<Property Map>
    List of notifications configured via email in the given preset alert
    id String
    name String
    Name of the given preset alert
    pagerdutyChannels List<Property Map>
    List of notifications configured via PagerDuty in the given preset alert
    presetid String
    slackChannels List<Property Map>
    List of notifications configured via Slack in the given preset alert
    webhookChannels List<Property Map>
    List of notifications configured via webhook(s) in the given preset alert

    Supporting Types

    GetAlertEmailChannel

    Emails List<string>
    Immediate string
    Operator string
    Terminal string
    Timezone string
    Triggerinterval string
    Triggerlimit double
    Emails []string
    Immediate string
    Operator string
    Terminal string
    Timezone string
    Triggerinterval string
    Triggerlimit float64
    emails List<String>
    immediate String
    operator String
    terminal String
    timezone String
    triggerinterval String
    triggerlimit Double
    emails string[]
    immediate string
    operator string
    terminal string
    timezone string
    triggerinterval string
    triggerlimit number
    emails List<String>
    immediate String
    operator String
    terminal String
    timezone String
    triggerinterval String
    triggerlimit Number

    GetAlertPagerdutyChannel

    GetAlertSlackChannel

    Immediate string
    Operator string
    Terminal string
    Triggerinterval string
    Triggerlimit double
    Url string
    Immediate string
    Operator string
    Terminal string
    Triggerinterval string
    Triggerlimit float64
    Url string
    immediate String
    operator String
    terminal String
    triggerinterval String
    triggerlimit Double
    url String
    immediate string
    operator string
    terminal string
    triggerinterval string
    triggerlimit number
    url string
    immediate String
    operator String
    terminal String
    triggerinterval String
    triggerlimit Number
    url String

    GetAlertWebhookChannel

    Bodytemplate string
    Headers Dictionary<string, string>
    Immediate string
    Method string
    Operator string
    Terminal string
    Triggerinterval string
    Triggerlimit double
    Url string
    Bodytemplate string
    Headers map[string]string
    Immediate string
    Method string
    Operator string
    Terminal string
    Triggerinterval string
    Triggerlimit float64
    Url string
    bodytemplate String
    headers Map<String,String>
    immediate String
    method String
    operator String
    terminal String
    triggerinterval String
    triggerlimit Double
    url String
    bodytemplate string
    headers {[key: string]: string}
    immediate string
    method string
    operator string
    terminal string
    triggerinterval string
    triggerlimit number
    url string
    bodytemplate String
    headers Map<String>
    immediate String
    method String
    operator String
    terminal String
    triggerinterval String
    triggerlimit Number
    url String

    Package Details

    Repository
    logdna logdna/terraform-provider-logdna
    License
    Notes
    This Pulumi package is based on the logdna Terraform Provider.
    logdna logo
    logdna 1.16.0 published on Monday, Apr 14, 2025 by logdna