システムパフォーマンス入門

パフォーマンスに詳しいインフラに憧れて

ユーザ用ツール

サイト用ツール


· 最終更新: 2025/01/26 by kurihara


DatadogをAPIで操作

APIキーとAPPキーの設定

export DD_API_KEY="xxxxxxx"
export DD_APP_KEY="xxxxxxx"


すべてのモニター一覧を取得

参考:https://docs.datadoghq.com/ja/api/latest/monitors/#get-all-monitors

curl -X GET "https://api.datadoghq.com/api/v1/monitor" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"


すべてのDowntimeの取得

参考:https://docs.datadoghq.com/ja/api/latest/downtimes/#get-all-downtimes

curl -X GET "https://api.datadoghq.com/api/v2/downtime" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"


出力の変換

jsonを1行のjsonにする

jq -c < sample.json

jsonをCSVに変換

cat sample1.json | jq -r '.[] | [.key1, .key2, .key3] | @csv'
$ cat corona.json |jq -r '.data[]|[.country, .cases, .todayCases, .deaths, .todayDeaths, .recovered, .active, .critical, .casesPerOneMillion, .deathsPerOneMillion, .tests, .testsPerOneMillion, .confirmed, .countryCode]|@csv'





· 最終更新: 2025/01/26 by kurihara

ページ用ツール