File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env -S deno run --allow-env --allow-net
2+
3+ import DatadogApi from "../mod.ts" ;
4+ const datadogApi = DatadogApi . fromEnvironment ( Deno . env ) ;
5+
6+ // This example looks at all monitors using any APM trace metrics,
7+ // and prints links to those which are not scoped to an APM environment.
8+
9+ let count = 0 ;
10+ // Search for relevant monitors via a metric filter
11+ for await ( const monitor of datadogApi . v1Monitors . searchToEnd ( "metric:trace*" ) ) {
12+
13+ // Skip monitors that have a scoped environment set
14+ if ( ! monitor . query . includes ( 'env:production' ) ) continue ;
15+ if ( ! monitor . query . includes ( 'env:sandbox' ) ) continue ;
16+
17+ // Print the monitor URL for further manual inspection
18+ console . log ( `https://app.datadoghq.eu/monitors/${ monitor . id } ` ) ;
19+ count ++ ;
20+ }
21+ // Print number of matched monitors as a summary
22+ console . log ( { count} )
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ interface ApiClient {
88 } ) : Promise < unknown > ;
99}
1010
11+ /**
12+ * Monitors allow you to watch a metric or check that you care about,
13+ * notifying your team when some defined threshold is exceeded.
14+ *
15+ * Official API docs: https://docs.datadoghq.com/api/latest/monitors/
16+ */
1117export default class DatadogMonitorsApi {
1218 #api: ApiClient ;
1319 constructor ( api : ApiClient ) {
You can’t perform that action at this time.
0 commit comments