Envoyez vos logs à votre plate-forme Datadog via HTTP. Les limites par requête HTTP sont les suivantes :
Taille maximale du contenu par charge utile (sans compression) : 5 Mo
Taille maximale d’un log : 1 Mo
Taille maximale d’un tableau en cas d’envoi de plusieurs logs dans un tableau : 1 000 entrées
Tous les logs dépassant 1 Mo sont acceptés et tronqués par Datadog :
Pour une requête avec un seul log, l’API réduit le log de façon à ce qu’il fasse 1 Mo et renvoie un code 2xx.
Pour une requête avec plusieurs logs, l’API traite tous les logs, réduit uniquement les logs dépassant 1 Mo et renvoie un code 2xx.
Nous vous conseillons de compresser vos logs avant de les envoyer.
Ajoutez l’en-tête Content-Encoding: gzip à la requête pour envoyer vos logs compressés.
Voici les différents codes de statut renvoyés par l’API HTTP :
200: OK
400: Bad request (probablement une erreur dans la mise en forme de la charge utile)
403: Permission issue (probablement une clé d’API non valide)
413: Payload too large (taille du lot supérieure à 5 Mo une fois décompressé)
5xx: Internal error (la requête sera renvoyée ultérieurement)
Arguments
Chaînes de requête
Nom
Type
Description
ddtags
string
Log tags can be passed as query parameters with text/plain content type.
The integration name associated with your log: the technology from which the log originated.
When it matches an integration name, Datadog automatically installs the corresponding parsers and facets.
See reserved attributes.
ddtags
string
Tags associated with your logs.
hostname
string
The name of the originating host of the log.
message
string
The message reserved attribute
of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry.
That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.
service
string
The name of the application or service generating the log events.
It is used to switch from Logs to APM, so make sure you define the same value when you use both products.
See reserved attributes.
[{"ddsource":"nginx","ddtags":"env:staging,version:5.1","hostname":"i-012345678","message":"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World","service":"payment"}]
[{"ddsource":"nginx","ddtags":"env:staging,version:5.1","hostname":"i-012345678","message":"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World","service":"payment"}]
[{"ddsource":"nginx","ddtags":"env:staging,version:5.1","hostname":"i-012345678","message":"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World","service":"payment","status":"info"}]
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi JSON Messages
# Pass multiple log objects at once.
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple JSON Message
# Log attributes can be passed as `key:value` pairs in valid JSON messages.
See one of the other client libraries for an example of sending deflate-compressed data.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi Logplex Messages
# Submit log messages.
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple Logplex Message
# Submit log string.
See one of the other client libraries for an example of sending deflate-compressed data.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi Raw Messages
# Submit log string.
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple Raw Message
# Submit log string. Log attributes can be passed as query parameters in the URL. This enables the addition of tags or the source by using the `ddtags` and `ddsource` parameters: `?host=my-hostname&service=my-service&ddsource=my-source&ddtags=env:prod,user:my-user`.
See one of the other client libraries for an example of sending deflate-compressed data.
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
/**
* Send deflate logs returns "Request accepted for processing (always 202 empty JSON)." response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsApi(configuration);constparams: v2.LogsApiSubmitLogRequest={body:[{ddsource:"nginx",ddtags:"env:staging,version:5.1",hostname:"i-012345678",message:"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",service:"payment",},],contentEncoding:"deflate",};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Send gzip logs returns "Request accepted for processing (always 202 empty JSON)." response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsApi(configuration);constparams: v2.LogsApiSubmitLogRequest={body:[{ddsource:"nginx",ddtags:"env:staging,version:5.1",hostname:"i-012345678",message:"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",service:"payment",},],contentEncoding:"gzip",};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Send logs returns "Request accepted for processing (always 202 empty JSON)." response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsApi(configuration);constparams: v2.LogsApiSubmitLogRequest={body:[{ddsource:"nginx",ddtags:"env:staging,version:5.1",hostname:"i-012345678",message:"2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",service:"payment",additionalProperties:{status:"info",},},],};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Envoyez vos logs à votre plate-forme Datadog via HTTP. Les limites par requête HTTP sont les suivantes :
Taille maximale du contenu par charge utile (sans compression) : 5 Mo
Taille maximale d’un log : 1 Mo
Taille maximale d’un tableau en cas d’envoi de plusieurs logs dans un tableau : 1 000 entrées
Tous les logs dépassant 1 Mo sont acceptés et tronqués par Datadog :
Pour une requête avec un seul log, l’API réduit le log de façon à ce qu’il fasse 1 Mo et renvoie un code 2xx.
Pour une requête avec plusieurs logs, l’API traite tous les logs, réduit uniquement les logs dépassant 1 Mo et renvoie un code 2xx.
Nous vous conseillons de compresser vos logs avant de les envoyer.
Ajoutez l’en-tête Content-Encoding: gzip à la requête pour envoyer vos logs compressés.
Voici les différents codes de statut renvoyés par l’API HTTP :
200: OK
400: Bad request (probablement une erreur dans la mise en forme de la charge utile)
403: Permission issue (probablement une clé d’API non valide)
413: Payload too large (taille du lot supérieure à 5 Mo une fois décompressé)
5xx: Internal error (la requête sera renvoyée ultérieurement)
Arguments
Chaînes de requête
Nom
Type
Description
ddtags
string
Log tags can be passed as query parameters with text/plain content type.
The integration name associated with your log: the technology from which the log originated.
When it matches an integration name, Datadog automatically installs the corresponding parsers and facets.
See reserved attributes.
ddtags
string
Tags associated with your logs.
hostname
string
The name of the originating host of the log.
message
string
The message reserved attribute
of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry.
That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.
service
string
The name of the application or service generating the log events.
It is used to switch from Logs to APM, so make sure you define the same value when you use both products.
See reserved attributes.
The integration name associated with your log: the technology from which the log originated.
When it matches an integration name, Datadog automatically installs the corresponding parsers and facets.
See reserved attributes.
ddtags
string
Tags associated with your logs.
hostname
string
The name of the originating host of the log.
message
string
The message reserved attribute
of your log. By default, Datadog ingests the value of the message attribute as the body of the log entry.
That value is then highlighted and displayed in the Logstream, where it is indexed for full text search.
service
string
The name of the application or service generating the log events.
It is used to switch from Logs to APM, so make sure you define the same value when you use both products.
See reserved attributes.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi JSON Messages
# Pass multiple log objects at once.
See one of the other client libraries for an example of sending deflate-compressed data.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple JSON Message
# Log attributes can be passed as `key:value` pairs in valid JSON messages.
See one of the other client libraries for an example of sending deflate-compressed data.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi Logplex Messages
# Submit log messages.
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple Logplex Message
# Submit log string.
See one of the other client libraries for an example of sending deflate-compressed data.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Multi Raw Messages
# Submit log string.
See one of the other client libraries for an example of sending deflate-compressed data.
## Simple Raw Message
# Submit log string. Log attributes can be passed as query parameters in the URL. This enables the addition of tags or the source by using the `ddtags` and `ddsource` parameters: `?host=my-hostname&service=my-service&ddsource=my-source&ddtags=env:prod,user:my-user`.
See one of the other client libraries for an example of sending deflate-compressed data.
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
/**
* Send deflate logs returns "Response from server (always 200 empty JSON)." response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.LogsApi(configuration);constparams: v1.LogsApiSubmitLogRequest={body:[{message:"Example-Log",ddtags:"host:ExampleLog",},],contentEncoding:"deflate",};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Send gzip logs returns "Response from server (always 200 empty JSON)." response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.LogsApi(configuration);constparams: v1.LogsApiSubmitLogRequest={body:[{message:"Example-Log",ddtags:"host:ExampleLog",},],contentEncoding:"gzip",};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Send logs returns "Response from server (always 200 empty JSON)." response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.LogsApi(configuration);constparams: v1.LogsApiSubmitLogRequest={body:[{message:"Example-Log",ddtags:"host:ExampleLog",},],};apiInstance.submitLog(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));