1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. arms
  5. getPrometheusAlertRules
Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi

alicloud.arms.getPrometheusAlertRules

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi

    This data source provides the Arms Prometheus Alert Rules of the current Alibaba Cloud user.

    NOTE: Available in v1.136.0+.

    Example Usage

    Basic Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var ids = AliCloud.Arms.GetPrometheusAlertRules.Invoke(new()
        {
            ClusterId = "example_value",
            Ids = new[]
            {
                "example_value-1",
                "example_value-2",
            },
        });
    
        var nameRegex = AliCloud.Arms.GetPrometheusAlertRules.Invoke(new()
        {
            ClusterId = "example_value",
            NameRegex = "^my-PrometheusAlertRule",
        });
    
        return new Dictionary<string, object?>
        {
            ["armsPrometheusAlertRuleId1"] = ids.Apply(getPrometheusAlertRulesResult => getPrometheusAlertRulesResult.Rules[0]?.Id),
            ["armsPrometheusAlertRuleId2"] = nameRegex.Apply(getPrometheusAlertRulesResult => getPrometheusAlertRulesResult.Rules[0]?.Id),
        };
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/arms"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		ids, err := arms.GetPrometheusAlertRules(ctx, &arms.GetPrometheusAlertRulesArgs{
    			ClusterId: "example_value",
    			Ids: []string{
    				"example_value-1",
    				"example_value-2",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("armsPrometheusAlertRuleId1", ids.Rules[0].Id)
    		nameRegex, err := arms.GetPrometheusAlertRules(ctx, &arms.GetPrometheusAlertRulesArgs{
    			ClusterId: "example_value",
    			NameRegex: pulumi.StringRef("^my-PrometheusAlertRule"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("armsPrometheusAlertRuleId2", nameRegex.Rules[0].Id)
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.arms.ArmsFunctions;
    import com.pulumi.alicloud.arms.inputs.GetPrometheusAlertRulesArgs;
    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 ids = ArmsFunctions.getPrometheusAlertRules(GetPrometheusAlertRulesArgs.builder()
                .clusterId("example_value")
                .ids(            
                    "example_value-1",
                    "example_value-2")
                .build());
    
            ctx.export("armsPrometheusAlertRuleId1", ids.applyValue(getPrometheusAlertRulesResult -> getPrometheusAlertRulesResult.rules()[0].id()));
            final var nameRegex = ArmsFunctions.getPrometheusAlertRules(GetPrometheusAlertRulesArgs.builder()
                .clusterId("example_value")
                .nameRegex("^my-PrometheusAlertRule")
                .build());
    
            ctx.export("armsPrometheusAlertRuleId2", nameRegex.applyValue(getPrometheusAlertRulesResult -> getPrometheusAlertRulesResult.rules()[0].id()));
        }
    }
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    ids = alicloud.arms.get_prometheus_alert_rules(cluster_id="example_value",
        ids=[
            "example_value-1",
            "example_value-2",
        ])
    pulumi.export("armsPrometheusAlertRuleId1", ids.rules[0].id)
    name_regex = alicloud.arms.get_prometheus_alert_rules(cluster_id="example_value",
        name_regex="^my-PrometheusAlertRule")
    pulumi.export("armsPrometheusAlertRuleId2", name_regex.rules[0].id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const ids = alicloud.arms.getPrometheusAlertRules({
        clusterId: "example_value",
        ids: [
            "example_value-1",
            "example_value-2",
        ],
    });
    export const armsPrometheusAlertRuleId1 = ids.then(ids => ids.rules?.[0]?.id);
    const nameRegex = alicloud.arms.getPrometheusAlertRules({
        clusterId: "example_value",
        nameRegex: "^my-PrometheusAlertRule",
    });
    export const armsPrometheusAlertRuleId2 = nameRegex.then(nameRegex => nameRegex.rules?.[0]?.id);
    
    variables:
      ids:
        fn::invoke:
          Function: alicloud:arms:getPrometheusAlertRules
          Arguments:
            clusterId: example_value
            ids:
              - example_value-1
              - example_value-2
      nameRegex:
        fn::invoke:
          Function: alicloud:arms:getPrometheusAlertRules
          Arguments:
            clusterId: example_value
            nameRegex: ^my-PrometheusAlertRule
    outputs:
      armsPrometheusAlertRuleId1: ${ids.rules[0].id}
      armsPrometheusAlertRuleId2: ${nameRegex.rules[0].id}
    

    Using getPrometheusAlertRules

    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 getPrometheusAlertRules(args: GetPrometheusAlertRulesArgs, opts?: InvokeOptions): Promise<GetPrometheusAlertRulesResult>
    function getPrometheusAlertRulesOutput(args: GetPrometheusAlertRulesOutputArgs, opts?: InvokeOptions): Output<GetPrometheusAlertRulesResult>
    def get_prometheus_alert_rules(cluster_id: Optional[str] = None,
                                   ids: Optional[Sequence[str]] = None,
                                   match_expressions: Optional[str] = None,
                                   name_regex: Optional[str] = None,
                                   output_file: Optional[str] = None,
                                   status: Optional[int] = None,
                                   type: Optional[str] = None,
                                   opts: Optional[InvokeOptions] = None) -> GetPrometheusAlertRulesResult
    def get_prometheus_alert_rules_output(cluster_id: Optional[pulumi.Input[str]] = None,
                                   ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                                   match_expressions: Optional[pulumi.Input[str]] = None,
                                   name_regex: Optional[pulumi.Input[str]] = None,
                                   output_file: Optional[pulumi.Input[str]] = None,
                                   status: Optional[pulumi.Input[int]] = None,
                                   type: Optional[pulumi.Input[str]] = None,
                                   opts: Optional[InvokeOptions] = None) -> Output[GetPrometheusAlertRulesResult]
    func GetPrometheusAlertRules(ctx *Context, args *GetPrometheusAlertRulesArgs, opts ...InvokeOption) (*GetPrometheusAlertRulesResult, error)
    func GetPrometheusAlertRulesOutput(ctx *Context, args *GetPrometheusAlertRulesOutputArgs, opts ...InvokeOption) GetPrometheusAlertRulesResultOutput

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

    public static class GetPrometheusAlertRules 
    {
        public static Task<GetPrometheusAlertRulesResult> InvokeAsync(GetPrometheusAlertRulesArgs args, InvokeOptions? opts = null)
        public static Output<GetPrometheusAlertRulesResult> Invoke(GetPrometheusAlertRulesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetPrometheusAlertRulesResult> getPrometheusAlertRules(GetPrometheusAlertRulesArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:arms/getPrometheusAlertRules:getPrometheusAlertRules
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ClusterId string

    The ID of the cluster.

    Ids List<string>

    A list of Prometheus Alert Rule IDs.

    MatchExpressions string
    NameRegex string

    A regex string to filter results by Prometheus Alert Rule name.

    OutputFile string

    File name where to save data source results (after running pulumi preview).

    Status int

    The status of the resource. Valid values: 0, 1.

    Type string

    The type of the alert rule.

    ClusterId string

    The ID of the cluster.

    Ids []string

    A list of Prometheus Alert Rule IDs.

    MatchExpressions string
    NameRegex string

    A regex string to filter results by Prometheus Alert Rule name.

    OutputFile string

    File name where to save data source results (after running pulumi preview).

    Status int

    The status of the resource. Valid values: 0, 1.

    Type string

    The type of the alert rule.

    clusterId String

    The ID of the cluster.

    ids List<String>

    A list of Prometheus Alert Rule IDs.

    matchExpressions String
    nameRegex String

    A regex string to filter results by Prometheus Alert Rule name.

    outputFile String

    File name where to save data source results (after running pulumi preview).

    status Integer

    The status of the resource. Valid values: 0, 1.

    type String

    The type of the alert rule.

    clusterId string

    The ID of the cluster.

    ids string[]

    A list of Prometheus Alert Rule IDs.

    matchExpressions string
    nameRegex string

    A regex string to filter results by Prometheus Alert Rule name.

    outputFile string

    File name where to save data source results (after running pulumi preview).

    status number

    The status of the resource. Valid values: 0, 1.

    type string

    The type of the alert rule.

    cluster_id str

    The ID of the cluster.

    ids Sequence[str]

    A list of Prometheus Alert Rule IDs.

    match_expressions str
    name_regex str

    A regex string to filter results by Prometheus Alert Rule name.

    output_file str

    File name where to save data source results (after running pulumi preview).

    status int

    The status of the resource. Valid values: 0, 1.

    type str

    The type of the alert rule.

    clusterId String

    The ID of the cluster.

    ids List<String>

    A list of Prometheus Alert Rule IDs.

    matchExpressions String
    nameRegex String

    A regex string to filter results by Prometheus Alert Rule name.

    outputFile String

    File name where to save data source results (after running pulumi preview).

    status Number

    The status of the resource. Valid values: 0, 1.

    type String

    The type of the alert rule.

    getPrometheusAlertRules Result

    The following output properties are available:

    ClusterId string
    Id string

    The provider-assigned unique ID for this managed resource.

    Ids List<string>
    Names List<string>
    Rules List<Pulumi.AliCloud.Arms.Outputs.GetPrometheusAlertRulesRule>
    MatchExpressions string
    NameRegex string
    OutputFile string
    Status int
    Type string
    ClusterId string
    Id string

    The provider-assigned unique ID for this managed resource.

    Ids []string
    Names []string
    Rules []GetPrometheusAlertRulesRule
    MatchExpressions string
    NameRegex string
    OutputFile string
    Status int
    Type string
    clusterId String
    id String

    The provider-assigned unique ID for this managed resource.

    ids List<String>
    names List<String>
    rules List<GetPrometheusAlertRulesRule>
    matchExpressions String
    nameRegex String
    outputFile String
    status Integer
    type String
    clusterId string
    id string

    The provider-assigned unique ID for this managed resource.

    ids string[]
    names string[]
    rules GetPrometheusAlertRulesRule[]
    matchExpressions string
    nameRegex string
    outputFile string
    status number
    type string
    cluster_id str
    id str

    The provider-assigned unique ID for this managed resource.

    ids Sequence[str]
    names Sequence[str]
    rules Sequence[GetPrometheusAlertRulesRule]
    match_expressions str
    name_regex str
    output_file str
    status int
    type str
    clusterId String
    id String

    The provider-assigned unique ID for this managed resource.

    ids List<String>
    names List<String>
    rules List<Property Map>
    matchExpressions String
    nameRegex String
    outputFile String
    status Number
    type String

    Supporting Types

    GetPrometheusAlertRulesRule

    Annotations List<Pulumi.AliCloud.Arms.Inputs.GetPrometheusAlertRulesRuleAnnotation>

    The annotations of the alert rule.

    ClusterId string

    The ID of the cluster.

    DispatchRuleId string

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    Duration string

    The duration of the alert.

    Expression string

    The alert rule expression that follows the PromQL syntax..

    Id string

    The ID of the Prometheus Alert Rule.

    Labels List<Pulumi.AliCloud.Arms.Inputs.GetPrometheusAlertRulesRuleLabel>

    The labels of the resource.

    Message string

    The message of the alert notification.

    NotifyType string

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    PrometheusAlertRuleId string

    The first ID of the resource.

    PrometheusAlertRuleName string

    The name of the resource.

    Status int

    The status of the resource. Valid values: 0, 1.

    Type string

    The type of the alert rule.

    Annotations []GetPrometheusAlertRulesRuleAnnotation

    The annotations of the alert rule.

    ClusterId string

    The ID of the cluster.

    DispatchRuleId string

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    Duration string

    The duration of the alert.

    Expression string

    The alert rule expression that follows the PromQL syntax..

    Id string

    The ID of the Prometheus Alert Rule.

    Labels []GetPrometheusAlertRulesRuleLabel

    The labels of the resource.

    Message string

    The message of the alert notification.

    NotifyType string

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    PrometheusAlertRuleId string

    The first ID of the resource.

    PrometheusAlertRuleName string

    The name of the resource.

    Status int

    The status of the resource. Valid values: 0, 1.

    Type string

    The type of the alert rule.

    annotations List<GetPrometheusAlertRulesRuleAnnotation>

    The annotations of the alert rule.

    clusterId String

    The ID of the cluster.

    dispatchRuleId String

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    duration String

    The duration of the alert.

    expression String

    The alert rule expression that follows the PromQL syntax..

    id String

    The ID of the Prometheus Alert Rule.

    labels List<GetPrometheusAlertRulesRuleLabel>

    The labels of the resource.

    message String

    The message of the alert notification.

    notifyType String

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    prometheusAlertRuleId String

    The first ID of the resource.

    prometheusAlertRuleName String

    The name of the resource.

    status Integer

    The status of the resource. Valid values: 0, 1.

    type String

    The type of the alert rule.

    annotations GetPrometheusAlertRulesRuleAnnotation[]

    The annotations of the alert rule.

    clusterId string

    The ID of the cluster.

    dispatchRuleId string

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    duration string

    The duration of the alert.

    expression string

    The alert rule expression that follows the PromQL syntax..

    id string

    The ID of the Prometheus Alert Rule.

    labels GetPrometheusAlertRulesRuleLabel[]

    The labels of the resource.

    message string

    The message of the alert notification.

    notifyType string

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    prometheusAlertRuleId string

    The first ID of the resource.

    prometheusAlertRuleName string

    The name of the resource.

    status number

    The status of the resource. Valid values: 0, 1.

    type string

    The type of the alert rule.

    annotations Sequence[GetPrometheusAlertRulesRuleAnnotation]

    The annotations of the alert rule.

    cluster_id str

    The ID of the cluster.

    dispatch_rule_id str

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    duration str

    The duration of the alert.

    expression str

    The alert rule expression that follows the PromQL syntax..

    id str

    The ID of the Prometheus Alert Rule.

    labels Sequence[GetPrometheusAlertRulesRuleLabel]

    The labels of the resource.

    message str

    The message of the alert notification.

    notify_type str

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    prometheus_alert_rule_id str

    The first ID of the resource.

    prometheus_alert_rule_name str

    The name of the resource.

    status int

    The status of the resource. Valid values: 0, 1.

    type str

    The type of the alert rule.

    annotations List<Property Map>

    The annotations of the alert rule.

    clusterId String

    The ID of the cluster.

    dispatchRuleId String

    The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

    duration String

    The duration of the alert.

    expression String

    The alert rule expression that follows the PromQL syntax..

    id String

    The ID of the Prometheus Alert Rule.

    labels List<Property Map>

    The labels of the resource.

    message String

    The message of the alert notification.

    notifyType String

    The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

    prometheusAlertRuleId String

    The first ID of the resource.

    prometheusAlertRuleName String

    The name of the resource.

    status Number

    The status of the resource. Valid values: 0, 1.

    type String

    The type of the alert rule.

    GetPrometheusAlertRulesRuleAnnotation

    Name string

    The name of the label.

    Value string

    The value of the label.

    Name string

    The name of the label.

    Value string

    The value of the label.

    name String

    The name of the label.

    value String

    The value of the label.

    name string

    The name of the label.

    value string

    The value of the label.

    name str

    The name of the label.

    value str

    The value of the label.

    name String

    The name of the label.

    value String

    The value of the label.

    GetPrometheusAlertRulesRuleLabel

    Name string

    The name of the label.

    Value string

    The value of the label.

    Name string

    The name of the label.

    Value string

    The value of the label.

    name String

    The name of the label.

    value String

    The value of the label.

    name string

    The name of the label.

    value string

    The value of the label.

    name str

    The name of the label.

    value str

    The value of the label.

    name String

    The name of the label.

    value String

    The value of the label.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the alicloud Terraform Provider.

    alicloud logo
    Alibaba Cloud v3.45.0 published on Monday, Nov 27, 2023 by Pulumi