一键导入
dd-add-monitor
Generate Terraform for Datadog monitors tailored to a project's services and active features, using real telemetry baselines when available.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate Terraform for Datadog monitors tailored to a project's services and active features, using real telemetry baselines when available.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create a Datadog demo project — scaffold infrastructure, build domain-specific microservices, and generate demo scenarios. Use when the user asks to create a demo, scaffold a project, set up a Datadog environment, or build a sample application.
Verify Datadog telemetry is flowing correctly using MCP tools
Build, deploy, smoke test, and validate a demo project before presenting it. Use after scaffolding or modifying services to ensure everything works end-to-end.
Look up current Datadog documentation via the official LLM-optimized index at docs.datadoghq.com/llms.txt. Use this skill whenever you need accurate, up-to-date Datadog configuration steps, feature details, API references, integration setup, or troubleshooting guidance — even if you think you already know the answer. Datadog docs change frequently and your training data is likely stale. Trigger on any Datadog-related question: agent install, log pipelines, APM setup, DBM, monitors, dashboards, SLOs, integrations, RBAC, cloud cost, synthetics, LLM observability, etc. Also trigger when another dd- prefixed skill needs to reference official documentation.
Generate Terraform for Datadog dashboards tailored to a project's services and active features, enriched with real telemetry data from the Datadog MCP server.
Configure the Locust traffic generator with domain-specific scenarios that exercise all services, demo golden paths, and trigger failure modes for Datadog visibility.
| name | dd-add-monitor |
| description | Generate Terraform for Datadog monitors tailored to a project's services and active features, using real telemetry baselines when available. |
| tools | ["terminal","file_read","file_write","ask_user"] |
Generate terraform/monitors.tf with datadog_monitor resources for every service in the project. Monitors are scoped to var.dd_env, thresholds use real telemetry baselines when Datadog MCP is available, and demo-friendly defaults otherwise. Exports monitor IDs as Terraform outputs for use by dd-add-slo.
dd-check-telemetry confirms data is reaching DatadogAGENTS.md, docker-compose.yml, and .envterraform version)Check whether terraform/provider.tf exists.
If it does not exist, create the following files:
terraform/provider.tf:
terraform {
required_providers {
datadog = {
source = "DataDog/datadog"
}
}
}
provider "datadog" {
api_key = var.dd_api_key
app_key = var.dd_app_key
api_url = var.dd_api_url
}
terraform/variables.tf:
variable "dd_api_key" {
description = "Datadog API key"
type = string
sensitive = true
}
variable "dd_app_key" {
description = "Datadog Application key"
type = string
sensitive = true
}
variable "dd_api_url" {
description = "Datadog API URL (e.g., https://api.datadoghq.com/ for US1, https://api.us5.datadoghq.com/ for US5)"
type = string
default = "https://api.datadoghq.com/"
}
variable "dd_env" {
description = "DD_ENV tag value for scoping queries"
type = string
}
variable "services" {
description = "List of application service names"
type = list(string)
}
terraform/terraform.tfvars.example:
# Copy to terraform.tfvars and populate from your .env file
dd_api_key = "" # DD_API_KEY from .env
dd_app_key = "" # DD_APP_KEY from .env
dd_api_url = "https://api.datadoghq.com/" # adjust for your Datadog site
dd_env = "" # DD_ENV from .env
services = [] # list of service names from docker-compose.yml
terraform/outputs.tf:
# Monitor IDs — populated by dd-add-monitor, consumed by dd-add-slo
If terraform/provider.tf already exists, skip creation and proceed. This step is idempotent.
Read the following files:
AGENTS.md → service names, active Datadog features (APM, DBM, RUM, apm:profiling, security:code, security:siem), whether a frontend existsdocker-compose.yml → canonical list of application service names (exclude datadog-agent, traffic, postgresql, redis, keycloak).env → DD_ENV value (used to scope all queries and Terraform variables)Build a working model:
dbm:postgresql, security:code, apm:profiling, security:siem, rum are enabledAttempt to query the Datadog MCP for each service, scoped to env:<dd_env>:
trace.http.request.errors / trace.http.request.hits over the last hourtrace.http.request.duration.by.service.95p over the last hourtrace.http.request.hits over the last hourstatus:error logs in the last hourUse these baselines to inform thresholds:
If Datadog MCP is unavailable or returns no data, log "Datadog MCP unavailable — using demo-friendly defaults" and proceed. Do not stop.
Demo-friendly defaults (used when real telemetry is absent):
> 0.05)> 2)Obtain the datadog_monitor resource schema to ensure generated HCL uses correct argument names:
get_provider_details for the DataDog/datadog provider, requesting details for datadog_monitordd-lookup-docs (llms.txt path: https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor)monitors.tf:
# WARNING: provider schema fetched from training data — verify argument names against
# https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor
Based on the discovered services and active features, compose the monitor plan using the following mapping:
| Condition | Monitor name | Type | Query pattern | Threshold (default) |
|---|---|---|---|---|
| Always — per service | [service] High Error Rate | metric alert | sum(last_5m):sum:trace.http.request.errors{env:<dd_env>,service:<svc>}.as_rate() / sum:trace.http.request.hits{env:<dd_env>,service:<svc>}.as_rate() > 0.05 | 0.05 |
| Always — per service | [service] High Latency p95 | metric alert | avg(last_5m):avg:trace.http.request.duration.by.service.95p{env:<dd_env>,service:<svc>} > 2 | 2 |
| Always — global | [env] Error Log Spike | log alert | logs("env:<dd_env> status:error").index("*").rollup("count").last("5m") > 50 | 50 |
dbm:postgresql active | [env] Slow Query | metric alert | avg(last_5m):avg:postgresql.queries.duration{env:<dd_env>} > 1000 | 1000 ms |
dbm:postgresql active | [env] Connection Pool Near Limit | metric alert | avg(last_5m):avg:postgresql.connections{env:<dd_env>} > 80 | 80 |
security:code active | [env] Security Threat Signal | event-v2 alert | ASM threat signal on env:<dd_env> | any |
apm:profiling active | [env] CPU Anomaly | metric alert | avg(last_15m):anomalies(avg:runtime.cpu.utilization{env:<dd_env>}, "basic", 2) >= 1 | anomaly |
security:siem active | [env] Failed Auth Spike | log alert | logs("env:<dd_env> @source:keycloak @outcome:failure").index("*").rollup("count").last("5m") > 20 | 20 |
security:app active | [env] Security Threat Signal | event-v2 alert | ASM threat signal on env:<dd_env> | any |
ai:llmobs active | [env] LLM Error Rate | metric alert | LLM error rate on env:<dd_env> | 5% |
dsm:kafka active | [env] Consumer Lag | metric alert | Kafka consumer lag on env:<dd_env> | 1000 |
| Frontend (RUM) active | [env] Frontend Error Rate | rum alert | rum("env:<dd_env> @type:error").rollup("count").last("5m") > 10 | 10 |
Replace <dd_env> and <svc> with actual values. When real telemetry baselines are available from Step 3, substitute the computed thresholds.
Present the full monitor list to the user with:
Stop here. Use ask_user to present the monitor proposal and wait for explicit user confirmation. Do not write any files until they reply.
terraform/monitors.tfWrite terraform/monitors.tf with one datadog_monitor resource per proposed monitor.
Rules:
for_each over var.services for per-service monitors (error rate, latency) to avoid duplicationvar.dd_env using Terraform string interpolation: env:${var.dd_env}message to include the service/monitor name and escalation hint using Terraform template syntaxmanaged_by:terraform and env:${var.dd_env}require_full_window = false for demo monitors (data may be sparse)notify_no_data = false unless the monitor is a heartbeat-style checkExample skeleton for a per-service metric alert:
resource "datadog_monitor" "high_error_rate" {
for_each = toset(var.services)
name = "[${each.key}] High Error Rate"
type = "metric alert"
message = "High error rate on ${each.key} in env:${var.dd_env}. Investigate recent deployments or upstream dependencies."
query = "sum(last_5m):sum:trace.http.request.errors{env:${var.dd_env},service:${each.key}}.as_rate() / sum:trace.http.request.hits{env:${var.dd_env},service:${each.key}}.as_rate() > ${var.error_rate_threshold}"
monitor_thresholds {
critical = var.error_rate_threshold
}
require_full_window = false
notify_no_data = false
tags = [
"managed_by:terraform",
"env:${var.dd_env}",
"service:${each.key}",
]
}
Add corresponding output blocks to terraform/outputs.tf for every monitor resource, exporting IDs for use by dd-add-slo:
output "monitor_ids_high_error_rate" {
description = "Monitor IDs for high error rate alerts, keyed by service"
value = { for k, v in datadog_monitor.high_error_rate : k => v.id }
}
Run Terraform formatting and validation:
cd terraform && terraform fmt monitors.tf
cd terraform && terraform init -backend=false
cd terraform && terraform validate
If terraform fmt produces changes, those are cosmetic — apply them silently.
If terraform validate reports errors:
monitors.tfterraform validate until it passesIf terraform is not installed, note it in the report and skip this step.
Tell the user:
terraform/ files were created or already existedterraform validate passed / skipped (terraform not installed)terraform/terraform.tfvars from the example file and .envterraform plan to preview changesterraform apply to create monitors in Datadogdd-add-slo to create SLOs backed by these monitorsterraform/provider.tf or terraform/variables.tf if they existask_user to present the full monitor proposal and wait for explicit user approval before generating terraform/monitors.tfenv:${var.dd_env}; never hardcode environment namesmanaged_by:terraformterraform/outputs.tf so dd-add-slo can reference themmonitors.tfAGENTS.md before adding DBM, security, apm:profiling, security:siem, or RUM monitors