0
# HTTP API Client
1
2
Complete REST API client providing access to all Datadog HTTP endpoints. The API client handles authentication, request formatting, response parsing, error handling, and retry logic for all Datadog platform functionality.
3
4
## Capabilities
5
6
### Events Management
7
8
Create, query, and retrieve events in your Datadog event stream for tracking deployments, alerts, and significant occurrences.
9
10
```python { .api }
11
class Event:
12
@staticmethod
13
def create(title, text, **kwargs):
14
"""
15
Post an event to Datadog.
16
17
Parameters:
18
- title (str): Event title
19
- text (str): Event description
20
- date_happened (int, optional): Unix timestamp when event occurred
21
- priority (str, optional): Event priority ('normal' or 'low')
22
- tags (list, optional): List of tags to apply
23
- alert_type (str, optional): 'error', 'warning', 'info', or 'success'
24
- aggregation_key (str, optional): Key for event aggregation
25
- source_type_name (str, optional): Source type name
26
- host (str, optional): Host name
27
28
Returns:
29
dict: Response with event details and status
30
"""
31
32
@staticmethod
33
def query(**kwargs):
34
"""
35
Query the event stream.
36
37
Parameters:
38
- start (int): Unix timestamp for start time
39
- end (int): Unix timestamp for end time
40
- priority (str, optional): Filter by priority
41
- sources (str, optional): Comma-separated source list
42
- tags (str, optional): Comma-separated tag list
43
- unaggregated (bool, optional): Get individual events
44
45
Returns:
46
dict: Events matching query criteria
47
"""
48
49
@staticmethod
50
def get(event_id):
51
"""
52
Get details for a specific event.
53
54
Parameters:
55
- event_id (int): Event identifier
56
57
Returns:
58
dict: Event details
59
"""
60
```
61
62
### Metrics Management
63
64
Query historical metrics data and submit custom metrics to Datadog for monitoring and alerting.
65
66
```python { .api }
67
class Metric:
68
@staticmethod
69
def query(**kwargs):
70
"""
71
Query for metrics data from Datadog.
72
73
Parameters:
74
- query (str): Metrics query string
75
- start (int): Start time as Unix timestamp
76
- end (int): End time as Unix timestamp
77
78
Returns:
79
dict: Time series data for the metrics query
80
"""
81
82
@staticmethod
83
def send(**kwargs):
84
"""
85
Submit metrics to Datadog.
86
87
Parameters:
88
- metric (str): Metric name
89
- points (list): List of [timestamp, value] pairs
90
- host (str, optional): Host name
91
- tags (list, optional): List of tags
92
- type (str, optional): Metric type ('gauge', 'count', 'rate')
93
- interval (int, optional): Interval in seconds
94
95
Returns:
96
dict: Submission status
97
"""
98
99
@staticmethod
100
def list(from_epoch):
101
"""
102
List all active metrics since a given time.
103
104
Parameters:
105
- from_epoch (int): Start time as Unix timestamp (seconds)
106
107
Returns:
108
dict: List of active metric names
109
"""
110
```
111
112
### Monitors Management
113
114
Create, configure, and manage monitors for automated alerting on metrics, logs, traces, and synthetic tests.
115
116
```python { .api }
117
class Monitor:
118
@staticmethod
119
def create(type, query, **kwargs):
120
"""
121
Create a new monitor.
122
123
Parameters:
124
- type (str): Monitor type ('metric alert', 'service check', etc.)
125
- query (str): Monitor query defining alert conditions
126
- name (str, optional): Monitor name
127
- message (str, optional): Alert message with notification details
128
- tags (list, optional): List of tags
129
- options (dict, optional): Monitor configuration options
130
- priority (int, optional): Priority level (1-5)
131
- restricted_roles (list, optional): Role UUIDs with edit access
132
133
Returns:
134
dict: Created monitor details with ID
135
"""
136
137
@staticmethod
138
def get_all(**kwargs):
139
"""
140
Get all monitors.
141
142
Parameters:
143
- group_states (list, optional): Filter by group states
144
- name (str, optional): Filter by monitor name
145
- tags (str, optional): Comma-separated tag filters
146
- monitor_tags (str, optional): Comma-separated monitor tag filters
147
- with_downtimes (bool, optional): Include downtime info
148
- id_offset (int, optional): Monitor ID offset for pagination
149
- page (int, optional): Page number for pagination
150
- page_size (int, optional): Number of monitors per page
151
152
Returns:
153
list: List of monitor objects
154
"""
155
156
@staticmethod
157
def get(monitor_id, **kwargs):
158
"""
159
Get monitor details by ID.
160
161
Parameters:
162
- monitor_id (int): Monitor identifier
163
- group_states (list, optional): Filter by group states
164
- with_downtimes (bool, optional): Include associated downtimes
165
166
Returns:
167
dict: Monitor configuration and status
168
"""
169
170
@staticmethod
171
def update(monitor_id, **kwargs):
172
"""
173
Update existing monitor.
174
175
Parameters:
176
- monitor_id (int): Monitor identifier
177
- type (str, optional): Monitor type
178
- query (str, optional): Updated query
179
- name (str, optional): Updated name
180
- message (str, optional): Updated message
181
- tags (list, optional): Updated tags
182
- options (dict, optional): Updated options
183
184
Returns:
185
dict: Updated monitor details
186
"""
187
188
@staticmethod
189
def delete(monitor_id, **kwargs):
190
"""
191
Delete a monitor.
192
193
Parameters:
194
- monitor_id (int): Monitor identifier
195
- force (bool, optional): Force deletion even if referenced
196
197
Returns:
198
dict: Deletion status
199
"""
200
201
@staticmethod
202
def mute(monitor_id, **kwargs):
203
"""
204
Mute monitor notifications.
205
206
Parameters:
207
- monitor_id (int): Monitor identifier
208
- scope (str, optional): Scope for muting (e.g., 'host:web01')
209
- end (int, optional): Unix timestamp when muting ends
210
211
Returns:
212
dict: Muting status
213
"""
214
215
@staticmethod
216
def unmute(monitor_id, **kwargs):
217
"""
218
Unmute monitor notifications.
219
220
Parameters:
221
- monitor_id (int): Monitor identifier
222
- scope (str, optional): Scope for unmuting
223
224
Returns:
225
dict: Unmuting status
226
"""
227
228
@staticmethod
229
def mute_all():
230
"""
231
Globally mute all monitors.
232
233
Returns:
234
dict: Global muting status
235
"""
236
237
@staticmethod
238
def unmute_all():
239
"""
240
Cancel global monitor mute setting (does not remove individual monitor mutes).
241
242
Returns:
243
dict: Global unmuting status
244
"""
245
246
@staticmethod
247
def search(**kwargs):
248
"""
249
Search monitors.
250
251
Parameters:
252
- query (str, optional): Search query for monitors
253
- page (int, optional): Page number for pagination
254
- per_page (int, optional): Number of results per page
255
256
Returns:
257
dict: Monitors matching search criteria
258
"""
259
260
@staticmethod
261
def search_groups(**kwargs):
262
"""
263
Search monitor groups.
264
265
Parameters:
266
- query (str, optional): Search query for groups
267
- page (int, optional): Page number for pagination
268
- per_page (int, optional): Number of results per page
269
270
Returns:
271
dict: Monitor groups matching search criteria
272
"""
273
274
@staticmethod
275
def can_delete(**kwargs):
276
"""
277
Check if monitors can be deleted.
278
279
Parameters:
280
- monitor_ids (list): List of monitor IDs to check
281
282
Returns:
283
dict: Deletion eligibility status for each monitor
284
"""
285
286
@staticmethod
287
def validate(**kwargs):
288
"""
289
Validate monitor configuration without creating.
290
291
Parameters:
292
- type (str): Monitor type
293
- query (str): Monitor query
294
- name (str, optional): Monitor name
295
- message (str, optional): Alert message
296
- options (dict, optional): Monitor options
297
298
Returns:
299
dict: Validation results and any errors
300
"""
301
```
302
303
### Dashboard Management
304
305
Create and manage dashboards for data visualization with widgets, layouts, and sharing configurations.
306
307
```python { .api }
308
class Dashboard:
309
@staticmethod
310
def create(**kwargs):
311
"""
312
Create a new dashboard.
313
314
Parameters:
315
- title (str): Dashboard title
316
- widgets (list): List of widget definitions
317
- layout_type (str): Layout type ('ordered' or 'free')
318
- description (str, optional): Dashboard description
319
- is_read_only (bool, optional): Read-only status
320
- notify_list (list, optional): List of notification handles
321
- template_variables (list, optional): Template variable definitions
322
- reflow_type (str, optional): Reflow behavior for 'ordered' layout
323
324
Returns:
325
dict: Created dashboard with ID and URL
326
"""
327
328
@staticmethod
329
def get_all(**kwargs):
330
"""
331
Get all dashboards.
332
333
Parameters:
334
- filter_shared (bool, optional): Filter by shared status
335
- filter_deleted (bool, optional): Include deleted dashboards
336
337
Returns:
338
dict: List of dashboard summaries
339
"""
340
341
@staticmethod
342
def get(dashboard_id):
343
"""
344
Get dashboard by ID.
345
346
Parameters:
347
- dashboard_id (str): Dashboard identifier
348
349
Returns:
350
dict: Complete dashboard configuration
351
"""
352
353
@staticmethod
354
def update(dashboard_id, **kwargs):
355
"""
356
Update existing dashboard.
357
358
Parameters:
359
- dashboard_id (str): Dashboard identifier
360
- title (str, optional): Updated title
361
- widgets (list, optional): Updated widget list
362
- layout_type (str, optional): Updated layout type
363
- description (str, optional): Updated description
364
365
Returns:
366
dict: Updated dashboard details
367
"""
368
369
@staticmethod
370
def delete(dashboard_id):
371
"""
372
Delete a dashboard.
373
374
Parameters:
375
- dashboard_id (str): Dashboard identifier
376
377
Returns:
378
dict: Deletion confirmation
379
"""
380
```
381
382
### Infrastructure Management
383
384
Manage hosts, tags, and infrastructure components for monitoring and organization.
385
386
```python { .api }
387
class Host:
388
@staticmethod
389
def mute(hostname, **kwargs):
390
"""
391
Mute notifications for a host.
392
393
Parameters:
394
- hostname (str): Host name to mute
395
- end (int, optional): Unix timestamp when muting ends
396
- message (str, optional): Muting reason message
397
- override (bool, optional): Override existing muting
398
399
Returns:
400
dict: Muting status and details
401
"""
402
403
@staticmethod
404
def unmute(hostname):
405
"""
406
Unmute notifications for a host.
407
408
Parameters:
409
- hostname (str): Host name to unmute
410
411
Returns:
412
dict: Unmuting confirmation
413
"""
414
415
class Hosts:
416
@staticmethod
417
def search(**kwargs):
418
"""
419
Search for hosts.
420
421
Parameters:
422
- filter (str, optional): Search filter
423
- sort_field (str, optional): Field to sort by
424
- sort_dir (str, optional): Sort direction ('asc' or 'desc')
425
- start (int, optional): Start index for pagination
426
- count (int, optional): Number of results to return
427
- include_muted_hosts_data (bool, optional): Include muted hosts
428
- include_hosts_metadata (bool, optional): Include metadata
429
430
Returns:
431
dict: Host search results with metadata
432
"""
433
434
@staticmethod
435
def get_all():
436
"""
437
Get all hosts.
438
439
Returns:
440
list: List of all host names
441
"""
442
443
@staticmethod
444
def totals():
445
"""
446
Get host count totals.
447
448
Returns:
449
dict: Total host counts by status
450
"""
451
452
class Tag:
453
@staticmethod
454
def create(host, tags, **kwargs):
455
"""
456
Add tags to a host.
457
458
Parameters:
459
- host (str): Host name
460
- tags (list): List of tags to add
461
- source (str, optional): Tag source identifier
462
463
Returns:
464
dict: Updated host tags
465
"""
466
467
@staticmethod
468
def update(host, tags, **kwargs):
469
"""
470
Update host tags (replaces existing).
471
472
Parameters:
473
- host (str): Host name
474
- tags (list): Complete list of tags
475
- source (str, optional): Tag source identifier
476
477
Returns:
478
dict: Updated host tags
479
"""
480
481
@staticmethod
482
def get(host, **kwargs):
483
"""
484
Get tags for a host.
485
486
Parameters:
487
- host (str): Host name
488
- source (str, optional): Filter by tag source
489
- by_source (bool, optional): Group tags by source
490
491
Returns:
492
dict: Host tags organized by source
493
"""
494
495
@staticmethod
496
def get_all(**kwargs):
497
"""
498
Get all tags.
499
500
Parameters:
501
- source (str, optional): Filter by tag source
502
503
Returns:
504
dict: All tags in the organization
505
"""
506
507
@staticmethod
508
def delete(host, **kwargs):
509
"""
510
Remove all tags from a host.
511
512
Parameters:
513
- host (str): Host name
514
- source (str, optional): Remove tags from specific source only
515
516
Returns:
517
dict: Deletion confirmation
518
"""
519
```
520
521
### Downtime Management
522
523
Schedule and manage downtime periods to suppress monitor notifications during maintenance windows.
524
525
```python { .api }
526
class Downtime:
527
@staticmethod
528
def create(**kwargs):
529
"""
530
Schedule downtime.
531
532
Parameters:
533
- scope (list): Downtime scope (host tags, monitor tags, etc.)
534
- start (int, optional): Unix timestamp for start time
535
- end (int, optional): Unix timestamp for end time
536
- message (str, optional): Downtime message
537
- timezone (str, optional): Timezone identifier
538
- recurrence (dict, optional): Recurrence configuration
539
- monitor_id (int, optional): Specific monitor to mute
540
- monitor_tags (list, optional): Monitor tags to match
541
542
Returns:
543
dict: Created downtime with ID and schedule
544
"""
545
546
@staticmethod
547
def get_all(**kwargs):
548
"""
549
Get all downtimes.
550
551
Parameters:
552
- current_only (bool, optional): Only active downtimes
553
- with_creator (bool, optional): Include creator information
554
555
Returns:
556
list: List of scheduled downtimes
557
"""
558
559
@staticmethod
560
def get(downtime_id):
561
"""
562
Get downtime by ID.
563
564
Parameters:
565
- downtime_id (int): Downtime identifier
566
567
Returns:
568
dict: Downtime details and status
569
"""
570
571
@staticmethod
572
def update(downtime_id, **kwargs):
573
"""
574
Update existing downtime.
575
576
Parameters:
577
- downtime_id (int): Downtime identifier
578
- scope (list, optional): Updated scope
579
- start (int, optional): Updated start time
580
- end (int, optional): Updated end time
581
- message (str, optional): Updated message
582
583
Returns:
584
dict: Updated downtime details
585
"""
586
587
@staticmethod
588
def delete(downtime_id):
589
"""
590
Cancel scheduled downtime.
591
592
Parameters:
593
- downtime_id (int): Downtime identifier
594
595
Returns:
596
dict: Cancellation confirmation
597
"""
598
```
599
600
### Service Level Objectives
601
602
Define, track, and manage SLOs for measuring service reliability and performance targets.
603
604
```python { .api }
605
class ServiceLevelObjective:
606
@staticmethod
607
def create(**kwargs):
608
"""
609
Create a new SLO.
610
611
Parameters:
612
- name (str): SLO name
613
- type (str): SLO type ('metric' or 'monitor')
614
- query (dict): Query definition for the SLO
615
- thresholds (list): List of threshold configurations
616
- timeframe (str): Time window ('7d', '30d', '90d')
617
- target_threshold (float): Target percentage (0-100)
618
- warning_threshold (float, optional): Warning percentage
619
- description (str, optional): SLO description
620
- tags (list, optional): List of tags
621
622
Returns:
623
dict: Created SLO with ID and configuration
624
"""
625
626
@staticmethod
627
def get_all(**kwargs):
628
"""
629
Get all SLOs.
630
631
Parameters:
632
- ids (str, optional): Comma-separated SLO IDs
633
- query (str, optional): Search query
634
- tags_query (str, optional): Tags filter query
635
- metrics_query (str, optional): Metrics filter query
636
- limit (int, optional): Maximum number of results
637
- offset (int, optional): Offset for pagination
638
639
Returns:
640
dict: List of SLO summaries
641
"""
642
643
@staticmethod
644
def get(slo_id, **kwargs):
645
"""
646
Get SLO by ID.
647
648
Parameters:
649
- slo_id (str): SLO identifier
650
- with_configured_alert_ids (bool, optional): Include alert IDs
651
652
Returns:
653
dict: Complete SLO configuration and status
654
"""
655
656
@staticmethod
657
def update(slo_id, **kwargs):
658
"""
659
Update existing SLO.
660
661
Parameters:
662
- slo_id (str): SLO identifier
663
- name (str, optional): Updated name
664
- query (dict, optional): Updated query
665
- thresholds (list, optional): Updated thresholds
666
- target_threshold (float, optional): Updated target
667
- description (str, optional): Updated description
668
669
Returns:
670
dict: Updated SLO details
671
"""
672
673
@staticmethod
674
def delete(slo_id, **kwargs):
675
"""
676
Delete an SLO.
677
678
Parameters:
679
- slo_id (str): SLO identifier
680
- force (bool, optional): Force deletion if referenced
681
682
Returns:
683
dict: Deletion confirmation
684
"""
685
686
@staticmethod
687
def history(slo_id, **kwargs):
688
"""
689
Get SLO history data.
690
691
Parameters:
692
- slo_id (str): SLO identifier
693
- from_ts (int): Start time as Unix timestamp
694
- to_ts (int): End time as Unix timestamp
695
- target (float, optional): Target threshold for calculations
696
- apply_correction (bool, optional): Apply data corrections
697
698
Returns:
699
dict: Historical SLO performance data
700
"""
701
```
702
703
### User and Role Management
704
705
Manage users, custom roles, and permissions for organization access control and security.
706
707
```python { .api }
708
class User:
709
@staticmethod
710
def create(**kwargs):
711
"""
712
Create a new user.
713
714
Parameters:
715
- email (str): User email address
716
- handle (str): User handle/username
717
- name (str): User full name
718
- access_role (str, optional): User access role
719
- disabled (bool, optional): Account disabled status
720
721
Returns:
722
dict: Created user details
723
"""
724
725
@staticmethod
726
def get_all():
727
"""
728
Get all users.
729
730
Returns:
731
list: List of all users in organization
732
"""
733
734
@staticmethod
735
def get(handle):
736
"""
737
Get user by handle.
738
739
Parameters:
740
- handle (str): User handle/username
741
742
Returns:
743
dict: User details and settings
744
"""
745
746
@staticmethod
747
def update(handle, **kwargs):
748
"""
749
Update user information.
750
751
Parameters:
752
- handle (str): User handle/username
753
- email (str, optional): Updated email
754
- name (str, optional): Updated name
755
- access_role (str, optional): Updated access role
756
- disabled (bool, optional): Updated disabled status
757
758
Returns:
759
dict: Updated user details
760
"""
761
762
@staticmethod
763
def delete(handle):
764
"""
765
Delete a user.
766
767
Parameters:
768
- handle (str): User handle/username
769
770
Returns:
771
dict: Deletion confirmation
772
"""
773
774
class Roles:
775
@staticmethod
776
def create(**kwargs):
777
"""
778
Create a custom role.
779
780
Parameters:
781
- name (str): Role name
782
- permissions (list, optional): List of permission IDs
783
784
Returns:
785
dict: Created role with ID
786
"""
787
788
@staticmethod
789
def get_all():
790
"""
791
Get all roles.
792
793
Returns:
794
list: List of all roles including built-in
795
"""
796
797
@staticmethod
798
def get(role_id):
799
"""
800
Get role by ID.
801
802
Parameters:
803
- role_id (str): Role identifier
804
805
Returns:
806
dict: Role details and permissions
807
"""
808
809
@staticmethod
810
def update(role_id, **kwargs):
811
"""
812
Update role configuration.
813
814
Parameters:
815
- role_id (str): Role identifier
816
- name (str, optional): Updated role name
817
- permissions (list, optional): Updated permission list
818
819
Returns:
820
dict: Updated role details
821
"""
822
823
@staticmethod
824
def delete(role_id):
825
"""
826
Delete a custom role.
827
828
Parameters:
829
- role_id (str): Role identifier
830
831
Returns:
832
dict: Deletion confirmation
833
"""
834
835
class Permissions:
836
@staticmethod
837
def get_all():
838
"""
839
Get all available permissions.
840
841
Returns:
842
list: List of all permission objects with IDs and descriptions
843
"""
844
```
845
846
### Cloud Integrations
847
848
Configure and manage cloud provider integrations for automatic resource discovery and monitoring.
849
850
```python { .api }
851
class AwsIntegration:
852
@staticmethod
853
def create(**kwargs):
854
"""
855
Create AWS integration.
856
857
Parameters:
858
- account_id (str): AWS account ID
859
- role_name (str): IAM role name for Datadog
860
- filter_tags (list, optional): Resource filtering tags
861
- host_tags (list, optional): Tags to apply to hosts
862
- account_specific_namespace_rules (dict, optional): Namespace rules
863
- excluded_regions (list, optional): Regions to exclude
864
- cspm_resource_collection_enabled (bool, optional): Enable CSPM
865
- metrics_collection_enabled (bool, optional): Enable metrics
866
867
Returns:
868
dict: Created integration configuration
869
"""
870
871
@staticmethod
872
def get_all():
873
"""
874
Get all AWS integrations.
875
876
Returns:
877
list: List of AWS integration configurations
878
"""
879
880
@staticmethod
881
def update(account_id, role_name, **kwargs):
882
"""
883
Update AWS integration.
884
885
Parameters:
886
- account_id (str): AWS account ID
887
- role_name (str): IAM role name
888
- filter_tags (list, optional): Updated filtering tags
889
- host_tags (list, optional): Updated host tags
890
891
Returns:
892
dict: Updated integration configuration
893
"""
894
895
@staticmethod
896
def delete(account_id, role_name):
897
"""
898
Delete AWS integration.
899
900
Parameters:
901
- account_id (str): AWS account ID
902
- role_name (str): IAM role name
903
904
Returns:
905
dict: Deletion confirmation
906
"""
907
908
class AzureIntegration:
909
@staticmethod
910
def create(**kwargs):
911
"""
912
Create Azure integration.
913
914
Parameters:
915
- tenant_name (str): Azure tenant name
916
- client_id (str): Azure client ID
917
- client_secret (str): Azure client secret
918
- host_filters (str, optional): Host filtering expression
919
- app_service_plan_filters (str, optional): App Service filters
920
- container_app_filters (str, optional): Container app filters
921
922
Returns:
923
dict: Created Azure integration
924
"""
925
926
@staticmethod
927
def get_all():
928
"""
929
Get all Azure integrations.
930
931
Returns:
932
list: List of Azure integration configurations
933
"""
934
935
class GcpIntegration:
936
@staticmethod
937
def create(**kwargs):
938
"""
939
Create GCP integration.
940
941
Parameters:
942
- project_id (str): GCP project ID
943
- private_key_id (str): Service account private key ID
944
- private_key (str): Service account private key
945
- client_email (str): Service account email
946
- client_id (str): Service account client ID
947
- host_filters (str, optional): Host filtering expression
948
- resource_collection_enabled (bool, optional): Enable resource collection
949
950
Returns:
951
dict: Created GCP integration
952
"""
953
954
@staticmethod
955
def get_all():
956
"""
957
Get all GCP integrations.
958
959
Returns:
960
list: List of GCP integration configurations
961
"""
962
```
963
964
### Synthetic Monitoring
965
966
Create and manage synthetic tests for proactive monitoring of web applications, APIs, and user journeys.
967
968
```python { .api }
969
class Synthetics:
970
@staticmethod
971
def create_test(**kwargs):
972
"""
973
Create a synthetic test.
974
975
Parameters:
976
- type (str): Test type ('api', 'browser', 'mobile')
977
- config (dict): Test configuration with request details
978
- options (dict): Test options and settings
979
- locations (list): List of test locations
980
- message (str): Alert message for test failures
981
- name (str): Test name
982
- tags (list, optional): List of tags
983
- status (str, optional): Test status ('live' or 'paused')
984
985
Returns:
986
dict: Created test with ID and configuration
987
"""
988
989
@staticmethod
990
def get_all_tests(**kwargs):
991
"""
992
Get all synthetic tests.
993
994
Returns:
995
list: List of all synthetic tests
996
"""
997
998
@staticmethod
999
def get_test(public_id):
1000
"""
1001
Get synthetic test by ID.
1002
1003
Parameters:
1004
- public_id (str): Test public identifier
1005
1006
Returns:
1007
dict: Complete test configuration
1008
"""
1009
1010
@staticmethod
1011
def update_test(public_id, **kwargs):
1012
"""
1013
Update synthetic test.
1014
1015
Parameters:
1016
- public_id (str): Test public identifier
1017
- name (str, optional): Updated test name
1018
- config (dict, optional): Updated configuration
1019
- options (dict, optional): Updated options
1020
- locations (list, optional): Updated locations
1021
1022
Returns:
1023
dict: Updated test configuration
1024
"""
1025
1026
@staticmethod
1027
def delete_test(public_id):
1028
"""
1029
Delete synthetic test.
1030
1031
Parameters:
1032
- public_id (str): Test public identifier
1033
1034
Returns:
1035
dict: Deletion confirmation
1036
"""
1037
```
1038
1039
## Usage Examples
1040
1041
### Creating and Managing Monitors
1042
1043
```python
1044
from datadog import initialize, api
1045
1046
# Initialize the client
1047
initialize(api_key="your-api-key", app_key="your-app-key")
1048
1049
# Create a metric monitor
1050
monitor = api.Monitor.create(
1051
type="metric alert",
1052
query="avg(last_5m):avg:system.cpu.user{*} > 80",
1053
name="High CPU usage",
1054
message="CPU usage is above 80% @webhook-http://example.com/hook",
1055
tags=["environment:production", "team:infrastructure"],
1056
options={
1057
"thresholds": {"critical": 80, "warning": 70},
1058
"new_host_delay": 300,
1059
"evaluation_delay": 900,
1060
"no_data_timeframe": 10,
1061
"renotify_interval": 60
1062
}
1063
)
1064
1065
# Get monitor details
1066
monitor_details = api.Monitor.get(monitor['id'])
1067
1068
# Update monitor
1069
api.Monitor.update(
1070
monitor['id'],
1071
message="Updated alert message with new webhook @webhook-slack-alerts"
1072
)
1073
1074
# Mute monitor temporarily
1075
api.Monitor.mute(monitor['id'], end=int(time.time()) + 3600) # 1 hour
1076
1077
# Clean up - delete monitor
1078
api.Monitor.delete(monitor['id'])
1079
```
1080
1081
### Dashboard Creation with Widgets
1082
1083
```python
1084
# Create a dashboard with multiple widgets
1085
dashboard = api.Dashboard.create(
1086
title="Application Performance Dashboard",
1087
layout_type="ordered",
1088
widgets=[
1089
{
1090
"definition": {
1091
"type": "timeseries",
1092
"requests": [
1093
{
1094
"q": "avg:system.cpu.user{environment:production}",
1095
"display_type": "line",
1096
"style": {"palette": "dog_classic", "line_type": "solid", "line_width": "normal"}
1097
}
1098
],
1099
"title": "CPU Usage Over Time",
1100
"yaxis": {"min": "0", "max": "100"}
1101
}
1102
},
1103
{
1104
"definition": {
1105
"type": "query_value",
1106
"requests": [
1107
{
1108
"q": "avg:system.load.1{environment:production}",
1109
"aggregator": "avg"
1110
}
1111
],
1112
"title": "Current Load Average",
1113
"precision": 2
1114
}
1115
}
1116
],
1117
description="Real-time monitoring for production application performance",
1118
template_variables=[
1119
{
1120
"name": "environment",
1121
"default": "production",
1122
"prefix": "environment"
1123
}
1124
]
1125
)
1126
1127
print(f"Dashboard created: {dashboard['url']}")
1128
```