Skip to main content
Alerting & Response/Alert Rules

ValidateAlertRule

Validate an alert rule definition for correctness before saving

POST/api/v1/alerting/rules/validate

Operation ID

ValidateAlertRule

Since

1.0.0

Execution Mode

Synchronous

Auth Context

Auth Required

Auth Context

Send these values as request headers when calling this API.

AuthorizationstringRequired

Bearer Token

X-Tenant-IDstring

X-Tenant-ID

Request Inputs

application/json

Body Fields

  • rule
    ObjectRequired

    Alert rule input to validate

    • name
      String

      Rule name to validate

      Example: High CPU Usage

    • promql
      String

      PromQL expression for the rule

      Example: avg(cpu_usage_percent) > 90

    • threshold
      Long

      Threshold value for the rule

      Example: 90

    • for
      String

      Duration string for the for clause

      Example: 5m

Responses

200 OK
200 OK

On success, this API returns the following response structure.

  • valid
    Boolean

    Whether the rule definition is valid

    Example: true

  • promqlErrors
    List

    List of PromQL syntax errors if any

    Example: item1,item2

  • wouldFireNow
    Boolean

    Whether the rule would currently fire

    Example: false

  • currentValue
    Long

    Current metric value if evaluated

    Example: 45.2

  • threshold
    Long

    Threshold used in validation check

    Example: 90

  • nameConflict
    Boolean

    Whether the rule name conflicts with an existing rule

    Example: false

  • validationErrors
    List

    General validation errors beyond PromQL

    Example: item1,item2