1 | import ApiClient from "https://deno.land/x/datadog_api/client.ts"; |
2 | import V1MonitorsApi from "https://deno.land/x/datadog_api/v1/monitors.ts"; |
3 |
|
4 | type Datadog = { |
5 | apiKey: string; |
6 | appKey: string; |
7 | apiBase: string; |
8 | }; |
9 | export async function main(dd_auth: Datadog) { |
10 | let count = 0; |
11 | |
12 | const datadog = new ApiClient(dd_auth); |
13 | const monitorsApi = new V1MonitorsApi(datadog); |
14 |
|
15 | let monitor_urls = []; |
16 | |
17 | for await (const monitor of monitorsApi.searchToEnd(`metric:trace*`)) { |
18 | |
19 | if (!monitor.query.includes("env:production")) continue; |
20 | if (!monitor.query.includes("env:sandbox")) continue; |
21 |
|
22 | |
23 | monitor_urls.push(`https://app.datadoghq.eu/monitors/${monitor.id}`); |
24 | count++; |
25 | } |
26 |
|
27 | |
28 | return { count: count, monitor_urls: monitor_urls }; |
29 | } |
30 |
|