1. Packages
  2. Azure Classic
  3. API Docs
  4. sentinel
  5. getAlertRule

We recommend using Azure Native.

Azure Classic v5.49.0 published on Tuesday, Aug 29, 2023 by Pulumi

azure.sentinel.getAlertRule

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.49.0 published on Tuesday, Aug 29, 2023 by Pulumi

    Use this data source to access information about an existing Sentinel Alert Rule.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleAnalyticsWorkspace = Azure.OperationalInsights.GetAnalyticsWorkspace.Invoke(new()
        {
            Name = "example",
            ResourceGroupName = "example-resources",
        });
    
        var exampleAlertRule = Azure.Sentinel.GetAlertRule.Invoke(new()
        {
            Name = "existing",
            LogAnalyticsWorkspaceId = exampleAnalyticsWorkspace.Apply(getAnalyticsWorkspaceResult => getAnalyticsWorkspaceResult.Id),
        });
    
        return new Dictionary<string, object?>
        {
            ["id"] = exampleAlertRule.Apply(getAlertRuleResult => getAlertRuleResult.Id),
        };
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sentinel"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleAnalyticsWorkspace, err := operationalinsights.LookupAnalyticsWorkspace(ctx, &operationalinsights.LookupAnalyticsWorkspaceArgs{
    			Name:              "example",
    			ResourceGroupName: "example-resources",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleAlertRule, err := sentinel.GetAlertRule(ctx, &sentinel.GetAlertRuleArgs{
    			Name:                    "existing",
    			LogAnalyticsWorkspaceId: exampleAnalyticsWorkspace.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("id", exampleAlertRule.Id)
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.operationalinsights.OperationalinsightsFunctions;
    import com.pulumi.azure.operationalinsights.inputs.GetAnalyticsWorkspaceArgs;
    import com.pulumi.azure.sentinel.SentinelFunctions;
    import com.pulumi.azure.sentinel.inputs.GetAlertRuleArgs;
    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 exampleAnalyticsWorkspace = OperationalinsightsFunctions.getAnalyticsWorkspace(GetAnalyticsWorkspaceArgs.builder()
                .name("example")
                .resourceGroupName("example-resources")
                .build());
    
            final var exampleAlertRule = SentinelFunctions.getAlertRule(GetAlertRuleArgs.builder()
                .name("existing")
                .logAnalyticsWorkspaceId(exampleAnalyticsWorkspace.applyValue(getAnalyticsWorkspaceResult -> getAnalyticsWorkspaceResult.id()))
                .build());
    
            ctx.export("id", exampleAlertRule.applyValue(getAlertRuleResult -> getAlertRuleResult.id()));
        }
    }
    
    import pulumi
    import pulumi_azure as azure
    
    example_analytics_workspace = azure.operationalinsights.get_analytics_workspace(name="example",
        resource_group_name="example-resources")
    example_alert_rule = azure.sentinel.get_alert_rule(name="existing",
        log_analytics_workspace_id=example_analytics_workspace.id)
    pulumi.export("id", example_alert_rule.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleAnalyticsWorkspace = azure.operationalinsights.getAnalyticsWorkspace({
        name: "example",
        resourceGroupName: "example-resources",
    });
    const exampleAlertRule = exampleAnalyticsWorkspace.then(exampleAnalyticsWorkspace => azure.sentinel.getAlertRule({
        name: "existing",
        logAnalyticsWorkspaceId: exampleAnalyticsWorkspace.id,
    }));
    export const id = exampleAlertRule.then(exampleAlertRule => exampleAlertRule.id);
    
    variables:
      exampleAnalyticsWorkspace:
        fn::invoke:
          Function: azure:operationalinsights:getAnalyticsWorkspace
          Arguments:
            name: example
            resourceGroupName: example-resources
      exampleAlertRule:
        fn::invoke:
          Function: azure:sentinel:getAlertRule
          Arguments:
            name: existing
            logAnalyticsWorkspaceId: ${exampleAnalyticsWorkspace.id}
    outputs:
      id: ${exampleAlertRule.id}
    

    Using getAlertRule

    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 getAlertRule(args: GetAlertRuleArgs, opts?: InvokeOptions): Promise<GetAlertRuleResult>
    function getAlertRuleOutput(args: GetAlertRuleOutputArgs, opts?: InvokeOptions): Output<GetAlertRuleResult>
    def get_alert_rule(log_analytics_workspace_id: Optional[str] = None,
                       name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetAlertRuleResult
    def get_alert_rule_output(log_analytics_workspace_id: Optional[pulumi.Input[str]] = None,
                       name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetAlertRuleResult]
    func GetAlertRule(ctx *Context, args *GetAlertRuleArgs, opts ...InvokeOption) (*GetAlertRuleResult, error)
    func GetAlertRuleOutput(ctx *Context, args *GetAlertRuleOutputArgs, opts ...InvokeOption) GetAlertRuleResultOutput

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

    public static class GetAlertRule 
    {
        public static Task<GetAlertRuleResult> InvokeAsync(GetAlertRuleArgs args, InvokeOptions? opts = null)
        public static Output<GetAlertRuleResult> Invoke(GetAlertRuleInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetAlertRuleResult> getAlertRule(GetAlertRuleArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azure:sentinel/getAlertRule:getAlertRule
      arguments:
        # arguments dictionary

    The following arguments are supported:

    LogAnalyticsWorkspaceId string

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    Name string

    The name which should be used for this Sentinel Alert Rule.

    LogAnalyticsWorkspaceId string

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    Name string

    The name which should be used for this Sentinel Alert Rule.

    logAnalyticsWorkspaceId String

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    name String

    The name which should be used for this Sentinel Alert Rule.

    logAnalyticsWorkspaceId string

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    name string

    The name which should be used for this Sentinel Alert Rule.

    log_analytics_workspace_id str

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    name str

    The name which should be used for this Sentinel Alert Rule.

    logAnalyticsWorkspaceId String

    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.

    name String

    The name which should be used for this Sentinel Alert Rule.

    getAlertRule Result

    The following output properties are available:

    Id string

    The provider-assigned unique ID for this managed resource.

    LogAnalyticsWorkspaceId string
    Name string
    Id string

    The provider-assigned unique ID for this managed resource.

    LogAnalyticsWorkspaceId string
    Name string
    id String

    The provider-assigned unique ID for this managed resource.

    logAnalyticsWorkspaceId String
    name String
    id string

    The provider-assigned unique ID for this managed resource.

    logAnalyticsWorkspaceId string
    name string
    id str

    The provider-assigned unique ID for this managed resource.

    log_analytics_workspace_id str
    name str
    id String

    The provider-assigned unique ID for this managed resource.

    logAnalyticsWorkspaceId String
    name String

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the azurerm Terraform Provider.

    azure logo

    We recommend using Azure Native.

    Azure Classic v5.49.0 published on Tuesday, Aug 29, 2023 by Pulumi