Update the API key of rules matching a query (dry-run by default)
Experimental; added in 9.5.0
Spaces method and path for this operation:
Refer to Spaces for more information.
Rotates each matching rule executor task API key to one derived from the current user’s credentials.
[Required authorization] Route required privileges: manage_alerting-v2-rules.
Body
-
KQL filter string to match target resources. At most 10000 matching resources are processed per request. Cannot be empty; to target every resource use
match_all: true.Minimum length is
1, maximum length is4096. -
When true, executes the operation. When false (default), returns a dry-run preview with
match_countand asampleof matching resource IDs so the client can verify before committing.Default value is
false. -
When true, targets every resource. Requires an explicit opt-in. Omitted by default.
Value is
true. -
Free-text search string matched against the resource-defined searchable fields. Cannot be empty; to target every resource use
match_all: true.Minimum length is
1, maximum length is256.
Responses
-
Returns a dry-run preview by default, or the executed operation when
forceis true. -
Indicates an invalid schema or parameters.
-
Indicates the request was not authenticated.
-
Indicates the user does not have the required privileges to perform the request.
-
Indicates an unexpected server-side error.
-
Indicates the alerting engine is disabled by the
alerting:v2:enabledadvanced setting.
curl \
--request POST 'https://localhost:5601/api/alerting/v2/rules/_update_api_key_by_query' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--header "kbn-xsrf: true" \
--data '"{\n \"filter\": \"tags: production\"\n}"'
{
"filter": "tags: production"
}
{
"match_count": 2,
"sample": [
"rule-1",
"rule-2"
]
}
{
"code": "BAD_REQUEST",
"details": {
"errors": {
"": [
"At least one of filter, search, or match_all must be provided."
]
}
},
"error": "Bad Request",
"message": "At least one of filter, search, or match_all must be provided."
}
{
"code": "UNAUTHORIZED",
"error": "Unauthorized",
"message": "Authentication required to access this API."
}
{
"code": "FORBIDDEN",
"error": "Forbidden",
"message": "The current user does not have the required privileges for this request."
}
{
"code": "INTERNAL_SERVER_ERROR",
"error": "Internal Server Error",
"message": "An unexpected error occurred."
}
{
"code": "ALERTING_DISABLED",
"error": "Service Unavailable",
"message": "Alerting is disabled."
}