スナップショット

APIを使ってグラフのスナップショットを撮る。

GET https://api.ap1.datadoghq.com/api/v1/graph/snapshothttps://api.datadoghq.eu/api/v1/graph/snapshothttps://api.ddog-gov.com/api/v1/graph/snapshothttps://api.datadoghq.com/api/v1/graph/snapshothttps://api.us3.datadoghq.com/api/v1/graph/snapshothttps://api.us5.datadoghq.com/api/v1/graph/snapshot

概要

グラフのスナップショットを作成します。 : スナップショットは、作成されてから利用できるようになるまで若干の時間がかかります。

引数

クエリ文字列

名前

種類

説明

metric_query

string

The metric query.

start [required]

integer

The POSIX timestamp of the start of the query in seconds.

end [required]

integer

The POSIX timestamp of the end of the query in seconds.

event_query

string

A query that adds event bands to the graph.

graph_def

string

A JSON document defining the graph. graph_def can be used instead of metric_query. The JSON document uses the grammar defined here and should be formatted to a single line then URL encoded.

title

string

A title for the graph. If no title is specified, the graph does not have a title.

height

integer

The height of the graph. If no height is specified, the graph’s original height is used.

width

integer

The width of the graph. If no width is specified, the graph’s original width is used.

応答

OK

Object representing a graph snapshot.

Expand All

フィールド

種類

説明

graph_def

string

A JSON document defining the graph. graph_def can be used instead of metric_query. The JSON document uses the grammar defined here and should be formatted to a single line then URL encoded.

metric_query

string

The metric query. One of metric_query or graph_def is required.

snapshot_url

string

URL of your graph snapshot.

{
  "graph_def": "string",
  "metric_query": "string",
  "snapshot_url": "https://app.datadoghq.com/s/f12345678/aaa-bbb-ccc"
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例

"""
Take graph snapshots returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.snapshots_api import SnapshotsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SnapshotsApi(api_client)
    response = api_instance.get_graph_snapshot(
        metric_query="avg:system.load.1{*}",
        start=int((datetime.now() + relativedelta(days=-1)).timestamp()),
        end=int(datetime.now().timestamp()),
        title="System load",
        height=400,
        width=600,
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"

PREVIEWING: hannahkm/clarify-v2-docs
Your Privacy Choices