dd-monitors
作者: datadog-labs
監控管理 - 建立、更新、靜音及警示最佳實踐。
npx skills add https://github.com/datadog-labs/pup --skill dd-monitorsDatadog Monitors
Create, manage, and maintain monitors for alerting.
Prerequisites
This requires the pup binary in your path.
pup - cargo install --git https://github.com/DataDog/pup
Quick Start
pup auth login
Common Operations
List Monitors
pup monitors list
pup monitors list --tags "team:platform"
pup monitors search --query "status:Alert"
Get Monitor
pup monitors get <id>
Create Monitor
pup monitors create --file monitor.json
Mute/Unmute
# Mute with duration
pup monitors update 12345 --file monitor-muted.json
# Or mute with specific end time
pup monitors update 12345 --file monitor-muted-until.json
# Unmute
pup monitors update 12345 --file monitor-unmuted.json
⚠️ Monitor Creation Best Practices
1. Avoid Alert Fatigue
| Rule | Why |
|---|---|
| No flapping alerts | Use last_Xm not last_1m |
| Meaningful thresholds | Based on SLOs, not guesses |
| Actionable alerts | If no action needed, don't alert |
| Include runbook | @runbook-url in message |
# WRONG - will flap constantly
query = "avg(last_1m):avg:system.cpu.user{*} > 50" # ❌ Too sensitive
# CORRECT - stable alerting
query = "avg(last_5m):avg:system.cpu.user{env:prod} by {host} > 80" # ✅ Reasonable window
2. Use Proper Scoping
# WRONG - alerts on everything
query = "avg(last_5m):avg:system.cpu.user{*} > 80" # ❌ No scope
# CORRECT - scoped to what matters
query = "avg(last_5m):avg:system.cpu.user{env:prod,service:api} by {host} > 80" # ✅
3. Set Recovery Thresholds
monitor = {
"query": "avg(last_5m):avg:system.cpu.user{env:prod} > 80",
"options": {
"thresholds": {
"critical": 80,
"critical_recovery": 70, # ✅ Prevents flapping
"warning": 60,
"warning_recovery": 50
}
}
}
4. Include Context in Messages
message = """
## High CPU Alert
Host: {{host.name}}
Current Value: {{value}}
Threshold: {{threshold}}
### Runbook
1. Check top processes: `ssh {{host.name}} 'top -bn1 | head -20'`
2. Check recent deploys
3. Scale if needed
@slack-ops @pagerduty-oncall
"""
⚠️ NEVER Delete Monitors Directly
Use safe deletion workflow (same as dashboards):
def safe_mark_monitor_for_deletion(monitor_id: str, client) -> bool:
"""Mark monitor instead of deleting."""
monitor = client.get_monitor(monitor_id)
name = monitor.get("name", "")
if "[MARKED FOR DELETION]" in name:
print(f"Already marked: {name}")
return False
new_name = f"[MARKED FOR DELETION] {name}"
client.update_monitor(monitor_id, {"name": new_name})
print(f"✓ Marked: {new_name}")
return True
Monitor Types
| Type | Use Case |
|---|---|
metric alert | CPU, memory, custom metrics |
query alert | Complex metric queries |
service check | Agent check status |
event alert | Event stream patterns |
log alert | Log pattern matching |
composite | Combine multiple monitors |
apm | APM metrics |
Audit Monitors
# Find monitors without owners
pup monitors list | jq '.[] | select(.tags | contains(["team:"]) | not) | {id, name}'
# Find noisy monitors (high alert count)
pup monitors list | jq 'sort_by(.overall_state_modified) | .[:10] | .[] | {id, name, status: .overall_state}'
Downtime vs Muting
| Use | When |
|---|---|
| Mute monitor | Quick one-off, < 1 hour |
| Downtime | Scheduled maintenance, recurring |
# Downtime (preferred)
pup downtime create --file downtime.json
Failure Handling
| Problem | Fix |
|---|---|
| Alert not firing | Check query returns data, thresholds |
| Too many alerts | Increase window, add recovery threshold |
| No data alerts | Check agent connectivity, metric exists |
| Auth error | pup auth refresh |
References
來自 datadog-labs 的更多技能
agent-install
datadog-labs
agent-install — 一個可安裝的 AI 代理技能,由 datadog-labs/agent-skills 發布。
official
agent-skills
datadog-labs
專為AI代理設計的Datadog技能。提供必要的監控、日誌記錄、追蹤與可觀測性功能。
official
dd-apm
datadog-labs
APM - 安裝、入門、儀器化、啟用、設定、配置、追蹤、服務、相依性、效能分析。用於任何涉及 Datadog APM 的請求…
official
dd-audit
datadog-labs
稽核軌跡調查——誰變更了什麼、金鑰遭入侵、成本飆升的根本原因、合規證據(SOC 2/PCI),以及AI活動稽核。
official
dd-audit-ai-activity
datadog-labs
稽核 Bits AI 助手(MCP 伺服器)在您的 Datadog 組織中所執行的操作 — 按使用者分類的工具呼叫、存取的資源,以及用於 AI 治理的異常標記。
official
dd-audit-compliance-report
datadog-labs
從 Datadog Audit Trail 生成符合 SOC 2 和 PCI DSS 的稽核證據,將框架控制項對應至特定查詢模式,並產出…
official
dd-audit-cost-spike-investigation
datadog-labs
調查 Datadog 產品用量或成本異常飆升,透過關聯用量計量資料(何時/何項目飆升)與稽核軌跡設定變更(誰變更了哪些設定…)
official
dd-audit-key-compromise
datadog-labs
調查可能遭入侵的 Datadog API 金鑰 — 動作時間軸、地理位置/IP 分析、呼叫的端點、異常標記及補救步驟。
official