mcpField
D
dd-monitors

dd-monitors

github.com/datadog-labsクラウド・DevOps1801.9k 回インストール6 日前に更新
リポジトリ

dd-monitors について

dd-monitorsは、PupコマンドラインでDatadogモニターを作成、確認、管理するスキルです。アラート範囲、しきい値、復旧条件、ダウンタイム、モニター監査の運用指針も含みます。

主な機能

  1. 01モニターの一覧表示と取得
  2. 02JSONファイルからのモニター作成
  3. 03ダウンタイムによるアラート通知の停止
  4. 04担当チームとアラート状況の監査
  5. 05クエリ範囲と復旧しきい値の設定

活用シーン

  1. 01メトリクスやサービスチェックのアラート作成
  2. 02計画メンテナンス中の通知停止
  3. 03チーム担当が未設定のモニターの監査
  4. 04過剰なアラートや未発火の調査

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/datadog-labs/agent-skills --skill dd-monitors

インストール後、Claude Code で/dd-monitorsを入力して読み込まれたか確認します。

詳細

Datadog モニター

アラート用のモニターを作成、管理、保守します。

前提条件

pup がパスに含まれている必要があります。Pup のセットアップを参照してください。

コマンド実行順序(トークン効率化)

対象を絞ったコマンドでは、次の順序で実行してください。

  1. まずコンテキストを確認します(過去の出力、会話、保存済みの値)。
  2. 必須の値が不足している場合は、まず情報を確認するコマンドを実行します。
  3. それでも曖昧な場合は、ユーザーに確認を求めます。
  4. その後、対象のコマンドを実行します。
  5. 失敗する可能性が高い、推測に基づくコマンドは避けます。

クイックスタート

pup auth login

よく使う操作

モニターの一覧表示
pup monitors list
pup monitors list --tags "team:platform"
モニターの取得
pup monitors get <id>
モニターの作成
pup monitors create --file monitor.json
アラートの一時停止(ダウンタイム)
# No pup monitors mute/unmute commands.
# Use downtime payloads to silence monitor notifications.
pup downtime create --file downtime.json
pup downtime cancel <downtime_id>

モニター作成のベストプラクティス

1. アラート疲れを防ぐ
ルール理由
頻繁に発生・解消を繰り返すアラートを避けるlast_1m ではなく last_Xm を使用します
意味のあるしきい値を設定する推測ではなく、SLO に基づいて設定します
対応可能なアラートにする対応が不要な場合は、アラートを出さないようにします
ランブックを含めるメッセージに @runbook-url を含めます
# 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. 適切なスコープを設定する
# 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. 復旧しきい値を設定する
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. メッセージにコンテキストを含める
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
"""

モニターを直接削除しないでください

安全な削除ワークフローを使用します(ダッシュボードと同様です)。

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

モニターの種類

種類用途
metric alertCPU、メモリ、カスタムメトリクス
query alert複雑なメトリクスクエリ
service checkAgent のチェック状態
event alertイベントストリームのパターン
log alertログパターンのマッチング
composite複数のモニターを組み合わせます
apmAPM メトリクス

モニターの監査

# 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 (preferred)
pup downtime create --file downtime.json

失敗時の対応

問題解決方法
アラートが発生しないクエリがデータを返すか、しきい値を確認します
アラートが多すぎるウィンドウを長くし、復旧しきい値を追加します
データなしのアラートAgent の接続状態とメトリクスの存在を確認します
認証エラーpup auth refresh

参考資料

コメント