-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathCreateMonitor_440013737.py
More file actions
36 lines (32 loc) · 1.17 KB
/
CreateMonitor_440013737.py
File metadata and controls
36 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Create an Error Tracking monitor returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
name="Example-Monitor",
type=MonitorType.ERROR_TRACKING_ALERT,
query='error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1',
message="some message",
tags=[
"test:examplemonitor",
"env:ci",
],
priority=3,
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=1.0,
),
),
draft_status=MonitorDraftStatus.DRAFT,
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)