Cloud & Backend Engineer: Datadog-as-Code & OpenTelemetry — Automating SLO Monitors and Dashboards for Go Microservices
Creating monitoring dashboards and alert thresholds manually via click-ops in the Datadog, Grafana, or Google Cloud Monitoring UI leads to unreviewed threshold changes, missing alerts on newly launched microservices, and alert fatigue from noisy CPU-percentage pages. As a Cloud Engineer and Backend Engineer, I implement Observability-as-Code using the Terraform Datadog/Grafana providers paired with vendor-neutral OpenTelemetry (OTel) metrics and multi-window error-budget burn-rate alerts.
1. Multi-Window Error-Budget Burn-Rate Monitors in Terraform
Instead of paging on-call engineers for a 30-second latency blip that resolves itself, we codify Google SRE multi-window burn-rate alerts in Terraform: paging only when both the 1-hour and 5-minute error-budget burn rates exceed threshold (indicating an active, sustained production incident):
resource "datadog_monitor" "checkout_service_slo_burn_rate" {
name = "[PROD] Checkout gRPC Service - High Error Budget Burn Rate (99.9% SLO)"
type = "metric alert"
message = <<-EOT
Checkout gRPC error rate is burning through the 30-day 99.9% SLO budget.
Runbook: https://internal.docs/runbooks/checkout-grpc-burn
@pagerduty-backend-oncall
EOT
query = <<-EOQ
avg(last_1h): (
sum:trace.grpc.server.errors{env:prod,service:checkout-grpc}.as_count() /
sum:trace.grpc.server.hits{env:prod,service:checkout-grpc}.as_count()
) > (14.4 * 0.001)
EOQ
monitor_thresholds {
critical = 0.0144
warning = 0.0072
}
notify_no_data = true
no_data_timeframe = 10
tags = ["env:prod", "service:checkout-grpc", "managed_by:terraform"]
}
2. Unified OpenTelemetry Trace-to-Log Correlation in Go
Every Go microservice injects `dd.trace_id` / `otel.trace_id` and `otel.span_id` into structured JSON logs (`slog`), allowing on-call engineers to jump directly from a Terraform-provisioned p99 latency graph to the exact distributed trace and PostgreSQL query span—aligning with our Cloud Engineer Terraform IaC workflows and Go & PostgreSQL production observability.
Need a Cloud Engineer or Backend Engineer to codify your Datadog, Grafana, or OpenTelemetry observability stack in Terraform? Book a 1-Day Engineering Sprint.