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

We recommend using Azure Native.

Azure v6.13.0 published on Monday, Dec 9, 2024 by Pulumi

azure.sentinel.getAlertRule

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure v6.13.0 published on Monday, Dec 9, 2024 by Pulumi

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

    Example Usage

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