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

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

ユーザ用ツール

サイト用ツール


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


Datadog:curlでテストログを送る方法




DatadogのモニターやPipelineを設定した後にテストをしたいと思います。
コンテナですと、ログテストが難しいので、curlからできることも覚えておきましょう。

ログのAPI

Datadog site

実行例

## Multi Raw Messages
# Submit log string.

# Curl command
curl -X POST "https://http-intake.logs.datadoghq.com/api/v2/logs" \
-H "Accept: application/json" \
-H "Content-Type: text/plain" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
2019-11-19T14:37:58,995 INFO [process.name][20081] Hello
2019-11-19T14:37:58,995 INFO [process.name][20081] World

EOF
## Simple Raw Message
# Submit log string. Log attributes can be passed as query parameters in the URL. This enables the addition of tags or the source by using the `ddtags` and `ddsource` parameters: `?host=my-hostname&service=my-service&ddsource=my-source&ddtags=env:prod,user:my-user`.

# Curl command
curl -X POST "https://http-intake.logs.datadoghq.com/api/v2/logs" \
-H "Accept: application/json" \
-H "Content-Type: text/plain" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World
EOF
curl -X POST "https://http-intake.logs.datadoghq.com/api/v2/logs" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "ddsource": "taromn",
  "ddtags": "env:staging,version:1.0",
  "hostname": "i-abcde",
  "message": "Taromn Awesome Log",
  "service": "taromn"
}
EOF


参考


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

ページ用ツール