import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages an AlertingAction Scheduled Query Rules resource within Azure Monitor. * * > **Note:** This resource is using an older AzureRM API version which is known to cause problems e.g. with custom webhook properties not included in triggered alerts. This resource is superseded by the azure.monitoring.ScheduledQueryRulesAlertV2 resource using newer API versions. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const example = new azure.core.ResourceGroup("example", { * name: "monitoring-resources", * location: "West Europe", * }); * const exampleInsights = new azure.appinsights.Insights("example", { * name: "appinsights", * location: example.location, * resourceGroupName: example.name, * applicationType: "web", * }); * const example2 = new azure.appinsights.Insights("example2", { * name: "appinsights2", * location: example.location, * resourceGroupName: example.name, * applicationType: "web", * }); * // Example: Alerting Action with result count trigger * const exampleScheduledQueryRulesAlert = new azure.monitoring.ScheduledQueryRulesAlert("example", { * name: "example", * location: example.location, * resourceGroupName: example.name, * action: { * actionGroups: [], * emailSubject: "Email Header", * customWebhookPayload: "{}", * }, * dataSourceId: exampleInsights.id, * description: "Alert when total results cross threshold", * enabled: true, * query: `requests * | where tolong(resultCode) >= 500 * | summarize count() by bin(timestamp, 5m) * `, * severity: 1, * frequency: 5, * timeWindow: 30, * trigger: { * operator: "GreaterThan", * threshold: 3, * }, * tags: { * foo: "bar", * }, * }); * // Example: Alerting Action Cross-Resource * const example2ScheduledQueryRulesAlert = new azure.monitoring.ScheduledQueryRulesAlert("example2", { * name: "example", * location: example.location, * resourceGroupName: example.name, * authorizedResourceIds: [example2.id], * action: { * actionGroups: [], * emailSubject: "Email Header", * customWebhookPayload: "{}", * }, * dataSourceId: exampleInsights.id, * description: "Query may access data within multiple resources", * enabled: true, * query: std.format({ * input: `let a=requests * | where toint(resultCode) >= 500 * | extend fail=1; let b=app('%s').requests * | where toint(resultCode) >= 500 | extend fail=1; a * | join b on fail * `, * args: [example2.id], * }).then(invoke => invoke.result), * severity: 1, * frequency: 5, * timeWindow: 30, * trigger: { * operator: "GreaterThan", * threshold: 3, * }, * tags: { * foo: "bar", * }, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Insights` - 2018-04-16 * * ## Import * * Scheduled Query Rule Alerts can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:monitoring/scheduledQueryRulesAlert:ScheduledQueryRulesAlert example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Insights/scheduledQueryRules/myrulename * ``` */ export declare class ScheduledQueryRulesAlert extends pulumi.CustomResource { /** * Get an existing ScheduledQueryRulesAlert resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: ScheduledQueryRulesAlertState, opts?: pulumi.CustomResourceOptions): ScheduledQueryRulesAlert; /** * Returns true if the given object is an instance of ScheduledQueryRulesAlert. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is ScheduledQueryRulesAlert; /** * An `action` block as defined below. */ readonly action: pulumi.Output; /** * List of Resource IDs referred into query. */ readonly authorizedResourceIds: pulumi.Output; /** * Should the alerts in this Metric Alert be auto resolved? Defaults to `false`. * > **Note:** `autoMitigationEnabled` and `throttling` are mutually exclusive and cannot both be set. */ readonly autoMitigationEnabled: pulumi.Output; /** * The resource URI over which log search query is to be run. Changing this forces a new resource to be created. */ readonly dataSourceId: pulumi.Output; /** * The description of the scheduled query rule. */ readonly description: pulumi.Output; /** * Whether this scheduled query rule is enabled. Default is `true`. */ readonly enabled: pulumi.Output; /** * Frequency (in minutes) at which rule condition should be evaluated. Values must be between 5 and 1440 (inclusive). */ readonly frequency: pulumi.Output; /** * Specifies the Azure Region where the resource should exist. Changing this forces a new resource to be created. */ readonly location: pulumi.Output; /** * The name of the scheduled query rule. Changing this forces a new resource to be created. */ readonly name: pulumi.Output; /** * Log search query. */ readonly query: pulumi.Output; /** * The type of query results. Possible values are `ResultCount` and `Number`. Default is `ResultCount`. If set to `ResultCount`, `query` must include an `AggregatedValue` column of a numeric type, for example, `Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)`. */ readonly queryType: pulumi.Output; /** * The name of the resource group in which to create the scheduled query rule instance. Changing this forces a new resource to be created. */ readonly resourceGroupName: pulumi.Output; /** * Severity of the alert. Possible values include: 0, 1, 2, 3, or 4. */ readonly severity: pulumi.Output; /** * A mapping of tags to assign to the resource. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Time (in minutes) for which Alerts should be throttled or suppressed. Values must be between 0 and 10000 (inclusive). */ readonly throttling: pulumi.Output; /** * Time window for which data needs to be fetched for query (must be greater than or equal to `frequency`). Values must be between 5 and 2880 (inclusive). */ readonly timeWindow: pulumi.Output; /** * A `trigger` block as defined below. */ readonly trigger: pulumi.Output; /** * Create a ScheduledQueryRulesAlert resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ScheduledQueryRulesAlertArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ScheduledQueryRulesAlert resources. */ export interface ScheduledQueryRulesAlertState { /** * An `action` block as defined below. */ action?: pulumi.Input; /** * List of Resource IDs referred into query. */ authorizedResourceIds?: pulumi.Input[]>; /** * Should the alerts in this Metric Alert be auto resolved? Defaults to `false`. * > **Note:** `autoMitigationEnabled` and `throttling` are mutually exclusive and cannot both be set. */ autoMitigationEnabled?: pulumi.Input; /** * The resource URI over which log search query is to be run. Changing this forces a new resource to be created. */ dataSourceId?: pulumi.Input; /** * The description of the scheduled query rule. */ description?: pulumi.Input; /** * Whether this scheduled query rule is enabled. Default is `true`. */ enabled?: pulumi.Input; /** * Frequency (in minutes) at which rule condition should be evaluated. Values must be between 5 and 1440 (inclusive). */ frequency?: pulumi.Input; /** * Specifies the Azure Region where the resource should exist. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * The name of the scheduled query rule. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * Log search query. */ query?: pulumi.Input; /** * The type of query results. Possible values are `ResultCount` and `Number`. Default is `ResultCount`. If set to `ResultCount`, `query` must include an `AggregatedValue` column of a numeric type, for example, `Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)`. */ queryType?: pulumi.Input; /** * The name of the resource group in which to create the scheduled query rule instance. Changing this forces a new resource to be created. */ resourceGroupName?: pulumi.Input; /** * Severity of the alert. Possible values include: 0, 1, 2, 3, or 4. */ severity?: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Time (in minutes) for which Alerts should be throttled or suppressed. Values must be between 0 and 10000 (inclusive). */ throttling?: pulumi.Input; /** * Time window for which data needs to be fetched for query (must be greater than or equal to `frequency`). Values must be between 5 and 2880 (inclusive). */ timeWindow?: pulumi.Input; /** * A `trigger` block as defined below. */ trigger?: pulumi.Input; } /** * The set of arguments for constructing a ScheduledQueryRulesAlert resource. */ export interface ScheduledQueryRulesAlertArgs { /** * An `action` block as defined below. */ action: pulumi.Input; /** * List of Resource IDs referred into query. */ authorizedResourceIds?: pulumi.Input[]>; /** * Should the alerts in this Metric Alert be auto resolved? Defaults to `false`. * > **Note:** `autoMitigationEnabled` and `throttling` are mutually exclusive and cannot both be set. */ autoMitigationEnabled?: pulumi.Input; /** * The resource URI over which log search query is to be run. Changing this forces a new resource to be created. */ dataSourceId: pulumi.Input; /** * The description of the scheduled query rule. */ description?: pulumi.Input; /** * Whether this scheduled query rule is enabled. Default is `true`. */ enabled?: pulumi.Input; /** * Frequency (in minutes) at which rule condition should be evaluated. Values must be between 5 and 1440 (inclusive). */ frequency: pulumi.Input; /** * Specifies the Azure Region where the resource should exist. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * The name of the scheduled query rule. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * Log search query. */ query: pulumi.Input; /** * The type of query results. Possible values are `ResultCount` and `Number`. Default is `ResultCount`. If set to `ResultCount`, `query` must include an `AggregatedValue` column of a numeric type, for example, `Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)`. */ queryType?: pulumi.Input; /** * The name of the resource group in which to create the scheduled query rule instance. Changing this forces a new resource to be created. */ resourceGroupName: pulumi.Input; /** * Severity of the alert. Possible values include: 0, 1, 2, 3, or 4. */ severity?: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Time (in minutes) for which Alerts should be throttled or suppressed. Values must be between 0 and 10000 (inclusive). */ throttling?: pulumi.Input; /** * Time window for which data needs to be fetched for query (must be greater than or equal to `frequency`). Values must be between 5 and 2880 (inclusive). */ timeWindow: pulumi.Input; /** * A `trigger` block as defined below. */ trigger: pulumi.Input; }