Skip to content

Commit 32dd927

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add critical_query / critical_recovery_query to MonitorThresholds (#4230)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 5650b18 commit 32dd927

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9229,11 +9229,19 @@ components:
92299229
description: The monitor `CRITICAL` threshold.
92309230
format: double
92319231
type: number
9232+
critical_query:
9233+
description: Query evaluated as a dynamic `CRITICAL` threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
9234+
example: 'formula("2 * query1").rollup("avg").last("6mo")'
9235+
type: string
92329236
critical_recovery:
92339237
description: The monitor `CRITICAL` recovery threshold.
92349238
format: double
92359239
nullable: true
92369240
type: number
9241+
critical_recovery_query:
9242+
description: Query evaluated as a dynamic `CRITICAL` recovery threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
9243+
example: 'formula("1.5 * query1").rollup("avg").last("3mo")'
9244+
type: string
92379245
ok:
92389246
description: The monitor `OK` threshold.
92399247
format: double
@@ -33700,6 +33708,10 @@ paths:
3370033708
- `operator`: <, <=, >, >=, ==, or !=
3370133709
- `#`: an integer or decimal number used to set the threshold
3370233710

33711+
To use a dynamic threshold on a metric monitor with a formula query, replace `#` with the `threshold` keyword
33712+
(for example, `... > threshold`) and provide the threshold as a query via `critical_query` on `options.thresholds`.
33713+
This feature is in preview.
33714+
3370333715
If you are using the `_change_` or `_pct_change_` time aggregator, instead use `change_aggr(time_aggr(time_window),
3370433716
timeshift):space_aggr:metric{tags} [by {key}] operator #` with:
3370533717

features/v1/monitors.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Feature: Monitors
219219
Scenario: Edit a monitor returns "Bad Request" response
220220
Given new "UpdateMonitor" request
221221
And request contains "monitor_id" parameter from "REPLACE.ME"
222-
And body with value {"assets": [{"category": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration", "name": "compute_result", "source": "filter_query"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}, "source": "filter_query"}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
222+
And body with value {"assets": [{"category": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_query": "formula(\"2 * query1\").rollup(\"avg\").last(\"6mo\")", "critical_recovery": null, "critical_recovery_query": "formula(\"1.5 * query1\").rollup(\"avg\").last(\"3mo\")", "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration", "name": "compute_result", "source": "filter_query"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}, "source": "filter_query"}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
223223
When the request is sent
224224
Then the response status is 400 Bad Request
225225

packages/datadog-api-client-v1/apis/MonitorsApi.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,10 @@ export class MonitorsApi {
14701470
* - `operator`: <, <=, >, >=, ==, or !=
14711471
* - `#`: an integer or decimal number used to set the threshold
14721472
*
1473+
* To use a dynamic threshold on a metric monitor with a formula query, replace `#` with the `threshold` keyword
1474+
* (for example, `... > threshold`) and provide the threshold as a query via `critical_query` on `options.thresholds`.
1475+
* This feature is in preview.
1476+
*
14731477
* If you are using the `_change_` or `_pct_change_` time aggregator, instead use `change_aggr(time_aggr(time_window),
14741478
* timeshift):space_aggr:metric{tags} [by {key}] operator #` with:
14751479
*

packages/datadog-api-client-v1/models/MonitorThresholds.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ export class MonitorThresholds {
1414
* The monitor `CRITICAL` threshold.
1515
*/
1616
"critical"?: number;
17+
/**
18+
* Query evaluated as a dynamic `CRITICAL` threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
19+
*/
20+
"criticalQuery"?: string;
1721
/**
1822
* The monitor `CRITICAL` recovery threshold.
1923
*/
2024
"criticalRecovery"?: number;
25+
/**
26+
* Query evaluated as a dynamic `CRITICAL` recovery threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
27+
*/
28+
"criticalRecoveryQuery"?: string;
2129
/**
2230
* The monitor `OK` threshold.
2331
*/
@@ -56,11 +64,19 @@ export class MonitorThresholds {
5664
type: "number",
5765
format: "double",
5866
},
67+
criticalQuery: {
68+
baseName: "critical_query",
69+
type: "string",
70+
},
5971
criticalRecovery: {
6072
baseName: "critical_recovery",
6173
type: "number",
6274
format: "double",
6375
},
76+
criticalRecoveryQuery: {
77+
baseName: "critical_recovery_query",
78+
type: "string",
79+
},
6480
ok: {
6581
baseName: "ok",
6682
type: "number",

0 commit comments

Comments
 (0)