For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/ja/api/latest/logs/search-logs.md. A documentation index is available at /llms.txt.
Language
Datadog site

ログを検索する

POSThttps://api.datadoghq.com/api/v1/logs-queries/listhttps://api.us3.datadoghq.com/api/v1/logs-queries/listhttps://api.us5.datadoghq.com/api/v1/logs-queries/listhttps://api.datadoghq.eu/api/v1/logs-queries/listhttps://api.ap1.datadoghq.com/api/v1/logs-queries/listhttps://api.ap2.datadoghq.com/api/v1/logs-queries/listhttps://api.uk1.datadoghq.com/api/v1/logs-queries/listhttps://api.ddog-gov.com/api/v1/logs-queries/listhttps://api.us2.ddog-gov.com/api/v1/logs-queries/list

概要

リストエンドポイントは、ログ検索クエリに一致するログを返します。 結果はページ分割されます。

組織のログのアーカイブを検討されている場合は、 リスト API の代わりに Datadog のアーカイブ機能の使用を検討します。 Datadog ログアーカイブのドキュメント を参照してください。

注: このエンドポイントは、ログを利用するお客様に対してデフォルトで有効になっています。無効にするには、Datadog サポート までお問い合わせください。

This endpoint requires the logs_read_data permission.

リクエスト

Body Data (required)

ログフィルター

フィールド
タイプ
説明
index
string

組織からログのリストを取得するためにリクエストとともに送信するオブジェクト。

limit
int32

Number of logs return in the response.

query
string

The search query - following the log search syntax.

sort
enum

Time-ascending asc or time-descending desc results.

Allowed enum values: asc, desc
startAt
string

Hash identifier of the first log to return in the list, available in a log id attribute. This parameter is used for the pagination feature.

Note: This parameter is ignored if the corresponding log is out of the scope of the specified time window.

time [required]
object

Timeframe to retrieve the log from.

応答

OK

Response object with all logs matching the request and pagination information.

フィールド
タイプ
説明
logs
[object]

Array of logs matching the request and the nextLogId if sent.

nextLogId
string

Hash identifier of the next log to return in the list. This parameter is used for the pagination feature.

requestId
string

Unique identifier of the request.

status
string

Status of the response.

コード例

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/logs-queries/list" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "index": "retention-3,retention-15",
  "limit": 25,
  "query": "service:web-api AND @http.status_code:[200 TO 299]",
  "sort": "desc",
  "time": {
    "from": "2020-02-02T02:02:02.202Z",
    "to": "2020-02-20T02:02:02.202Z"
  }
}
EOF