---
title: "POST /{resourceId}/providers/Microsoft.AlertsManagement/previewAlertRule"
method: POST
path: "/{resourceId}/providers/Microsoft.AlertsManagement/previewAlertRule"
---

# POST /{resourceId}/providers/Microsoft.AlertsManagement/previewAlertRule

`POST /{resourceId}/providers/Microsoft.AlertsManagement/previewAlertRule`

Retrieves the results of a simulated historical execution of an alert rule

## Path parameters

- `resourceId` string, required

## Parameters

- `../../../../../../common-types/resource-management/v3/types.json#/components/parameters/ApiVersionParameter` — unresolved $ref

## Request body

- PreviewAlertRuleRequest
  - `location` string, required — The location of the rule resource.
  - `properties` PreviewAlertRuleRequestProperties, required
    - `timespan` string, duration, required — Specifies the timespan of the preview in ISO 8601 duration format.
    - `scheduledQueryRuleProperties` LogAlertRuleResource — The scheduled query rule resource.
      - `tags` object — Resource tags.
      - `location` string, required — The geo-location where the resource lives
      - `kind` 'LogAlert' | 'EventLogAlert' | 'LogToMetric' — Indicates the type of scheduled query rule. The default is LogAlert.
      - `properties` LogAlertRuleProperties, required — scheduled query rule Definition
        - `description` string — The description of the scheduled query rule.
        - `displayName` string — The display name of the alert rule
        - `severity` 0 | 1 | 2 | 3 | 4 — Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for rules of the kind LogAlert.
        - `enabled` boolean — The flag which indicates whether this scheduled query rule is enabled. Value should be true or false
        - `scopes` string[] — The list of resource id's that this scheduled query rule is scoped to.
        - `evaluationFrequency` string, duration — How often the scheduled query rule is evaluated represented in ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert.
        - `windowSize` string, duration — The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). Relevant and required only for rules of the kind LogAlert.
        - `overrideQueryTimeRange` string, duration — If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert.
        - `targetResourceTypes` string[] — List of resource type of the target resource(s) on which the alert is created/updated. For example if the scope is a resource group and targetResourceTypes is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. Relevant only for rules of the kind LogAlert
        - `criteria` LogAlertRuleCriteria — The rule criteria that defines the conditions of the scheduled query rule.
          - `allOf` LogAlertRuleCondition[] — A list of conditions to evaluate against the specified scopes
            - `criterionType` 'StaticThresholdCriterion' | 'DynamicThresholdCriterion' — Specifies the type of threshold criteria
            - `query` string — KQL log query alert
            - `timeAggregation` 'Count' | 'Average' | 'Minimum' | 'Maximum' | 'Total' — Aggregation type. Relevant and required only for rules of the kind LogAlert.
            - `metricMeasureColumn` string — The column containing the metric measure number. Relevant only for rules of the kind LogAlert.
            - `resourceIdColumn` string — The column containing the resource id. The content of the column must be a uri formatted as resource id. Relevant only for rules of the kind LogAlert.
            - `dimensions` LogAlertRuleDimension[] — List of Dimensions conditions
              - …
            - `operator` 'Equals' | 'GreaterThan' | 'GreaterThanOrEqual' | 'LessThan' | 'LessThanOrEqual' | 'GreaterOrLessThan' — The criteria operator. Relevant and required only for rules of the kind LogAlert.
            - `threshold` number, double — the criteria threshold value that activates the alert. Relevant and required only for static threshold rules of the kind LogAlert.
            - `alertSensitivity` string — The extent of deviation required to trigger an alert. Allowed values are 'Low', 'Medium' and 'High'. This will affect how tight the threshold is to the metric series pattern. Relevant and required only for dynamic threshold rules of the kind LogAlert.
            - `ignoreDataBefore` string, date-time — Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). Relevant only for dynamic threshold rules of the kind LogAlert.
            - `failingPeriods` LogAlertRuleConditionFailingPeriods — The minimum number of violations required within the selected lookback time window required to raise an alert. Relevant only for rules of the kind LogAlert.
              - …
            - `metricName` string — The name of the metric to be sent. Relevant and required only for rules of the kind LogToMetric.

## Response `200`

The request has succeeded.

- PreviewAlertRuleResponse
  - `rulePreviewResults` RulePreviewResult[] — An array of rule preview results.
    - `dimensionCombination` DimensionNameAndValue[] — The list of dimensions for the evaluation.
      - `name` string, required — Name of the dimension
      - `value` string, required — Value of the dimension
    - `evaluations` Evaluation[] — An array of evaluations.
      - `evaluationTime` string, date-time — The time when the evaluation was performed.
      - `alertState` 'NoAlert' | 'Fired' | 'Firing' | 'Resolving' | 'Resolved' — The state of the alert after the evaluation.
      - `evaluatedPeriods` EvaluatedPeriod[] — An array of evaluated periods.
        - `timestamp` string, date-time — The timestamp of the evaluated period.
        - `highThreshold` number, double — The high threshold value for the evaluation period.
        - `lowThreshold` number, double — The low threshold value for the evaluation period.
        - `metricValue` number, double — The metric value for the evaluation period.
        - `thresholdMet` boolean — Indicates whether the threshold was met during the evaluation period.
      - `thresholdMet` boolean — Indicates whether the threshold was met for this evaluation.

## Other responses

- `default` — An unexpected error response.

---

[API](https://skmtc.net/azure/apis/alertsmanagement-microsoft-alertsmanagement-previewalertrule.md) · [All operations](https://skmtc.net/azure/apis/alertsmanagement-microsoft-alertsmanagement-previewalertrule/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/azure/alertsmanagement-microsoft-alertsmanagement-previewalertrule/revisions/26eb2647703c/schema)
