スナップショット

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
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_snapshots::GetGraphSnapshotOptionalParams;
use datadog_api_client::datadogV1::api_snapshots::SnapshotsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = SnapshotsAPI::with_config(configuration);
    let resp = api
        .get_graph_snapshot(
            1636542671,
            1636629071,
            GetGraphSnapshotOptionalParams::default()
                .metric_query("avg:system.load.1{*}".to_string())
                .title("System load".to_string())
                .height(400)
                .width(600),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs 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>" cargo run