Skip to content
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
12 changes: 12 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9229,11 +9229,19 @@ components:
description: The monitor `CRITICAL` threshold.
format: double
type: number
critical_query:
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.
example: 'formula("2 * query1").rollup("avg").last("6mo")'
type: string
critical_recovery:
description: The monitor `CRITICAL` recovery threshold.
format: double
nullable: true
type: number
critical_recovery_query:
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.
example: 'formula("1.5 * query1").rollup("avg").last("3mo")'
type: string
ok:
description: The monitor `OK` threshold.
format: double
Expand Down Expand Up @@ -33700,6 +33708,10 @@ paths:
- `operator`: <, <=, >, >=, ==, or !=
- `#`: an integer or decimal number used to set the threshold

To use a dynamic threshold on a metric monitor with a formula query, replace `#` with the `threshold` keyword
(for example, `... > threshold`) and provide the threshold as a query via `critical_query` on `options.thresholds`.
This feature is in preview.

If you are using the `_change_` or `_pct_change_` time aggregator, instead use `change_aggr(time_aggr(time_window),
timeshift):space_aggr:metric{tags} [by {key}] operator #` with:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ public CompletableFuture<Monitor> createMonitorAsync(Monitor body) {
* <li><code>#</code>: an integer or decimal number used to set the threshold
* </ul>
*
* <p>To use a dynamic threshold on a metric monitor with a formula query, replace <code>#</code>
* with the <code>threshold</code> keyword (for example, <code>... &gt; threshold</code>) and
* provide the threshold as a query via <code>critical_query</code> on <code>options.thresholds
* </code>. This feature is in preview.
*
* <p>If you are using the <code>_change_</code> or <code>_pct_change_</code> time aggregator,
* instead use <code>change_aggr(time_aggr(time_window),
* timeshift):space_aggr:metric{tags} [by {key}] operator #</code> with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
/** List of the different monitor threshold available. */
@JsonPropertyOrder({
MonitorThresholds.JSON_PROPERTY_CRITICAL,
MonitorThresholds.JSON_PROPERTY_CRITICAL_QUERY,
MonitorThresholds.JSON_PROPERTY_CRITICAL_RECOVERY,
MonitorThresholds.JSON_PROPERTY_CRITICAL_RECOVERY_QUERY,
MonitorThresholds.JSON_PROPERTY_OK,
MonitorThresholds.JSON_PROPERTY_UNKNOWN,
MonitorThresholds.JSON_PROPERTY_WARNING,
Expand All @@ -33,9 +35,15 @@ public class MonitorThresholds {
public static final String JSON_PROPERTY_CRITICAL = "critical";
private Double critical;

public static final String JSON_PROPERTY_CRITICAL_QUERY = "critical_query";
private String criticalQuery;

public static final String JSON_PROPERTY_CRITICAL_RECOVERY = "critical_recovery";
private JsonNullable<Double> criticalRecovery = JsonNullable.<Double>undefined();

public static final String JSON_PROPERTY_CRITICAL_RECOVERY_QUERY = "critical_recovery_query";
private String criticalRecoveryQuery;

public static final String JSON_PROPERTY_OK = "ok";
private JsonNullable<Double> ok = JsonNullable.<Double>undefined();

Expand Down Expand Up @@ -69,6 +77,29 @@ public void setCritical(Double critical) {
this.critical = critical;
}

public MonitorThresholds criticalQuery(String criticalQuery) {
this.criticalQuery = criticalQuery;
return this;
}

/**
* Query evaluated as a dynamic <code>CRITICAL</code> threshold. Only supported on metric monitors
* with a formula query and options['variables']. Cannot be combined with static thresholds. This
* field is in preview.
*
* @return criticalQuery
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CRITICAL_QUERY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getCriticalQuery() {
return criticalQuery;
}

public void setCriticalQuery(String criticalQuery) {
this.criticalQuery = criticalQuery;
}

public MonitorThresholds criticalRecovery(Double criticalRecovery) {
this.criticalRecovery = JsonNullable.<Double>of(criticalRecovery);
return this;
Expand Down Expand Up @@ -100,6 +131,29 @@ public void setCriticalRecovery(Double criticalRecovery) {
this.criticalRecovery = JsonNullable.<Double>of(criticalRecovery);
}

public MonitorThresholds criticalRecoveryQuery(String criticalRecoveryQuery) {
this.criticalRecoveryQuery = criticalRecoveryQuery;
return this;
}

/**
* Query evaluated as a dynamic <code>CRITICAL</code> 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.
*
* @return criticalRecoveryQuery
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CRITICAL_RECOVERY_QUERY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getCriticalRecoveryQuery() {
return criticalRecoveryQuery;
}

public void setCriticalRecoveryQuery(String criticalRecoveryQuery) {
this.criticalRecoveryQuery = criticalRecoveryQuery;
}

public MonitorThresholds ok(Double ok) {
this.ok = JsonNullable.<Double>of(ok);
return this;
Expand Down Expand Up @@ -281,7 +335,9 @@ public boolean equals(Object o) {
}
MonitorThresholds monitorThresholds = (MonitorThresholds) o;
return Objects.equals(this.critical, monitorThresholds.critical)
&& Objects.equals(this.criticalQuery, monitorThresholds.criticalQuery)
&& Objects.equals(this.criticalRecovery, monitorThresholds.criticalRecovery)
&& Objects.equals(this.criticalRecoveryQuery, monitorThresholds.criticalRecoveryQuery)
&& Objects.equals(this.ok, monitorThresholds.ok)
&& Objects.equals(this.unknown, monitorThresholds.unknown)
&& Objects.equals(this.warning, monitorThresholds.warning)
Expand All @@ -292,15 +348,27 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
return Objects.hash(
critical, criticalRecovery, ok, unknown, warning, warningRecovery, additionalProperties);
critical,
criticalQuery,
criticalRecovery,
criticalRecoveryQuery,
ok,
unknown,
warning,
warningRecovery,
additionalProperties);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MonitorThresholds {\n");
sb.append(" critical: ").append(toIndentedString(critical)).append("\n");
sb.append(" criticalQuery: ").append(toIndentedString(criticalQuery)).append("\n");
sb.append(" criticalRecovery: ").append(toIndentedString(criticalRecovery)).append("\n");
sb.append(" criticalRecoveryQuery: ")
.append(toIndentedString(criticalRecoveryQuery))
.append("\n");
sb.append(" ok: ").append(toIndentedString(ok)).append("\n");
sb.append(" unknown: ").append(toIndentedString(unknown)).append("\n");
sb.append(" warning: ").append(toIndentedString(warning)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Feature: Monitors
Scenario: Edit a monitor returns "Bad Request" response
Given new "UpdateMonitor" request
And request contains "monitor_id" parameter from "REPLACE.ME"
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"}
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"}
When the request is sent
Then the response status is 400 Bad Request

Expand Down
Loading