Skip to content

Commit 2dcf570

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add critical_query / critical_recovery_query to MonitorThresholds (DataDog#3368)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent f3bb71d commit 2dcf570

4 files changed

Lines changed: 38 additions & 2 deletions

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

lib/datadog_api_client/v1/api/monitors_api.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def create_monitor(body, opts = {})
147147
# - `operator`: <, <=, >, >=, ==, or !=
148148
# - `#`: an integer or decimal number used to set the threshold
149149
#
150+
# To use a dynamic threshold on a metric monitor with a formula query, replace `#` with the `threshold` keyword
151+
# (for example, `... > threshold`) and provide the threshold as a query via `critical_query` on `options.thresholds`.
152+
# This feature is in preview.
153+
#
150154
# If you are using the `_change_` or `_pct_change_` time aggregator, instead use `change_aggr(time_aggr(time_window),
151155
# timeshift):space_aggr:metric{tags} [by {key}] operator #` with:
152156
#

lib/datadog_api_client/v1/models/monitor_thresholds.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ class MonitorThresholds
2424
# The monitor `CRITICAL` threshold.
2525
attr_accessor :critical
2626

27+
# 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.
28+
attr_accessor :critical_query
29+
2730
# The monitor `CRITICAL` recovery threshold.
2831
attr_accessor :critical_recovery
2932

33+
# 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.
34+
attr_accessor :critical_recovery_query
35+
3036
# The monitor `OK` threshold.
3137
attr_accessor :ok
3238

@@ -46,7 +52,9 @@ class MonitorThresholds
4652
def self.attribute_map
4753
{
4854
:'critical' => :'critical',
55+
:'critical_query' => :'critical_query',
4956
:'critical_recovery' => :'critical_recovery',
57+
:'critical_recovery_query' => :'critical_recovery_query',
5058
:'ok' => :'ok',
5159
:'unknown' => :'unknown',
5260
:'warning' => :'warning',
@@ -59,7 +67,9 @@ def self.attribute_map
5967
def self.openapi_types
6068
{
6169
:'critical' => :'Float',
70+
:'critical_query' => :'String',
6271
:'critical_recovery' => :'Float',
72+
:'critical_recovery_query' => :'String',
6373
:'ok' => :'Float',
6474
:'unknown' => :'Float',
6575
:'warning' => :'Float',
@@ -101,10 +111,18 @@ def initialize(attributes = {})
101111
self.critical = attributes[:'critical']
102112
end
103113

114+
if attributes.key?(:'critical_query')
115+
self.critical_query = attributes[:'critical_query']
116+
end
117+
104118
if attributes.key?(:'critical_recovery')
105119
self.critical_recovery = attributes[:'critical_recovery']
106120
end
107121

122+
if attributes.key?(:'critical_recovery_query')
123+
self.critical_recovery_query = attributes[:'critical_recovery_query']
124+
end
125+
108126
if attributes.key?(:'ok')
109127
self.ok = attributes[:'ok']
110128
end
@@ -149,7 +167,9 @@ def ==(o)
149167
return true if self.equal?(o)
150168
self.class == o.class &&
151169
critical == o.critical &&
170+
critical_query == o.critical_query &&
152171
critical_recovery == o.critical_recovery &&
172+
critical_recovery_query == o.critical_recovery_query &&
153173
ok == o.ok &&
154174
unknown == o.unknown &&
155175
warning == o.warning &&
@@ -161,7 +181,7 @@ def ==(o)
161181
# @return [Integer] Hash code
162182
# @!visibility private
163183
def hash
164-
[critical, critical_recovery, ok, unknown, warning, warning_recovery, additional_properties].hash
184+
[critical, critical_query, critical_recovery, critical_recovery_query, ok, unknown, warning, warning_recovery, additional_properties].hash
165185
end
166186
end
167187
end

0 commit comments

Comments
 (0)