Storage is blocked in this browser, so progress will not be saved. Everything else still works.
Module 5 · Dec 28 to Jan 1
Alerts as code
Dynatrace SLOs and alerts in Terraform, with locked remote state and reviewed pull requests.
0 of 5 bursts done
Concept in plain words
Put each Dynatrace SLO and alert in Terraform, keep state in a locked remote backend, and change alerts only through a reviewed pull request. That gives you history, review and rollback for free. Each SLO or alert is one resource block: dynatrace_slo_v2 for SLOs, dynatrace_metric_events for alerts. terraform plan shows the change; terraform apply makes it. Export first: the provider can export existing Dynatrace config to code, so you start from what is live, not a blank page. A metric event looks at one-minute samples, opens a problem when enough samples in the window break the threshold, and closes when enough return to normal. Terraform remembers what it created in a state file, and locking stops two people applying at once.
Payments analogy: Alerts as code is dual control for monitoring: like a wire over a set amount needing a second approver, every alert change needs a reviewer, and the approval is logged with a timestamp.
Banking scenario
What the source says
During the deployment of the new code, one of Knight's technicians did not copy the new code to one of the eight SMARS computer servers.
Knight did not have a second technician review this deployment and no one at Knight realized that the Power Peg code had not been removed from the eighth server, nor the new RLP code added. Knight had no written procedures that required such a review.
On August 1, Knight did not have supervisory procedures concerning incident response.
Source: SEC order, Release No. 70694 (Oct 16, 2013) needs internet
Illustrative scenario
Someone silences the "wire submission failures" alert in the monitoring UI during a noisy maintenance night and forgets to turn it back on. Three weeks later, wire submissions fail for 90 minutes and nobody is paged. The audit asks who changed the alert and when; the UI history has rolled off.
What an SRE would have seen first: During the incident, nothing, because the alert was off. Afterwards, a gap: no record of who changed it or why.
The control that would have caught it: The alert defined as a dynatrace_metric_events resource in Terraform, changed only by reviewed pull request with the plan attached, and a rule that manual UI edits get reverted.
Made-up payments translation for study. Not a real event at any company.
Thresholds
| Setting | Starting value | Source |
|---|---|---|
| Metric event window | 5 one-minute samples, 3 violating to open, 5 normal to close The provider's example, not a default. | dynatrace_metric_events docs needs internet |
| Alert on missing data | Off for sparse series, to avoid false alerts | dynatrace_metric_events docs needs internet |
| SLO burn-rate alert | Static threshold of 10 to 14 on a -1h look-back | Dynatrace SLO docs needs internet |
| SLO target and warning | Warning set slightly above target, for example target 99.9, warning 99.95 | estimate |
| API token scopes | Read and write settings for alerts; plus read and write SLO for SLOs. Nothing more. | dynatrace_slo_v2 docs needs internet |
| State locking | S3 backend with use_lockfile = true (default is false) | Terraform S3 backend needs internet |
| State bucket | Versioning on | Terraform S3 backend needs internet |
| Reviewers per alert change | 1 besides the author | estimate |
| Rollback target | Restore the last good alert version in under 10 minutes | estimate |
Rows marked estimate have no published source. Test them against your own traffic.
Quiz
Try it
Desktop Installing Terraform on your desktop is your call; use HashiCorp's own install steps. One file, one resource. No modules, no CI pipeline, no wrapper scripts this week.
- Write one .tf file with one Dynatrace resource: a burn-rate alert or an SLO from Module 2.
- Run terraform fmt and terraform validate.
- Run terraform plan only against a personal trial or sandbox tenant, never a work tenant. Do not apply unless you are sure what it changes.
- Write 5 lines on what the plan says it will create.
You keep: The .tf file plus your 5-line plan summary.
Verify notes
- Payments angle: code review gives every alert change an approver and a timestamp, which is the kind of change evidence SOX-style reviews ask about. Verify with your compliance team whether monitoring config is in scope for change control where you work.
- The Terraform Registry page for the Dynatrace provider needs a browser with JavaScript, so the resource docs are cited from the provider's public GitHub repository instead.
- Your guide notes there is no famous public outage caused by an edited monitoring alert. Knight Capital is the closest public lesson on unreviewed change; the alert scenario is illustrative.
Read these
- Dynatrace Configuration as Code overview needs internet
- dynatrace_slo_v2 resource needs internet
- dynatrace_metric_events resource needs internet
- Terraform remote state needs internet
- Terraform S3 backend needs internet
From your Sourced Reading Guide. Reading times in that guide are estimates.
Companion book estimate
Becoming a Rockstar SRE needs internet, Jeremy Proffitt and Rod Anami (Packt Publishing, April 28, 2023)
- Ch. 6: Operational Framework - Managing Infrastructure and Systems. Managing infrastructure and systems; the book's code repo lists Terraform among its tools.
Dynatrace translation: Your Terraform targets the Dynatrace provider: dynatrace_slo_v2 for SLOs and dynatrace_metric_events for alerts.
Mapped from chapter titles and the publisher's feature list only; I have not read the book, so treat each link as an estimate. Chapters 8 to 17 were not listed on the pages I opened. The book is from April 2023, so it predates the 2025 incidents and API docs used here; its code repo's software list names Prometheus and Grafana and does not name Dynatrace.