Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(infra): preserve imported Datadog monitor settings (#7162)

Wolf Mermelstein5c475099901e
diff --git a/infra/stacks/monitoring/README.md b/infra/stacks/monitoring/README.md
index 852793d3a6..1834f155d0 100644
--- a/infra/stacks/monitoring/README.md
+++ b/infra/stacks/monitoring/README.md
@@ -24,6 +24,7 @@ cd infra/stacks/monitoring
export DD_API_KEY=... DD_APP_KEY=... DD_HOST=https://api.us5.datadoghq.com/
pulumi stack select macro-inc/prod --create
pulumi import --file import.json --out imported.generated.ts --protect --yes
+pulumi refresh --yes
pulumi preview --diff
```
@@ -33,6 +34,9 @@ ground truth to reconcile against if the preview shows drift. Delete it after;
it must not be committed (index.ts does not import it, and a second copy of
every monitor would double-declare them).
+The refresh reads the live resources back into state without changing Datadog
+and records options omitted during import.
+
The gate is that preview:
- **35 monitors + 1 synthetic test unchanged** — adoption is exact.
@@ -81,6 +85,18 @@ provider models differently from the API are the risk, and these are the spots:
*text*, not alert behavior.
- `onMissingData` values are the API's snake_case (`show_no_data`). Pulumi's
generated docs camelCase them; the provider forwards the string as-is.
+- All adopted monitors have `requireFullWindow: false`; `adopted()` preserves
+ that setting instead of the provider's default of `true`.
+- Datadog omits `newHostDelay` on monitors using `newGroupDelay`, but provider
+ 4.68 defaults it to 300. Imported nulls can cause perpetual updates. After
+ backing up state and verifying that each affected monitor is not grouped by
+ `host`, normalize only its input/output `newHostDelay` to 300 in Pulumi state.
+ The helper declares that same default. Host delay is ignored for these
+ monitors; group delay stays unchanged. Verify again with `preview --refresh`
+ and compare the live Datadog definitions before deploying.
+- The existing APM latency monitor is a draft. Keep its `draftStatus` explicit
+ so adoption does not publish it. RUM monitors omit the log-only
+ `enableLogsSample` and `groupbySimpleMonitor` options.
## Drift
diff --git a/infra/stacks/monitoring/adopted.ts b/infra/stacks/monitoring/adopted.ts
index 5841e6a734..58eaaf9902 100644
--- a/infra/stacks/monitoring/adopted.ts
+++ b/infra/stacks/monitoring/adopted.ts
@@ -13,5 +13,13 @@ export function adopted(
name: string,
args: datadog.MonitorArgs
): datadog.Monitor {
- return new datadog.Monitor(name, args, { protect: true });
+ // All imported monitors allow partial evaluation windows. The provider
+ // defaults to true when omitted, which would change their alert behavior.
+ // Datadog omits host delay when group delay applies. Keep the provider's
+ // default explicit after normalizing imported state; group delay wins.
+ return new datadog.Monitor(
+ name,
+ { requireFullWindow: false, newHostDelay: 300, ...args },
+ { protect: true }
+ );
}
diff --git a/infra/stacks/monitoring/monitors/apm.ts b/infra/stacks/monitoring/monitors/apm.ts
index 78577ffcb6..6bc600024f 100644
--- a/infra/stacks/monitoring/monitors/apm.ts
+++ b/infra/stacks/monitoring/monitors/apm.ts
@@ -6,6 +6,7 @@ import { adopted } from '../adopted';
// https://us5.datadoghq.com/monitors/19271629
adopted('apm-get-channel-messages-p95', {
+ draftStatus: 'draft',
name: 'High p95 Latency – get_channel_messages (cloud-storage-service prod)',
type: 'query alert',
query:
diff --git a/infra/stacks/monitoring/monitors/rum.ts b/infra/stacks/monitoring/monitors/rum.ts
index 8c8caae944..4ed2f44b76 100644
--- a/infra/stacks/monitoring/monitors/rum.ts
+++ b/infra/stacks/monitoring/monitors/rum.ts
@@ -19,8 +19,6 @@ adopted('web-app-errors-staging', {
notifyAudit: false,
includeTags: false,
newHostDelay: 300,
- enableLogsSample: false,
- groupbySimpleMonitor: false,
});
// https://us5.datadoghq.com/monitors/1189349
@@ -45,8 +43,6 @@ adopted('web-app-source-errors-prod', {
renotifyInterval: 60,
renotifyStatuses: ['alert'],
notificationPresetName: 'hide_all',
- enableLogsSample: false,
- groupbySimpleMonitor: false,
variables: {
eventQueries: [
{