-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example using the Monitors API
- Loading branch information
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env -S deno run --allow-env --allow-net | ||
|
||
import DatadogApi from "../mod.ts"; | ||
const datadogApi = DatadogApi.fromEnvironment(Deno.env); | ||
|
||
// This example looks at all monitors using any APM trace metrics, | ||
// and prints links to those which are not scoped to an APM environment. | ||
|
||
let count = 0; | ||
// Search for relevant monitors via a metric filter | ||
for await (const monitor of datadogApi.v1Monitors.searchToEnd("metric:trace*")) { | ||
|
||
// Skip monitors that have a scoped environment set | ||
if (!monitor.query.includes('env:production')) continue; | ||
if (!monitor.query.includes('env:sandbox')) continue; | ||
|
||
// Print the monitor URL for further manual inspection | ||
console.log(`https://app.datadoghq.eu/monitors/${monitor.id}`); | ||
count++; | ||
} | ||
// Print number of matched monitors as a summary | ||
console.log({count}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters