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

Fix monitors ID resolution and add support for new burn_rate SLO queries #182

Merged
merged 3 commits into from
Sep 19, 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
4 changes: 2 additions & 2 deletions datadog_sync/model/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def connect_id(self, key: str, r_obj: Dict, resource_to_connect: str) -> Optiona
synthetics_tests = self.config.resources["synthetics_tests"].resource_config.destination_resources
slos = self.config.resources["service_level_objectives"].resource_config.destination_resources

if r_obj.get("type") == "composite" and key == "query":
if r_obj.get("type") == "composite" and key == "query" and resource_to_connect != "service_level_objectives":
failed_connections = []
ids = re.findall("[0-9]+", r_obj[key])
for _id in ids:
Expand All @@ -117,7 +117,7 @@ def connect_id(self, key: str, r_obj: Dict, resource_to_connect: str) -> Optiona
return failed_connections
elif resource_to_connect == "service_level_objectives" and r_obj.get("type") == "slo alert" and key == "query":
failed_connections = []
if res := re.search(r"error_budget\(\"(.*)\"\)\.", r_obj[key]):
if res := re.search(r"(?:error_budget|burn_rate)\(\"(.*?)\"\)\.", r_obj[key]):
_id = res.group(1)
if _id in slos:
r_obj[key] = re.sub(_id, slos[_id]["id"], r_obj[key])
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:06:43.745795-04:00
2023-09-19T12:34:53.134728-04:00
2,800 changes: 1,104 additions & 1,696 deletions tests/integration/cassettes/test_cli/TestCli.test_cleanup.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:05:52.402421-04:00
2023-09-19T12:34:00.720243-04:00
2,756 changes: 1,256 additions & 1,500 deletions tests/integration/cassettes/test_cli/TestCli.test_import.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:05:55.640028-04:00
2023-09-19T12:34:03.991350-04:00
3,822 changes: 1,655 additions & 2,167 deletions tests/integration/cassettes/test_cli/TestCli.test_sync.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:09:49.346349-04:00
2023-09-19T12:26:45.600379-04:00
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:09:49.354636-04:00
2023-09-19T12:26:45.608259-04:00
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-00000000000000009508ae4e0b6b527f-19c057d2dd41a74e-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '1855579609643460430'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '10739024961687212671'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742272?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103075?force=True
response:
body:
string: '{"deleted_monitor_id": 12742272}'
string: '{"deleted_monitor_id": 13103075}'
headers: {}
status:
code: 200
Expand All @@ -38,23 +26,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-0000000000000000e136065bacb87bbb-3fb554e5a7c2d43b-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '4590668740512896059'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '16228165298085723067'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742271?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103078?force=True
response:
body:
string: '{"deleted_monitor_id": 12742271}'
string: '{"deleted_monitor_id": 13103078}'
headers: {}
status:
code: 200
Expand All @@ -68,23 +44,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-0000000000000000643a0edc743014ee-ffa2030a825c4c33-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '18420288769570393139'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '7222101292446913774'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742274?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103083?force=True
response:
body:
string: '{"deleted_monitor_id": 12742274}'
string: '{"deleted_monitor_id": 13103083}'
headers: {}
status:
code: 200
Expand All @@ -98,23 +62,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-000000000000000043fa3a09cfef7e95-aa4c066c97edab4e-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '12271190148152929102'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '4898291358536531605'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742275?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103080?force=True
response:
body:
string: '{"deleted_monitor_id": 12742275}'
string: '{"deleted_monitor_id": 13103080}'
headers: {}
status:
code: 200
Expand All @@ -128,23 +80,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-0000000000000000378e81de1d16febc-d457418428aa4478-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '15300770294888285304'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '4003279909749718716'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742273?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103081?force=True
response:
body:
string: '{"deleted_monitor_id": 12742273}'
string: '{"deleted_monitor_id": 13103081}'
headers: {}
status:
code: 200
Expand All @@ -158,23 +98,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-000000000000000099a7d55763f9b1dd-ef3b7d8247e0381e-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '17238509997195802654'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '11072052780229833181'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742269?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103079?force=True
response:
body:
string: '{"deleted_monitor_id": 12742269}'
string: '{"deleted_monitor_id": 13103079}'
headers: {}
status:
code: 200
Expand All @@ -188,23 +116,11 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-0000000000000000e52fb0ce368f4567-b10aa7a25a76b11c-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '12757193210224619804'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '16514612758316008807'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742270?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103077?force=True
response:
body:
string: '{"deleted_monitor_id": 12742270}'
string: '{"deleted_monitor_id": 13103077}'
headers: {}
status:
code: 200
Expand All @@ -218,23 +134,29 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-0000000000000000667832788d872316-724b1ae6138983bf-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '8235705919049663423'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '7383707082425836310'
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/12742268?force=True
uri: https://api.datadoghq.eu/api/v1/monitor/13103082?force=True
response:
body:
string: '{"deleted_monitor_id": 12742268}'
string: '{"deleted_monitor_id": 13103082}'
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
method: DELETE
uri: https://api.datadoghq.eu/api/v1/monitor/13103076?force=True
response:
body:
string: '{"deleted_monitor_id": 13103076}'
headers: {}
status:
code: 200
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:09:42.606412-04:00
2023-09-19T12:26:38.049526-04:00
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ interactions:
- gzip, deflate
Content-Type:
- application/json
traceparent:
- 00-00000000000000001100bd41c8605904-979f1d4aa1bd708c-01
tracestate:
- dd=s:1;t.dm:-0
x-datadog-parent-id:
- '10925483427402444940'
x-datadog-sampling-priority:
- '1'
x-datadog-tags:
- _dd.p.dm=-0
x-datadog-trace-id:
- '1225187188877056260'
method: GET
uri: https://api.datadoghq.com/api/v1/monitor?page=0&page_size=100
response:
Expand Down Expand Up @@ -131,7 +119,7 @@ interactions:
false, "escalation_message": "", "thresholds": {"critical": 100.0}, "silenced":
{}}, "multi": false, "created_at": 1647980371000, "created": "2022-03-22T20:19:31.437344+00:00",
"modified": "2022-03-22T20:19:31.437344+00:00", "deleted": null, "restricted_roles":
null, "priority": null, "overall_state_modified": "2022-03-22T20:22:09+00:00",
null, "priority": null, "overall_state_modified": "2023-09-11T14:20:07+00:00",
"overall_state": "OK", "creator": {"name": "Datadog Support", "handle": "support-datadogsynccliustestorg-1137936",
"email": "support-user-prod@datadoghq.com", "id": 3205966}, "matching_downtimes":
[]}, {"id": 103095757, "org_id": 569509, "type": "synthetics alert", "name":
Expand All @@ -153,7 +141,7 @@ interactions:
0, "silenced": {}}, "multi": false, "created_at": 1668546304000, "created":
"2022-11-15T21:05:04.460432+00:00", "modified": "2022-11-15T21:05:04.460432+00:00",
"deleted": null, "restricted_roles": null, "priority": null, "overall_state_modified":
"2023-07-14T05:05:08+00:00", "overall_state": "OK", "creator": {"name": "Sherzod
"2023-09-10T05:20:09+00:00", "overall_state": "OK", "creator": {"name": "Sherzod
Karimov", "handle": "sherzod.karimov@datadoghq.com", "email": "sherzod.karimov@datadoghq.com",
"id": 2781275}, "matching_downtimes": []}, {"id": 103095759, "org_id": 569509,
"type": "synthetics alert", "name": "[Synthetics] TCP Test", "message": "Notify
Expand All @@ -164,7 +152,7 @@ interactions:
0, "silenced": {}}, "multi": false, "created_at": 1668546304000, "created":
"2022-11-15T21:05:04.469143+00:00", "modified": "2022-11-15T21:05:04.469143+00:00",
"deleted": null, "restricted_roles": null, "priority": null, "overall_state_modified":
"2023-07-24T13:35:10+00:00", "overall_state": "OK", "creator": {"name": "Sherzod
"2023-09-08T20:21:09+00:00", "overall_state": "OK", "creator": {"name": "Sherzod
Karimov", "handle": "sherzod.karimov@datadoghq.com", "email": "sherzod.karimov@datadoghq.com",
"id": 2781275}, "matching_downtimes": []}, {"id": 103095760, "org_id": 569509,
"type": "synthetics alert", "name": "[Synthetics] Browser Test (cloned)",
Expand Down Expand Up @@ -221,15 +209,25 @@ interactions:
"overall_state": "No Data", "creator": {"name": "Frog", "handle": "frog@datadoghq.com",
"email": "frog@datadoghq.com", "id": 2781302}, "matching_downtimes": []},
{"id": 124728911, "org_id": 569509, "type": "slo alert", "name": "Test slo
monitor", "message": "Random message", "tags": [], "query": "error_budget(\"ba72d10835d75e0c8910597144f3733a\").over(\"7d\")
> 100", "options": {"thresholds": {"critical": 100.0}, "notify_no_data": false,
monitor", "message": "Random message", "tags": [], "query": "burn_rate(\"ba72d10835d75e0c8910597144f3733a\").over(\"7d\").long_window(\"1h\").short_window(\"5m\")
> 1", "options": {"thresholds": {"critical": 1.0}, "notify_no_data": false,
"notify_audit": false, "new_host_delay": 300, "include_tags": true, "silenced":
{}}, "multi": false, "created_at": 1688999118000, "created": "2023-07-10T14:25:18.627726+00:00",
"modified": "2023-07-10T14:25:18.627726+00:00", "deleted": null, "restricted_roles":
"modified": "2023-09-19T16:02:35.079242+00:00", "deleted": null, "restricted_roles":
null, "priority": null, "overall_state_modified": "2023-07-10T14:25:22+00:00",
"overall_state": "No Data", "creator": {"name": "Sherzod Karimov", "handle":
"sherzod.karimov@datadoghq.com", "email": "sherzod.karimov@datadoghq.com",
"id": 2781275}, "matching_downtimes": []}]'
"id": 2781275}, "matching_downtimes": []}, {"id": 131664819, "org_id": 569509,
"type": "slo alert", "name": "Check monitor slo", "message": "Message", "tags":
[], "query": "error_budget(\"b02adcb3d95a5c3dbfebf7c94bf4e8c5\").over(\"7d\")
> 90", "options": {"thresholds": {"critical": 90.0}, "notify_no_data": false,
"notify_audit": false, "new_host_delay": 300, "include_tags": true, "silenced":
{}}, "multi": false, "created_at": 1695138188000, "created": "2023-09-19T15:43:08.383274+00:00",
"modified": "2023-09-19T15:43:08.383274+00:00", "deleted": null, "restricted_roles":
null, "priority": null, "overall_state_modified": "2023-09-19T15:43:10+00:00",
"overall_state": "OK", "creator": {"name": "Sherzod Karimov", "handle": "sherzod.karimov@datadoghq.com",
"email": "sherzod.karimov@datadoghq.com", "id": 2781275}, "matching_downtimes":
[]}]'
headers:
Content-Type:
- application/json
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-24T10:09:42.900560-04:00
2023-09-19T12:26:38.243196-04:00
Loading
Loading