LoginSignup
2
1

More than 3 years have passed since last update.

(引用)Datadog からデータ出力を試してみる

Posted at

素晴らしいエントリ
Datadog からデータ出力を試してみる
の方法でデータ出力可能。

とはいうものの、Datadog側の仕様が変わっているので、
api_keyとapp_keyはheaderで送ってあげないとだめになってる

api_key=取得したAPIキー
app_key=取得したアプリケーションキー
to_time=$(date +%s) # UNIXTIME指定
from_time=$(date -v -20M +%s) # UNIXTIME指定

curl -G \
    -H "DD-API-KEY: ${api_key}" \
    -H "DD-APPLICATION-KEY: ${app_key}" \
    "https://app.datadoghq.com/api/v1/query" \
    -d "from=${from_time}" \
    -d "to=${to_time}" \
    -d "query=max:nginx.net.request_per_s{example}by{name}"

cf. Datadog APIリファレンス#時系列ポイントのクエリ

あと、Datadogからのデータ抽出は、1回のクエリで最高350個にまとめられる。
なので、to_timeとfrom_timeを長くすると、予想外のデータが帰ってくるので注意。
.rollup() を使って調整するのがGood!

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1