L’endpoint de métriques vous permet d’envoyer des données de série temporelle afin de les représenter graphiquement dans les dashboards de Datadog.
La limite de taille des charges utiles compressées est de 3,2 Mo (3 200 000 octets), tandis que celle des charges utiles non compressées est de 62 Mo (62 914 560 octets).
Si vous envoyez directement des métriques à l’API Datadog sans passer par DogStatsD, vous pouvez compter :
64 bits pour le timestamp
64 bits pour la valeur
40 octets pour les noms de métriques
50 octets pour la série temporelle
La charge utile totale fait environ 100 octets. Cependant, avec l’API DogStatsD, cette charge est compressée afin de réduire son poids.
If the type of the metric is rate or count, define the corresponding interval in seconds.
metadata
object
Metadata for the metric.
origin
object
Metric origin information.
metric_type
int32
The origin metric type code
product
int32
The origin product code
service
int32
The origin service code
metric [required]
string
The name of the timeseries.
points [required]
[object]
Points relating to a metric. All points must be objects with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
timestamp
int64
The timestamp should be in seconds and current.
Current is defined as not more than 10 minutes in the future or more than 1 hour in the past.
value
double
The numeric value format should be a 64bit float gauge-type value.
resources
[object]
A list of resources to associate with this metric.
name
string
The name of the resource.
type
string
The type of the resource.
source_type_name
string
The source type name.
tags
[string]
A list of tags associated with the metric.
type
enum
The type of metric. The available types are 0 (unspecified), 1 (count), 2 (rate), and 3 (gauge).
Allowed enum values: 0,1,2,3
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
// Submit metrics returns "Payload accepted" responsepackagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){body:=datadogV2.MetricPayload{Series:[]datadogV2.MetricSeries{{Metric:"system.load.1",Type:datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),Points:[]datadogV2.MetricPoint{{Timestamp:datadog.PtrInt64(time.Now().Unix()),Value:datadog.PtrFloat64(0.7),},},Resources:[]datadogV2.MetricResource{{Name:datadog.PtrString("dummyhost"),Type:datadog.PtrString("host"),},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV2.NewSubmitMetricsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitMetrics`:\n%s\n",responseContent)}
// Submit metrics with compression returns "Payload accepted" responsepackagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){body:=datadogV2.MetricPayload{Series:[]datadogV2.MetricSeries{{Metric:"system.load.1",Type:datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),Points:[]datadogV2.MetricPoint{{Timestamp:datadog.PtrInt64(time.Now().Unix()),Value:datadog.PtrFloat64(0.7),},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV2.NewSubmitMetricsOptionalParameters().WithContentEncoding(datadogV2.METRICCONTENTENCODING_ZSTD1))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitMetrics`:\n%s\n",responseContent)}
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>"cargo run
/**
* Submit metrics returns "Payload accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:0,points:[{timestamp: Math.round(newDate().getTime()/1000),value: 0.7,},],resources:[{name:"dummyhost",type:"host",},],},],},};apiInstance.submitMetrics(params).then((data: v2.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Submit metrics with compression returns "Payload accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:0,points:[{timestamp: Math.round(newDate().getTime()/1000),value: 0.7,},],},],},contentEncoding:"zstd1",};apiInstance.submitMetrics(params).then((data: v2.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
L’endpoint de métriques vous permet d’envoyer des données de série temporelle afin de les représenter graphiquement dans les dashboards de Datadog.
La limite de taille des charges utiles compressées est de 3,2 Mo (3 200 000 octets), tandis que celle des charges utiles non compressées est de 62 Mo (62 914 560 octets).
Si vous envoyez directement des métriques à l’API Datadog sans passer par DogStatsD, vous pouvez compter :
64 bits pour le timestamp
64 bits pour la valeur
40 octets pour les noms de métriques
50 octets pour la série temporelle
La charge utile totale fait environ 100 octets. Cependant, avec l’API DogStatsD, cette charge est compressée afin de réduire son poids.
If the type of the metric is rate or count, define the corresponding interval in seconds.
metric [required]
string
The name of the timeseries.
points [required]
[array]
Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
tags
[string]
A list of tags associated with the metric.
type
string
The type of the metric. Valid types are "",count, gauge, and rate.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
fromdatadogimportinitialize,apiimporttimeoptions={'api_key':'<DATADOG_API_KEY>'## EU costumers need to define 'api_host' as below#'api_host': 'https://api.datadoghq.eu/'}initialize(**options)now=time.time()future_10s=now+10# Submit a single point with a timestamp of `now`api.Metric.send(metric='page.views',points=1000)# Submit a point with a timestamp (must be current)api.Metric.send(metric='my.pair',points=(now,15))# Submit multiple points.api.Metric.send(metric='my.series',points=[(now,15),(future_10s,16)])# Submit a point with a host and tags.api.Metric.send(metric='my.series',points=100,host="myhost.example.com",tags=["version:1"])# Submit multiple metricsapi.Metric.send([{'metric':'my.series','points':15},{'metric':'my1.series','points':16}])
require'rubygems'require'dogapi'api_key='<DATADOG_API_KEY>'dog=Dogapi::Client.new(api_key)# Submit one metric value.dog.emit_point('some.metric.name',50.0,:host=>"my_host.example.com")# Submit multiple metric valuespoints=[[Time.now,0],[Time.now+10,10.0],[Time.now+20,20.0]]dog.emit_points('some.metric.name',points,:tags=>["version:1"])# Emit differents metrics in a single request to be more efficientdog.batch_metricsdodog.emit_point('test.api.test_metric',10)dog.emit_point('test.api.this_other_metric',1)end
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>"cargo run
/**
* Submit deflate metrics returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:"gauge",points:[[Math.round(newDate().getTime()/1000),1.1]],tags:["test:ExampleMetric"],},],},contentEncoding:"deflate",};apiInstance.submitMetrics(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Submit metrics returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:"gauge",points:[[Math.round(newDate().getTime()/1000),1.1]],tags:["test:ExampleMetric"],},],},};apiInstance.submitMetrics(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));