Skip to main content
Alerting & Response/Alert Rules
POSTAlertingSince 1.0SynchronousAuth Required

ValidateAlertRule

Validate an alert rule definition for correctness before saving

Execution Availability

Try It Out

Submit a mock request using the current auth context and example-driven inputs.

Request Inputs

Body Fields

  • ruleObjectRequired

    Alert rule input to validate

    • nameString

      Rule name to validate

      Example: High CPU Usage

    • promqlString

      PromQL expression for the rule

      Example: avg(cpu_usage_percent) > 90

    • thresholdLong

      Threshold value for the rule

      Example: 90

    • forString

      Duration string for the for clause

      Example: 5m

Responses

200 OK

On success, this API returns the following response structure.

  • validBoolean

    Whether the rule definition is valid

    Example: true

  • promqlErrorsList

    List of PromQL syntax errors if any

    Example: item1,item2

  • wouldFireNowBoolean

    Whether the rule would currently fire

    Example: false

  • currentValueLong

    Current metric value if evaluated

    Example: 45.2

  • thresholdLong

    Threshold used in validation check

    Example: 90

  • nameConflictBoolean

    Whether the rule name conflicts with an existing rule

    Example: false

  • validationErrorsList

    General validation errors beyond PromQL

    Example: item1,item2

Endpoint

POST/api/v1/alerting/rules/validate

/api/v1/alerting/rules/validate

Operation ID

ValidateAlertRule

Permalink

Request Example

curl -X POST '{host}/api/v1/alerting/rules/validate' -H 'Authorization: Bearer {token}' -H 'Content-Type: application/json' -d '{"rule":{"name":"High CPU Usage","promql":"avg(cpu_usage_percent) > 90","threshold":90.0,"for":"5m"}}'

Response Example

200
{
  "valid": true,
  "promqlErrors": [],
  "wouldFireNow": false,
  "currentValue": 45.2,
  "threshold": 90.0,
  "nameConflict": false,
  "validationErrors": []
}

Change History

This API has no change history records yet.

View all change history