Create a rule
- Base URL
-
https://{kibana_url}
- POST /api/alerting/rule/{id}
- POST /s/{space_id}/api/alerting/rule/{id}
Path parameters
-
space_idstringoptional -
An identifier for the space. If
space_idis not provided in the URL, the default space is used. Refer to Spaces for more information.
Request body
-
actionsobject[] · default: [] -
alerts_filterobject -
Conditions that affect whether the action runs. If you specify multiple conditions, all conditions must be met for the action to run. For example, if an alert occurs within the specified time frame and matches the query, the action runs.
-
timeframeobject -
Defines a period that limits whether the action runs.
-
frequencyobject -
notify_whenenumrequired -
Indicates how often alerts generate actions. Valid values include:
onActionGroupChange: Actions run when the alert status changes;onActiveAlert: Actions run when the alert becomes active and at each check interval while the rule conditions are met;onThrottleInterval: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specifynotify_whenat both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
Values:
onActionGroupChangeonActiveAlertonThrottleInterval -
throttlestringrequired nullable -
The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if
notify_whenis set toonThrottleInterval. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
groupstring -
The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to
default. -
alert_delayobject -
Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.
-
consumerstringrequired -
The name of the application or feature that owns the rule. For example:
alerts,apm,discover,infrastructure,logs,metrics,ml,monitoring,securitySolution,siem,stackAlerts, oruptime. -
enabledboolean · default: true -
Indicates whether you want to run the rule on an interval basis after it is created.
-
flappingobjectnullable -
When flapping detection is turned on, alerts that switch quickly between active and recovered states are identified as “flapping” and notifications are reduced.
-
namestringrequired -
The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule.
-
notify_whenenumnullable -
Indicates how often alerts generate actions. Valid values include:
onActionGroupChange: Actions run when the alert status changes;onActiveAlert: Actions run when the alert becomes active and at each check interval while the rule conditions are met;onThrottleInterval: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specifynotify_whenat both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
Values:
onActionGroupChangeonActiveAlertonThrottleInterval -
scheduleobjectrequired -
The check interval, which specifies how frequently the rule conditions are checked.
-
throttlestringnullable -
Use the
throttleproperty in the actionfrequencyobject instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
paramsunion anyOf · default: {} -
The parameters for the rule.
- Any of:
-
aggFieldstring -
The name of the numeric field that is used in the aggregation. This property is required when
aggTypeisavg,max,minorsum. -
excludeHitsFromPreviousRunboolean -
Indicates whether to exclude matches from previous runs. If
true, you can avoid alert duplication by excluding documents that have already been detected by the previous rule run. This option is not available when a grouping field is specified. -
groupByenum · default: all -
Indicates whether the aggregation is applied over all documents (
all) or split into groups (top) using a grouping field (termField). If grouping is used, an alert will be created for each group when it exceeds the threshold; only the top groups (up totermSizenumber of groups) are checked. -
Values:
alltop -
searchTypeenum · default: esQuery -
The type of query, in this case a query that uses Elasticsearch Query DSL.
-
Values:
esQuery -
sizeinteger -
The number of documents to pass to the configured actions when the threshold condition is met.
-
termFieldunion oneOf -
The names of up to four fields that are used for grouping the aggregation. This property is required when
groupByistop. -
One of:
string[]orstring -
termSizeinteger -
This property is required when
groupByistop. It specifies the number of groups to check against the threshold and therefore limits the number of alerts on high cardinality fields. -
thresholdinteger[]required -
The threshold value that is used with the
thresholdComparator. If thethresholdComparatorisbetweenornotBetween, you must specify the boundary values. -
thresholdComparatorenumrequired -
The comparison function for the threshold. For example, "is above", "is above or equals", "is below", "is below or equals", "is between", and "is not between".
-
Values:
>>=<<=betweennotBetween -
aggFieldstring -
The name of the numeric field that is used in the aggregation. This property is required when
aggTypeisavg,max,minorsum. -
excludeHitsFromPreviousRunboolean -
Indicates whether to exclude matches from previous runs. If
true, you can avoid alert duplication by excluding documents that have already been detected by the previous rule run. This option is not available when a grouping field is specified. -
groupByenum · default: all -
Indicates whether the aggregation is applied over all documents (
all) or split into groups (top) using a grouping field (termField). If grouping is used, an alert will be created for each group when it exceeds the threshold; only the top groups (up totermSizenumber of groups) are checked. -
Values:
alltop -
searchTypeenumrequired -
The type of query, in this case a query that uses Elasticsearch Query Language (ES|QL).
-
Values:
esqlQuery -
sizeintegerrequired -
When
searchTypeisesqlQuery, this property is required but it does not affect the rule behavior. -
termSizeinteger -
This property is required when
groupByistop. It specifies the number of groups to check against the threshold and therefore limits the number of alerts on high cardinality fields. -
thresholdinteger[]required -
The threshold value that is used with the
thresholdComparator. WhensearchTypeisesqlQuery, this property is required and must be set to zero. -
thresholdComparatorenumrequired -
The comparison function for the threshold. When
searchTypeisesqlQuery, this property is required and must be set to ">". Since thethresholdvalue must be0, the result is that an alert occurs whenever the query returns results. -
Values:
> -
aggFieldstring -
The name of the numeric field that is used in the aggregation. This property is required when
aggTypeisavg,max,minorsum. -
excludeHitsFromPreviousRunboolean -
Indicates whether to exclude matches from previous runs. If
true, you can avoid alert duplication by excluding documents that have already been detected by the previous rule run. This option is not available when a grouping field is specified. -
groupByenum · default: all -
Indicates whether the aggregation is applied over all documents (
all) or split into groups (top) using a grouping field (termField). If grouping is used, an alert will be created for each group when it exceeds the threshold; only the top groups (up totermSizenumber of groups) are checked. -
Values:
alltop -
searchConfigurationobject -
The query definition, which uses KQL or Lucene to fetch the documents from Elasticsearch.
-
searchTypeenumrequired -
The type of query, in this case a text-based query that uses KQL or Lucene.
-
Values:
searchSource -
sizeintegerrequired -
The number of documents to pass to the configured actions when the threshold condition is met.
-
termFieldunion oneOf -
The names of up to four fields that are used for grouping the aggregation. This property is required when
groupByistop. -
One of:
string[]orstring -
termSizeinteger -
This property is required when
groupByistop. It specifies the number of groups to check against the threshold and therefore limits the number of alerts on high cardinality fields. -
thresholdinteger[]required -
The threshold value that is used with the
thresholdComparator. If thethresholdComparatorisbetweenornotBetween, you must specify the boundary values. -
thresholdComparatorenumrequired -
The comparison function for the threshold. For example, "is above", "is above or equals", "is below", "is below or equals", "is between", and "is not between".
-
Values:
>>=<<=betweennotBetween -
aggFieldstring -
The name of the numeric field that is used in the aggregation. This property is required when
aggTypeisavg,max,minorsum. -
groupByenum · default: all -
Indicates whether the aggregation is applied over all documents (
all) or split into groups (top) using a grouping field (termField). If grouping is used, an alert will be created for each group when it exceeds the threshold; only the top groups (up totermSizenumber of groups) are checked. -
Values:
alltop -
termFieldunion oneOf -
The names of up to four fields that are used for grouping the aggregation. This property is required when
groupByistop. -
One of:
string[]orstring -
termSizeinteger -
This property is required when
groupByistop. It specifies the number of groups to check against the threshold and therefore limits the number of alerts on high cardinality fields. -
thresholdinteger[]required -
The threshold value that is used with the
thresholdComparator. If thethresholdComparatorisbetweenornotBetween, you must specify the boundary values. -
thresholdComparatorenumrequired -
The comparison function for the threshold. For example, "is above", "is above or equals", "is below", "is below or equals", "is between", and "is not between".
-
Values:
>>=<<=betweennotBetween -
criteriaobject[] -
metricenum -
Values:
countcpudiskLatencyloadmemorymemoryTotaltxrxlogRatediskIOReadBytesdiskIOWriteBytess3TotalRequestss3NumberOfObjectss3BucketSizes3DownloadBytess3UploadBytesrdsConnectionsrdsQueriesExecutedrdsActiveTransactionsrdsLatencysqsMessagesVisiblesqsMessagesDelayedsqsMessagesSentsqsMessagesEmptysqsOldestMessagecustom -
criteriaunion oneOf[] - One of:
-
thresholdnumber[] -
The threshold value that is used with the
comparator. If thecomparatorisbetween, you must specify the boundary values. -
comparatorenum -
The comparison function for the threshold. For example, "is above", "is above or equals", "is below", "is below or equals", "is between", and "outside".
-
Values:
<<=>>=betweenoutside -
timeUnitenum -
The type of units for the time window: seconds, minutes, hours, or days.
-
Values:
smhd -
timeSizenumber -
The size of the time window (in
timeUnitunits), which determines how far back to search for documents. Generally it should be a value higher than the rule check interval to avoid gaps in detection. -
timeUnitenum -
The type of units for the time window: seconds, minutes, hours, or days.
-
Values:
smhd -
timeSizenumber -
The size of the time window (in
timeUnitunits), which determines how far back to search for documents. Generally it should be a value higher than the rule check interval to avoid gaps in detection. -
groupByunion string | string[] -
Create an alert for every unique value of the specified fields. For example, you can create a rule per host or every mount point of each host. IMPORTANT: If you include the same field in both the
filterQueryandgroupBy, you might receive fewer results than you expect. For example, if you filter bycloud.region: us-east, grouping bycloud.regionwill have no effect because the filter query can match only one region. -
filterQuerystring -
A query that limits the scope of the rule. The rule evaluates only metric data that matches the query.
The parameters for the APM anomaly rule. These parameters are appropriate when rule_type_id is apm.rules.anomaly.
The parameters for the APM error count rule. These parameters are appropriate when rule_type_id is apm.error_rate.
The parameters for the APM transaction duration rule. These parameters are appropriate when rule_type_id is apm.transaction_duration.
The parameters for the APM transaction error rate rule. These parameters are appropriate when rule_type_id is apm.transaction_error_rate.
An Elasticsearch query rule can run a query defined in Elasticsearch Query DSL and compare the number of matches to a configured threshold. These parameters are appropriate when rule_type_id is .es-query.
An Elasticsearch query rule can run an ES|QL query and compare the number of matches to a configured threshold. These parameters are appropriate when rule_type_id is .es-query.
An Elasticsearch query rule can run a query defined in KQL or Lucene and compare the number of matches to a configured threshold. These parameters are appropriate when rule_type_id is .es-query.
An index threshold rule runs an Elasticsearch query, aggregates field values from documents, compares them to threshold values, and schedules actions to run when the thresholds are met. These parameters are appropriate when rule_type_id is .index-threshold.
The parameters for the infrastructure inventory rule. These parameters are appropriate when rule_type_id is metrics.alert.inventory.threshold.
The parameters for the metric threshold rule. These parameters are appropriate when rule_type_id is metrics.alert.threshold.
The parameters for the SLO burn rate rule. These parameters are appropriate when rule_type_id is slo.rules.burnRate.
The parameters for the synthetics TLS certificate rule. These parameters are appropriate when rule_type_id is xpack.uptime.alerts.tls.
The parameters for the Synthetics monitor status rule. These parameters are appropriate when rule_type_id is xpack.uptime.alerts.monitorStatus.
Responses
Indicates a successful call.
-
actionsobject[]required -
alerts_filterobject -
Defines a period that limits whether the action runs.
-
connector_type_idstringrequired -
The type of connector. This property appears in responses but cannot be set in requests.
-
frequencyobject -
notify_whenenumrequired -
Indicates how often alerts generate actions. Valid values include:
onActionGroupChange: Actions run when the alert status changes;onActiveAlert: Actions run when the alert becomes active and at each check interval while the rule conditions are met;onThrottleInterval: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specifynotify_whenat both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
Values:
onActionGroupChangeonActiveAlertonThrottleInterval -
throttlestringrequired nullable -
The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.
-
groupstring -
The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to
default. -
alert_delayobject -
Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.
-
api_key_created_by_userbooleannullable -
Indicates whether the API key that is associated with the rule was created by the user.
-
api_key_ownerstringrequired nullable -
The owner of the API key that is associated with the rule and used to run background tasks.
-
consumerstringrequired -
The name of the application or feature that owns the rule. For example:
alerts,apm,discover,infrastructure,logs,metrics,ml,monitoring,securitySolution,siem,stackAlerts, oruptime. -
enabledbooleanrequired -
Indicates whether you want to run the rule on an interval basis after it is created.
-
flappingobjectnullable -
When flapping detection is turned on, alerts that switch quickly between active and recovered states are identified as “flapping” and notifications are reduced.
-
monitoringobject -
Monitoring details of the rule.
-
notify_whenenumnullable -
Indicates how often alerts generate actions. Valid values include:
onActionGroupChange: Actions run when the alert status changes;onActiveAlert: Actions run when the alert becomes active and at each check interval while the rule conditions are met;onThrottleInterval: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specifynotify_whenat both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values. -
Values:
onActionGroupChangeonActiveAlertonThrottleInterval -
throttlestringnullable deprecated -
Deprecated in 8.13.0. Use the
throttleproperty in the actionfrequencyobject instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.
Indicates an invalid schema or parameters.
Indicates that this call is forbidden.
Indicates that the rule id is already in use.