Skip to content

Commit 8abe36b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add scheduling_options to monitor definition (#890)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent c2bfb64 commit 8abe36b

File tree

11 files changed

+312
-5
lines changed

11 files changed

+312
-5
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-10-31 18:53:20.515808",
8-
"spec_repo_commit": "06929484"
7+
"regenerated": "2022-10-31 20:12:35.356850",
8+
"spec_repo_commit": "420bd229"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-10-31 18:53:20.528613",
13-
"spec_repo_commit": "06929484"
12+
"regenerated": "2022-10-31 20:12:35.369998",
13+
"spec_repo_commit": "420bd229"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6340,6 +6340,8 @@ components:
63406340
to `false` for sparse metrics,\notherwise some evaluations are skipped.
63416341
Default is false."
63426342
type: boolean
6343+
scheduling_options:
6344+
$ref: '#/components/schemas/MonitorOptionsSchedulingOptions'
63436345
silenced:
63446346
additionalProperties:
63456347
description: UTC epoch timestamp in seconds when the downtime for the
@@ -6391,6 +6393,39 @@ components:
63916393
type: string
63926394
readOnly: true
63936395
type: object
6396+
MonitorOptionsSchedulingOptions:
6397+
description: Configuration options for scheduling.
6398+
properties:
6399+
evaluation_window:
6400+
$ref: '#/components/schemas/MonitorOptionsSchedulingOptionsEvaluationWindow'
6401+
type: object
6402+
MonitorOptionsSchedulingOptionsEvaluationWindow:
6403+
description: Configuration options for the evaluation window. If `hour_starts`
6404+
is set, no other fields may be set. Otherwise, `day_starts` and `month_starts`
6405+
must be set together.
6406+
properties:
6407+
day_starts:
6408+
description: The time of the day at which a one day cumulative evaluation
6409+
window starts. Must be defined in UTC time in `HH:mm` format.
6410+
example: 04:00
6411+
type: string
6412+
hour_starts:
6413+
description: The minute of the hour at which a one hour cumulative evaluation
6414+
window starts.
6415+
example: 0
6416+
format: int32
6417+
maximum: 59
6418+
minimum: 0
6419+
type: integer
6420+
month_starts:
6421+
description: The day of the month at which a one month cumulative evaluation
6422+
window starts.
6423+
example: 1
6424+
format: int32
6425+
maximum: 1
6426+
minimum: 1
6427+
type: integer
6428+
type: object
63946429
MonitorOverallStates:
63956430
description: The different states your monitor can be in.
63966431
enum:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2022-10-28T19:34:06.761Z"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Monitors/Create a metric monitor returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "936c156958cc755daaee683db8cd2021",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 320,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 555,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_metric_monitor_returns_OK_response-1666985646\",\"options\":{\"scheduling_options\":{\"evaluation_window\":{\"day_starts\":\"04:00\",\"month_starts\":1}},\"thresholds\":{\"critical\":0.5}},\"query\":\"avg(current_1d):avg:system.load.5{*} > 0.5\",\"type\":\"metric alert\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/monitor"
39+
},
40+
"response": {
41+
"bodySize": 799,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 799,
45+
"text": "{\"restricted_roles\":null,\"tags\":[],\"deleted\":null,\"query\":\"avg(current_1d):avg:system.load.5{*} > 0.5\",\"message\":\"some message Notify: @hipchat-channel\",\"id\":101334182,\"multi\":false,\"name\":\"Test-Create_a_metric_monitor_returns_OK_response-1666985646\",\"created\":\"2022-10-28T19:34:06.916192+00:00\",\"created_at\":1666985646000,\"creator\":{\"id\":1445416,\"handle\":\"[email protected]\",\"name\":null,\"email\":\"[email protected]\"},\"org_id\":321813,\"modified\":\"2022-10-28T19:34:06.916192+00:00\",\"priority\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"type\":\"query alert\",\"options\":{\"notify_audit\":false,\"scheduling_options\":{\"evaluation_window\":{\"day_starts\":\"04:00\",\"month_starts\":1}},\"include_tags\":true,\"thresholds\":{\"critical\":0.5},\"silenced\":{},\"new_host_delay\":300,\"notify_no_data\":false}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 621,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2022-10-28T19:34:06.778Z",
61+
"time": 180
62+
},
63+
{
64+
"_id": "12513410df3146ac0022a43201da43ab",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 514,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/monitor/101334182"
82+
},
83+
"response": {
84+
"bodySize": 33,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 33,
88+
"text": "{\"deleted_monitor_id\":101334182}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 489,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2022-10-28T19:34:06.969Z",
104+
"time": 156
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Create a metric monitor returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.MonitorsApi(configuration);
9+
10+
const params: v1.MonitorsApiCreateMonitorRequest = {
11+
body: {
12+
name: "Example-Create_a_metric_monitor_returns_OK_response",
13+
type: "metric alert",
14+
query: "avg(current_1d):avg:system.load.5{*} > 0.5",
15+
message: "some message Notify: @hipchat-channel",
16+
options: {
17+
thresholds: {
18+
critical: 0.5,
19+
},
20+
schedulingOptions: {
21+
evaluationWindow: {
22+
dayStarts: "04:00",
23+
monthStarts: 1,
24+
},
25+
},
26+
},
27+
},
28+
};
29+
30+
apiInstance
31+
.createMonitor(params)
32+
.then((data: v1.Monitor) => {
33+
console.log(
34+
"API called successfully. Returned data: " + JSON.stringify(data)
35+
);
36+
})
37+
.catch((error: any) => console.error(error));

features/v1/monitors.feature

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ Feature: Monitors
6767
When the request is sent
6868
Then the response status is 200 OK
6969

70+
@team:DataDog/monitor-app
71+
Scenario: Create a metric monitor returns "OK" response
72+
Given new "CreateMonitor" request
73+
And body with value {"name": "{{ unique }}", "type": "metric alert", "query": "avg(current_1d):avg:system.load.5{*} > 0.5", "message": "some message Notify: @hipchat-channel", "options":{"thresholds":{"critical":0.5}, "scheduling_options":{"evaluation_window":{"day_starts":"04:00", "month_starts":1}}}}
74+
When the request is sent
75+
Then the response status is 200 OK
76+
7077
@team:DataDog/monitor-app
7178
Scenario: Create a monitor returns "Bad Request" response
7279
Given new "CreateMonitor" request
@@ -115,7 +122,7 @@ Feature: Monitors
115122
Scenario: Edit a monitor returns "Bad Request" response
116123
Given new "UpdateMonitor" request
117124
And request contains "monitor_id" parameter from "REPLACE.ME"
118-
And body with value {"options": {"escalation_message": "none", "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, "notify_audit": false, "notify_by": [], "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "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"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"}
125+
And body with value {"options": {"escalation_message": "none", "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, "notify_audit": false, "notify_by": [], "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "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"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"}
119126
When the request is sent
120127
Then the response status is 400 Bad Request
121128

packages/datadog-api-client-v1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ export { MonitorGroupSearchResponseCounts } from "./models/MonitorGroupSearchRes
581581
export { MonitorGroupSearchResult } from "./models/MonitorGroupSearchResult";
582582
export { MonitorOptions } from "./models/MonitorOptions";
583583
export { MonitorOptionsAggregation } from "./models/MonitorOptionsAggregation";
584+
export { MonitorOptionsSchedulingOptions } from "./models/MonitorOptionsSchedulingOptions";
585+
export { MonitorOptionsSchedulingOptionsEvaluationWindow } from "./models/MonitorOptionsSchedulingOptionsEvaluationWindow";
584586
export { MonitorOverallStates } from "./models/MonitorOverallStates";
585587
export { MonitorRenotifyStatusType } from "./models/MonitorRenotifyStatusType";
586588
export { MonitorSearchCountItem } from "./models/MonitorSearchCountItem";

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { MonitorDeviceID } from "./MonitorDeviceID";
77
import { MonitorFormulaAndFunctionQueryDefinition } from "./MonitorFormulaAndFunctionQueryDefinition";
88
import { MonitorOptionsAggregation } from "./MonitorOptionsAggregation";
9+
import { MonitorOptionsSchedulingOptions } from "./MonitorOptionsSchedulingOptions";
910
import { MonitorRenotifyStatusType } from "./MonitorRenotifyStatusType";
1011
import { MonitorThresholds } from "./MonitorThresholds";
1112
import { MonitorThresholdWindowOptions } from "./MonitorThresholdWindowOptions";
@@ -141,6 +142,10 @@ export class MonitorOptions {
141142
* otherwise some evaluations are skipped. Default is false.
142143
*/
143144
"requireFullWindow"?: boolean;
145+
/**
146+
* Configuration options for scheduling.
147+
*/
148+
"schedulingOptions"?: MonitorOptionsSchedulingOptions;
144149
/**
145150
* Information about the downtime applied to the monitor.
146151
*/
@@ -271,6 +276,10 @@ export class MonitorOptions {
271276
baseName: "require_full_window",
272277
type: "boolean",
273278
},
279+
schedulingOptions: {
280+
baseName: "scheduling_options",
281+
type: "MonitorOptionsSchedulingOptions",
282+
},
274283
silenced: {
275284
baseName: "silenced",
276285
type: "{ [key: string]: number; }",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
import { MonitorOptionsSchedulingOptionsEvaluationWindow } from "./MonitorOptionsSchedulingOptionsEvaluationWindow";
7+
8+
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
9+
10+
/**
11+
* Configuration options for scheduling.
12+
*/
13+
export class MonitorOptionsSchedulingOptions {
14+
/**
15+
* Configuration options for the evaluation window. If `hour_starts` is set, no other fields may be set. Otherwise, `day_starts` and `month_starts` must be set together.
16+
*/
17+
"evaluationWindow"?: MonitorOptionsSchedulingOptionsEvaluationWindow;
18+
19+
/**
20+
* @ignore
21+
*/
22+
"unparsedObject"?: any;
23+
24+
/**
25+
* @ignore
26+
*/
27+
static readonly attributeTypeMap: AttributeTypeMap = {
28+
evaluationWindow: {
29+
baseName: "evaluation_window",
30+
type: "MonitorOptionsSchedulingOptionsEvaluationWindow",
31+
},
32+
};
33+
34+
/**
35+
* @ignore
36+
*/
37+
static getAttributeTypeMap(): AttributeTypeMap {
38+
return MonitorOptionsSchedulingOptions.attributeTypeMap;
39+
}
40+
41+
public constructor() {}
42+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Configuration options for the evaluation window. If `hour_starts` is set, no other fields may be set. Otherwise, `day_starts` and `month_starts` must be set together.
11+
*/
12+
export class MonitorOptionsSchedulingOptionsEvaluationWindow {
13+
/**
14+
* The time of the day at which a one day cumulative evaluation window starts. Must be defined in UTC time in `HH:mm` format.
15+
*/
16+
"dayStarts"?: string;
17+
/**
18+
* The minute of the hour at which a one hour cumulative evaluation window starts.
19+
*/
20+
"hourStarts"?: number;
21+
/**
22+
* The day of the month at which a one month cumulative evaluation window starts.
23+
*/
24+
"monthStarts"?: number;
25+
26+
/**
27+
* @ignore
28+
*/
29+
"unparsedObject"?: any;
30+
31+
/**
32+
* @ignore
33+
*/
34+
static readonly attributeTypeMap: AttributeTypeMap = {
35+
dayStarts: {
36+
baseName: "day_starts",
37+
type: "string",
38+
},
39+
hourStarts: {
40+
baseName: "hour_starts",
41+
type: "number",
42+
format: "int32",
43+
},
44+
monthStarts: {
45+
baseName: "month_starts",
46+
type: "number",
47+
format: "int32",
48+
},
49+
};
50+
51+
/**
52+
* @ignore
53+
*/
54+
static getAttributeTypeMap(): AttributeTypeMap {
55+
return MonitorOptionsSchedulingOptionsEvaluationWindow.attributeTypeMap;
56+
}
57+
58+
public constructor() {}
59+
}

0 commit comments

Comments
 (0)