RousselTMLEARNING

Article · Datadog: from discovery to expertise

Monitors, SLOs and Terraform

1. Monitors #

Alerting in Datadog.

Types #

TypeExample
Metricavg(last_5m):avg:system.cpu.user{env:prod} by {host} > 85
LogMore than 50 service:checkout status:error logs in 5 min
APMError rate or p95 latency of a service
Anomaly, Forecast, OutlierDeviation from usual behavior, predicted full disk
CompositeLogical combination of monitors
SLOBurn rate of an SLO
{{#is_alert}}
CPU à {{value}} % sur {{host.name}} ({{env.name}}).
Runbook : https://wiki.example.org/cpu
@slack-alertes-plateforme @pagerduty-plateforme
{{/is_alert}}
{{#is_recovery}}Retour à la normale sur {{host.name}}.{{/is_recovery}}
Good practice: Template variables ({{host.name}}) and conditional blocks allow a single « multi-alert » monitor per service instead of one per host.

2. SLOs and dashboards #

Steering.

SLOs #

A Datadog SLO is defined from monitors (uptime) or metrics (good / total ratio), with a target and a window (7, 30 or 90 days). Burn rate monitors are attached to it (see the SRE course for the concepts).

Dashboards and notebooks #

  • Dashboards with template variables ($env, $service) for a single dashboard per type of service.
  • Notebooks for investigations and post-mortems: graphs and text in the same place.
  • Powerpacks to reuse groups of widgets.

3. Datadog as code #

Terraform.

Example #

terraform {
  required_providers { datadog = { source = "DataDog/datadog" } }
}
provider "datadog" {
  api_url = "https://api.datadoghq.eu/"      # clés : variables DD_API_KEY et DD_APP_KEY
}

resource "datadog_monitor" "cpu" {
  name    = "CPU élevé sur {{host.name}}"
  type    = "metric alert"
  query   = "avg(last_5m):avg:system.cpu.user{env:prod} by {host} > 85"
  message = "{{#is_alert}}CPU à {{value}} % sur {{host.name}}{{/is_alert}} @slack-alertes-plateforme"
  monitor_thresholds {
    critical = 85
    warning  = 75
  }
  tags = ["env:prod", "team:plateforme", "managed-by:terraform"]
}
terraform init && terraform plan && terraform apply
Good to know: Existing monitors and dashboards can be exported as JSON from the interface; tools such as terraformer generate the corresponding Terraform code to take over what already exists.

📄 Monitors, SLOs, dashboards and Datadog as code →

My progress

  • ⏱ Estimated time : ≈ 6 min

Sign in to track your progress and take notes. Sign in

💬 Recent discussions about this course

Ask a question about this lesson →See all discussions about this course

Recommended Articles

Datadog best practices: tags, costs, alerts and governance

Checklist for using Datadog effectively: unified tagging, cost control (hosts, logs, custom metri...

Incidents and automation with Datadog: On-Call, Incident Management and Workflow Automation

Manage incidents in Datadog: well-designed monitors, on-call with On-Call, declaring and tracking...

Datadog dashboards and notebooks: widgets, template variables and best practices

Design useful Datadog dashboards: widget types, template variables, groups, Powerpacks, formulas,...

Datadog costs and governance: usage, attribution, RBAC and tag policies

Control the bill and govern Datadog: tracking usage and estimates, cost attribution per team, usa...

Generating Prometheus SLOs with Sloth

Describe an SLO in a few lines with Sloth and automatically generate multi-window recording rules...

SLOs in Dynatrace: objectives, error budget and burn rate

SLI, SLO and SLA, error budget and burn rate: defining an availability or performance SLO in Dyna...

OpenSearch Dashboards, alerting and observability

Explore data in OpenSearch Dashboards, create alert monitors and discover Trace Analytics, Event ...

Chaos engineering: principles, tools and practice with SLOs

A complete guide to chaos engineering: principles, steady state and hypothesis, blast radius, lin...

Managing SLOs with Pyrra

Pyrra: define availability and latency SLOs as Kubernetes CRDs or files, generate Prometheus rule...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!