Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OAS] Add more Elasticsearch query rule examples #164386

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 162 additions & 17 deletions x-pack/plugins/alerting/docs/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@
"url": "https://www.elastic.co/licensing/elastic-license"
}
},
"tags": [
{
"name": "alerting",
"description": "Alerting APIs enable you to create and manage rules and alerts."
}
],
"servers": [
{
"url": "http://localhost:5601",
"description": "local"
}
],
"security": [
{
"basicAuth": []
},
{
"apiKeyAuth": []
}
],
"tags": [
{
"name": "alerting",
"description": "Alerting APIs enable you to create and manage rules and alerts."
}
],
"paths": {
"/s/{spaceId}/api/alerting/rule": {
"post": {
Expand Down Expand Up @@ -52,6 +60,9 @@
"createEsQueryRuleRequest": {
"$ref": "#/components/examples/create_es_query_rule_request"
},
"createEsQueryKqlRuleRequest": {
"$ref": "#/components/examples/create_es_query_kql_rule_request"
},
"createIndexThresholdRuleRequest": {
"$ref": "#/components/examples/create_index_threshold_rule_request"
}
Expand All @@ -71,6 +82,9 @@
"createEsQueryRuleResponse": {
"$ref": "#/components/examples/create_es_query_rule_response"
},
"createEsQueryKqlRuleResponse": {
"$ref": "#/components/examples/create_es_query_kql_rule_response"
},
"createIndexThresholdRuleResponse": {
"$ref": "#/components/examples/create_index_threshold_rule_response"
}
Expand Down Expand Up @@ -255,6 +269,9 @@
"createEsQueryRuleIdRequest": {
"$ref": "#/components/examples/create_es_query_rule_request"
},
"createEsQueryKqlRuleIdRequest": {
"$ref": "#/components/examples/create_es_query_kql_rule_request"
},
"createIndexThreholdRuleIdRequest": {
"$ref": "#/components/examples/create_index_threshold_rule_request"
}
Expand All @@ -274,6 +291,9 @@
"createEsQueryRuleIdResponse": {
"$ref": "#/components/examples/create_es_query_rule_response"
},
"createEsQueryKqlRuleIdResponse": {
"$ref": "#/components/examples/create_es_query_kql_rule_response"
},
"createIndexThresholdRuleIdResponse": {
"$ref": "#/components/examples/create_index_threshold_rule_response"
}
Expand Down Expand Up @@ -6710,10 +6730,62 @@
},
"examples": {
"create_es_query_rule_request": {
"summary": "Create an Elasticsearch query rule.",
"summary": "Create an Elasticsearch query rule that uses Elasticsearch query domain specific language (DSL) to define its query and a server log connector to send notifications.",
"value": {
"actions": [
{
"group": "query matched",
"params": {
"level": "info",
"message": "The system has detected {{alerts.new.count}} new, {{alerts.ongoing.count}} ongoing, and {{alerts.recovered.count}} recovered alerts."
},
"id": "fdbece50-406c-11ee-850e-c71febc4ca7f",
"frequency": {
"throttle": "1d",
"summary": true,
"notify_when": "onThrottleInterval"
}
},
{
"group": "recovered",
"params": {
"level": "info",
"message": "Recovered"
},
"id": "fdbece50-406c-11ee-850e-c71febc4ca7f",
"frequency": {
"summary": false,
"notify_when": "onActionGroupChange"
}
}
],
"consumer": "alerts",
"name": "my Elasticsearch query rule",
"params": {
"esQuery": "\"\"\"{\"query\":{\"match_all\" : {}}}\"\"\"",
"index": [
"kibana_sample_data_logs"
],
"size": 100,
"threshold": [
100
],
"thresholdComparator": ">",
"timeField": "@timestamp",
"timeWindowSize": 1,
"timeWindowUnit": "d"
},
"rule_type_id": ".es-query",
"schedule": {
"interval": "1d"
}
}
},
"create_es_query_kql_rule_request": {
"summary": "Create an Elasticsearch query rule that uses Kibana query language (KQL).",
"value": {
"consumer": "alerts",
"name": "my Elasticsearch query KQL rule",
"params": {
"aggType": "count",
"excludeHitsFromPreviousRun": true,
Expand Down Expand Up @@ -6786,11 +6858,92 @@
}
},
"create_es_query_rule_response": {
"summary": "The create rule API returns a JSON object that contains details about the rule.",
"value": {
"id": "58148c70-407f-11ee-850e-c71febc4ca7f",
"enabled": true,
"name": "my Elasticsearch query rule",
"tags": [],
"rule_type_id": ".es-query",
"consumer": "alerts",
"schedule": {
"interval": "1d"
},
"actions": [
{
"group": "query matched",
"id": "fdbece50-406c-11ee-850e-c71febc4ca7f",
"params": {
"level": "info",
"message": "The system has detected {{alerts.new.count}} new, {{alerts.ongoing.count}} ongoing, and {{alerts.recovered.count}} recovered alerts."
},
"connector_type_id": ".server-log",
"frequency": {
"summary": true,
"notify_when": "onThrottleInterval",
"throttle": "1d"
},
"uuid": "53f3c2a3-e5d0-4cfa-af3b-6f0881385e78"
},
{
"group": "recovered",
"id": "fdbece50-406c-11ee-850e-c71febc4ca7f",
"params": {
"level": "info",
"message": "Recovered"
},
"connector_type_id": ".server-log",
"frequency": {
"summary": false,
"notify_when": "onActionGroupChange",
"throttle": null
},
"uuid": "2324e45b-c0df-45c7-9d70-4993e30be758"
}
],
"params": {
"thresholdComparator": ">",
"timeWindowSize": 1,
"timeWindowUnit": "d",
"threshold": [
100
],
"size": 100,
"timeField": "@timestamp",
"index": [
"kibana_sample_data_logs"
],
"esQuery": "\"\"\"{\"query\":{\"match_all\" : {}}}\"\"\"",
"excludeHitsFromPreviousRun": true,
"aggType": "count",
"groupBy": "all",
"searchType": "esQuery"
},
"scheduled_task_id": "58148c70-407f-11ee-850e-c71febc4ca7f",
"created_by": "elastic",
"updated_by": "elastic",
"created_at": "2023-08-22T00:03:38.263Z",
"updated_at": "2023-08-22T00:03:38.263Z",
"api_key_owner": "elastic",
"api_key_created_by_user": false,
"throttle": null,
"mute_all": false,
"notify_when": null,
"muted_alert_ids": [],
"execution_status": {
"status": "pending",
"last_execution_date": "2023-08-22T00:03:38.263Z"
},
"revision": 0,
"running": false
}
},
"create_es_query_kql_rule_response": {
"summary": "The create rule API returns a JSON object that contains details about the rule.",
"value": {
"id": "7bd506d0-2284-11ee-8fad-6101956ced88",
"enabled": true,
"name": "my Elasticsearch query rule\"",
"name": "my Elasticsearch query KQL rule\"",
"tags": [],
"rule_type_id": ".es-query",
"consumer": "alerts",
Expand Down Expand Up @@ -7504,13 +7657,5 @@
]
}
}
},
"security": [
{
"basicAuth": []
},
{
"apiKeyAuth": []
}
]
}
}
Loading