Take graph snapshots. Snapshots are PNG images generated by rendering a specified widget in a web page and capturing it once the data is available. The image is then uploaded to cloud storage.
Note: When a snapshot is created, there is some delay before it is available.
Arguments
Query Strings
Name
Type
Description
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.
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.
# Required query arguments exportmetric_query="CHANGE_ME" exportstart="CHANGE_ME" exportend="CHANGE_ME" # Use a Personal Access Token or Service Access Token exportDD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"python3"example.py"
# Take graph snapshots returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.access_token=ENV["DD_BEARER_TOKEN"]endapi_instance=DatadogAPIClient::V1::SnapshotsAPI.newopts={metric_query:"avg:system.load.1{*}",title:"System load",height:400,width:600,}papi_instance.get_graph_snapshot((Time.now+-1*86400).to_i,Time.now.to_i,opts)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"rb"example.rb"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"go run"main.go"
// Take graph snapshots returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.SnapshotsApi;importcom.datadog.api.client.v1.api.SnapshotsApi.GetGraphSnapshotOptionalParameters;importcom.datadog.api.client.v1.model.GraphSnapshot;importjava.time.OffsetDateTime;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));SnapshotsApiapiInstance=newSnapshotsApi(defaultClient);try{GraphSnapshotresult=apiInstance.getGraphSnapshot(OffsetDateTime.now().plusDays(-1).toInstant().getEpochSecond(),OffsetDateTime.now().toInstant().getEpochSecond(),newGetGraphSnapshotOptionalParameters().metricQuery("avg:system.load.1{*}").title("System load").height(400L).width(600L));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling SnapshotsApi#getGraphSnapshot");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"java"Example.java"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Take graph snapshots returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});constapiInstance=newv1.SnapshotsApi(configuration);constparams: v1.SnapshotsApiGetGraphSnapshotRequest={metricQuery:"avg:system.load.1{*}",start: Math.round(newDate(newDate().getTime()+-1*86400*1000).getTime()/1000),end: Math.round(newDate().getTime()/1000),title:"System load",height: 400,width: 600,};apiInstance.getGraphSnapshot(params).then((data: v1.GraphSnapshot)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"tsc"example.ts"
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.