// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.AliCloud.Cms
{
    /// <summary>
    /// This resource provides a alarm rule resource and it can be used to monitor several cloud services according different metrics.
    /// Details for [alarm rule](https://www.alibabacloud.com/help/doc-detail/28608.htm).
    /// 
    /// ## Example Usage
    /// 
    /// Basic Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var basic = new AliCloud.Cms.Alarm("basic", new()
    ///     {
    ///         ContactGroups = new[]
    ///         {
    ///             "test-group",
    ///         },
    ///         EffectiveInterval = "0:00-2:00",
    ///         EscalationsCritical = new AliCloud.Cms.Inputs.AlarmEscalationsCriticalArgs
    ///         {
    ///             ComparisonOperator = "&lt;=",
    ///             Statistics = "Average",
    ///             Threshold = "35",
    ///             Times = 2,
    ///         },
    ///         MetricDimensions = "[{\"instanceId\":\"i-bp1247jeep0y53nu3bnk\",\"device\":\"/dev/vda1\"},{\"instanceId\":\"i-bp11gdcik8z6dl5jm84p\",\"device\":\"/dev/vdb1\"}]",
    ///         Period = 900,
    ///         Project = "acs_ecs_dashboard",
    ///         Webhook = $"https://{data.Alicloud_account.Current.Id}.eu-central-1.fc.aliyuncs.com/2016-08-15/proxy/Terraform/AlarmEndpointMock/",
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// Alarm rule can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:cms/alarm:Alarm alarm abc12345
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:cms/alarm:Alarm")]
    public partial class Alarm : global::Pulumi.CustomResource
    {
        /// <summary>
        /// List contact groups of the alarm rule, which must have been created on the console.
        /// </summary>
        [Output("contactGroups")]
        public Output<ImmutableArray<string>> ContactGroups { get; private set; } = null!;

        /// <summary>
        /// Field `dimensions` has been deprecated from version 1.95.0. Use `metric_dimensions` instead.
        /// </summary>
        [Output("dimensions")]
        public Output<ImmutableDictionary<string, object>> Dimensions { get; private set; } = null!;

        /// <summary>
        /// The interval of effecting alarm rule. It format as "hh:mm-hh:mm", like "0:00-4:00". Default to "00:00-23:59".
        /// </summary>
        [Output("effectiveInterval")]
        public Output<string?> EffectiveInterval { get; private set; } = null!;

        /// <summary>
        /// Whether to enable alarm rule. Default to true.
        /// </summary>
        [Output("enabled")]
        public Output<bool?> Enabled { get; private set; } = null!;

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Output("endTime")]
        public Output<int?> EndTime { get; private set; } = null!;

        /// <summary>
        /// A configuration of critical alarm (documented below).
        /// </summary>
        [Output("escalationsCritical")]
        public Output<Outputs.AlarmEscalationsCritical?> EscalationsCritical { get; private set; } = null!;

        /// <summary>
        /// A configuration of critical info (documented below).
        /// </summary>
        [Output("escalationsInfo")]
        public Output<Outputs.AlarmEscalationsInfo?> EscalationsInfo { get; private set; } = null!;

        /// <summary>
        /// A configuration of critical warn (documented below).
        /// </summary>
        [Output("escalationsWarn")]
        public Output<Outputs.AlarmEscalationsWarn?> EscalationsWarn { get; private set; } = null!;

        /// <summary>
        /// Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Output("metric")]
        public Output<string> Metric { get; private set; } = null!;

        /// <summary>
        /// Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string, and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Output("metricDimensions")]
        public Output<string> MetricDimensions { get; private set; } = null!;

        /// <summary>
        /// The alarm rule name.
        /// </summary>
        [Output("name")]
        public Output<string> Name { get; private set; } = null!;

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.comparison_operator' instead.
        /// </summary>
        [Output("operator")]
        public Output<string> Operator { get; private set; } = null!;

        /// <summary>
        /// Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
        /// </summary>
        [Output("period")]
        public Output<int?> Period { get; private set; } = null!;

        /// <summary>
        /// Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// **NOTE:** The `dimensions` and `metric_dimensions` must be empty when `project` is `acs_prometheus`, otherwise, one of them must be set.
        /// </summary>
        [Output("project")]
        public Output<string> Project { get; private set; } = null!;

        /// <summary>
        /// The Prometheus alert rule. See the following `Block prometheus`. **Note:** This parameter is required only when you create a Prometheus alert rule for Hybrid Cloud Monitoring.
        /// </summary>
        [Output("prometheuses")]
        public Output<ImmutableArray<Outputs.AlarmPrometheus>> Prometheuses { get; private set; } = null!;

        /// <summary>
        /// Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
        /// </summary>
        [Output("silenceTime")]
        public Output<int?> SilenceTime { get; private set; } = null!;

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Output("startTime")]
        public Output<int?> StartTime { get; private set; } = null!;

        /// <summary>
        /// Critical level alarm statistics method. It must be consistent with that defined for metrics. For more information, see [How to use it](https://cms.console.aliyun.com/metric-meta/acs_ecs_dashboard/ecs).
        /// </summary>
        [Output("statistics")]
        public Output<string> Statistics { get; private set; } = null!;

        /// <summary>
        /// The current alarm rule status.
        /// </summary>
        [Output("status")]
        public Output<string> Status { get; private set; } = null!;

        /// <summary>
        /// A mapping of tags to assign to the resource.
        /// </summary>
        [Output("tags")]
        public Output<ImmutableDictionary<string, object>?> Tags { get; private set; } = null!;

        /// <summary>
        /// Critical level alarm threshold value, which must be a numeric value currently.
        /// </summary>
        [Output("threshold")]
        public Output<string> Threshold { get; private set; } = null!;

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.times' instead.
        /// </summary>
        [Output("triggeredCount")]
        public Output<int> TriggeredCount { get; private set; } = null!;

        /// <summary>
        /// The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
        /// </summary>
        [Output("webhook")]
        public Output<string?> Webhook { get; private set; } = null!;


        /// <summary>
        /// Create a Alarm resource with the given unique name, arguments, and options.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resource</param>
        /// <param name="args">The arguments used to populate this resource's properties</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public Alarm(string name, AlarmArgs args, CustomResourceOptions? options = null)
            : base("alicloud:cms/alarm:Alarm", name, args ?? new AlarmArgs(), MakeResourceOptions(options, ""))
        {
        }

        private Alarm(string name, Input<string> id, AlarmState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:cms/alarm:Alarm", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "github://api.github.com/rhysmdnz/pulumi-alicloud",
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);
            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return merged;
        }
        /// <summary>
        /// Get an existing Alarm resource's state with the given name, ID, and optional extra
        /// properties used to qualify the lookup.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resulting resource.</param>
        /// <param name="id">The unique provider ID of the resource to lookup.</param>
        /// <param name="state">Any extra arguments used during the lookup.</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public static Alarm Get(string name, Input<string> id, AlarmState? state = null, CustomResourceOptions? options = null)
        {
            return new Alarm(name, id, state, options);
        }
    }

    public sealed class AlarmArgs : global::Pulumi.ResourceArgs
    {
        [Input("contactGroups", required: true)]
        private InputList<string>? _contactGroups;

        /// <summary>
        /// List contact groups of the alarm rule, which must have been created on the console.
        /// </summary>
        public InputList<string> ContactGroups
        {
            get => _contactGroups ?? (_contactGroups = new InputList<string>());
            set => _contactGroups = value;
        }

        [Input("dimensions")]
        private InputMap<object>? _dimensions;

        /// <summary>
        /// Field `dimensions` has been deprecated from version 1.95.0. Use `metric_dimensions` instead.
        /// </summary>
        [Obsolete(@"Field 'dimensions' has been deprecated from version 1.173.0. Use 'metric_dimensions' instead.")]
        public InputMap<object> Dimensions
        {
            get => _dimensions ?? (_dimensions = new InputMap<object>());
            set => _dimensions = value;
        }

        /// <summary>
        /// The interval of effecting alarm rule. It format as "hh:mm-hh:mm", like "0:00-4:00". Default to "00:00-23:59".
        /// </summary>
        [Input("effectiveInterval")]
        public Input<string>? EffectiveInterval { get; set; }

        /// <summary>
        /// Whether to enable alarm rule. Default to true.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Input("endTime")]
        public Input<int>? EndTime { get; set; }

        /// <summary>
        /// A configuration of critical alarm (documented below).
        /// </summary>
        [Input("escalationsCritical")]
        public Input<Inputs.AlarmEscalationsCriticalArgs>? EscalationsCritical { get; set; }

        /// <summary>
        /// A configuration of critical info (documented below).
        /// </summary>
        [Input("escalationsInfo")]
        public Input<Inputs.AlarmEscalationsInfoArgs>? EscalationsInfo { get; set; }

        /// <summary>
        /// A configuration of critical warn (documented below).
        /// </summary>
        [Input("escalationsWarn")]
        public Input<Inputs.AlarmEscalationsWarnArgs>? EscalationsWarn { get; set; }

        /// <summary>
        /// Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Input("metric", required: true)]
        public Input<string> Metric { get; set; } = null!;

        /// <summary>
        /// Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string, and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Input("metricDimensions")]
        public Input<string>? MetricDimensions { get; set; }

        /// <summary>
        /// The alarm rule name.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.comparison_operator' instead.
        /// </summary>
        [Input("operator")]
        public Input<string>? Operator { get; set; }

        /// <summary>
        /// Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
        /// </summary>
        [Input("period")]
        public Input<int>? Period { get; set; }

        /// <summary>
        /// Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// **NOTE:** The `dimensions` and `metric_dimensions` must be empty when `project` is `acs_prometheus`, otherwise, one of them must be set.
        /// </summary>
        [Input("project", required: true)]
        public Input<string> Project { get; set; } = null!;

        [Input("prometheuses")]
        private InputList<Inputs.AlarmPrometheusArgs>? _prometheuses;

        /// <summary>
        /// The Prometheus alert rule. See the following `Block prometheus`. **Note:** This parameter is required only when you create a Prometheus alert rule for Hybrid Cloud Monitoring.
        /// </summary>
        public InputList<Inputs.AlarmPrometheusArgs> Prometheuses
        {
            get => _prometheuses ?? (_prometheuses = new InputList<Inputs.AlarmPrometheusArgs>());
            set => _prometheuses = value;
        }

        /// <summary>
        /// Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
        /// </summary>
        [Input("silenceTime")]
        public Input<int>? SilenceTime { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Input("startTime")]
        public Input<int>? StartTime { get; set; }

        /// <summary>
        /// Critical level alarm statistics method. It must be consistent with that defined for metrics. For more information, see [How to use it](https://cms.console.aliyun.com/metric-meta/acs_ecs_dashboard/ecs).
        /// </summary>
        [Input("statistics")]
        public Input<string>? Statistics { get; set; }

        [Input("tags")]
        private InputMap<object>? _tags;

        /// <summary>
        /// A mapping of tags to assign to the resource.
        /// </summary>
        public InputMap<object> Tags
        {
            get => _tags ?? (_tags = new InputMap<object>());
            set => _tags = value;
        }

        /// <summary>
        /// Critical level alarm threshold value, which must be a numeric value currently.
        /// </summary>
        [Input("threshold")]
        public Input<string>? Threshold { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.times' instead.
        /// </summary>
        [Input("triggeredCount")]
        public Input<int>? TriggeredCount { get; set; }

        /// <summary>
        /// The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
        /// </summary>
        [Input("webhook")]
        public Input<string>? Webhook { get; set; }

        public AlarmArgs()
        {
        }
        public static new AlarmArgs Empty => new AlarmArgs();
    }

    public sealed class AlarmState : global::Pulumi.ResourceArgs
    {
        [Input("contactGroups")]
        private InputList<string>? _contactGroups;

        /// <summary>
        /// List contact groups of the alarm rule, which must have been created on the console.
        /// </summary>
        public InputList<string> ContactGroups
        {
            get => _contactGroups ?? (_contactGroups = new InputList<string>());
            set => _contactGroups = value;
        }

        [Input("dimensions")]
        private InputMap<object>? _dimensions;

        /// <summary>
        /// Field `dimensions` has been deprecated from version 1.95.0. Use `metric_dimensions` instead.
        /// </summary>
        [Obsolete(@"Field 'dimensions' has been deprecated from version 1.173.0. Use 'metric_dimensions' instead.")]
        public InputMap<object> Dimensions
        {
            get => _dimensions ?? (_dimensions = new InputMap<object>());
            set => _dimensions = value;
        }

        /// <summary>
        /// The interval of effecting alarm rule. It format as "hh:mm-hh:mm", like "0:00-4:00". Default to "00:00-23:59".
        /// </summary>
        [Input("effectiveInterval")]
        public Input<string>? EffectiveInterval { get; set; }

        /// <summary>
        /// Whether to enable alarm rule. Default to true.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Input("endTime")]
        public Input<int>? EndTime { get; set; }

        /// <summary>
        /// A configuration of critical alarm (documented below).
        /// </summary>
        [Input("escalationsCritical")]
        public Input<Inputs.AlarmEscalationsCriticalGetArgs>? EscalationsCritical { get; set; }

        /// <summary>
        /// A configuration of critical info (documented below).
        /// </summary>
        [Input("escalationsInfo")]
        public Input<Inputs.AlarmEscalationsInfoGetArgs>? EscalationsInfo { get; set; }

        /// <summary>
        /// A configuration of critical warn (documented below).
        /// </summary>
        [Input("escalationsWarn")]
        public Input<Inputs.AlarmEscalationsWarnGetArgs>? EscalationsWarn { get; set; }

        /// <summary>
        /// Name of the monitoring metrics corresponding to a project, such as "CPUUtilization" and "networkin_rate". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Input("metric")]
        public Input<string>? Metric { get; set; }

        /// <summary>
        /// Map of the resources associated with the alarm rule, such as "instanceId", "device" and "port". Each key's value is a string, and it uses comma to split multiple items. For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// </summary>
        [Input("metricDimensions")]
        public Input<string>? MetricDimensions { get; set; }

        /// <summary>
        /// The alarm rule name.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.comparison_operator' instead.
        /// </summary>
        [Input("operator")]
        public Input<string>? Operator { get; set; }

        /// <summary>
        /// Index query cycle, which must be consistent with that defined for metrics. Default to 300, in seconds.
        /// </summary>
        [Input("period")]
        public Input<int>? Period { get; set; }

        /// <summary>
        /// Monitor project name, such as "acs_ecs_dashboard" and "acs_rds_dashboard". For more information, see [Metrics Reference](https://www.alibabacloud.com/help/doc-detail/28619.htm).
        /// **NOTE:** The `dimensions` and `metric_dimensions` must be empty when `project` is `acs_prometheus`, otherwise, one of them must be set.
        /// </summary>
        [Input("project")]
        public Input<string>? Project { get; set; }

        [Input("prometheuses")]
        private InputList<Inputs.AlarmPrometheusGetArgs>? _prometheuses;

        /// <summary>
        /// The Prometheus alert rule. See the following `Block prometheus`. **Note:** This parameter is required only when you create a Prometheus alert rule for Hybrid Cloud Monitoring.
        /// </summary>
        public InputList<Inputs.AlarmPrometheusGetArgs> Prometheuses
        {
            get => _prometheuses ?? (_prometheuses = new InputList<Inputs.AlarmPrometheusGetArgs>());
            set => _prometheuses = value;
        }

        /// <summary>
        /// Notification silence period in the alarm state, in seconds. Valid value range: [300, 86400]. Default to 86400
        /// </summary>
        [Input("silenceTime")]
        public Input<int>? SilenceTime { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.50.0 and 'effective_interval' instead.
        /// </summary>
        [Input("startTime")]
        public Input<int>? StartTime { get; set; }

        /// <summary>
        /// Critical level alarm statistics method. It must be consistent with that defined for metrics. For more information, see [How to use it](https://cms.console.aliyun.com/metric-meta/acs_ecs_dashboard/ecs).
        /// </summary>
        [Input("statistics")]
        public Input<string>? Statistics { get; set; }

        /// <summary>
        /// The current alarm rule status.
        /// </summary>
        [Input("status")]
        public Input<string>? Status { get; set; }

        [Input("tags")]
        private InputMap<object>? _tags;

        /// <summary>
        /// A mapping of tags to assign to the resource.
        /// </summary>
        public InputMap<object> Tags
        {
            get => _tags ?? (_tags = new InputMap<object>());
            set => _tags = value;
        }

        /// <summary>
        /// Critical level alarm threshold value, which must be a numeric value currently.
        /// </summary>
        [Input("threshold")]
        public Input<string>? Threshold { get; set; }

        /// <summary>
        /// It has been deprecated from provider version 1.94.0 and 'escalations_critical.times' instead.
        /// </summary>
        [Input("triggeredCount")]
        public Input<int>? TriggeredCount { get; set; }

        /// <summary>
        /// The webhook that should be called when the alarm is triggered. Currently, only http protocol is supported. Default is empty string.
        /// </summary>
        [Input("webhook")]
        public Input<string>? Webhook { get; set; }

        public AlarmState()
        {
        }
        public static new AlarmState Empty => new AlarmState();
    }
}
