-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathCreateMonitor_1539578087.py
More file actions
57 lines (53 loc) · 2.2 KB
/
CreateMonitor_1539578087.py
File metadata and controls
57 lines (53 loc) · 2.2 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Create a metric monitor with a custom schedule 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_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
MonitorOptionsCustomScheduleRecurrence,
)
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
MonitorOptionsSchedulingOptionsEvaluationWindow,
)
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
message="some message Notify: @hipchat-channel",
name="Example-Monitor",
query="avg(current_1mo):avg:system.load.5{*} > 0.5",
tags=[],
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=0.5,
),
notify_audit=False,
include_tags=False,
scheduling_options=MonitorOptionsSchedulingOptions(
evaluation_window=MonitorOptionsSchedulingOptionsEvaluationWindow(
day_starts="04:00",
month_starts=1,
),
custom_schedule=MonitorOptionsCustomSchedule(
recurrences=[
MonitorOptionsCustomScheduleRecurrence(
rrule="FREQ=DAILY;INTERVAL=1",
timezone="America/Los_Angeles",
start="2024-10-26T09:13:00",
),
],
),
),
),
type=MonitorType.QUERY_ALERT,
draft_status=MonitorDraftStatus.PUBLISHED,
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)