Skip to Content
Docs

Log drains to Datadog

Send the logs of your workspace to Datadog Logs with a log drain.

The type datadog sends the records of a log drain to the Datadog Logs intake API. You need an API key with the scope log_drains:write and a Datadog API key. A log drain is a feature of the Business plan.

Make the log drain

Use a Datadog API key. An application key does not work. Choose the site of your Datadog account:

siteDatadog site
us1datadoghq.com
us3us3.datadoghq.com
us5us5.datadoghq.com
eu1datadoghq.eu
ap1ap1.datadoghq.com
ap2ap2.datadoghq.com
uk1uk1.datadoghq.com
us1-fedddog-gov.com
us2-fedus2.ddog-gov.com
curl https://api.afffast.com/v1/log_drains \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "datadog",
    "label": "Datadog",
    "config": { "site": "eu1", "service": "affiliate", "tags": "env:prod,team:growth" },
    "credentials": { "api_key": "..." },
    "sources": ["api_request", "sync_run"]
  }'
  • site is required.
  • service is optional. The default is afffast.
  • tags is optional. Write tags that are separated by commas (200 characters at most). Use letters, digits and the characters _ . / : -.
  • api_key is write-only. The API never returns it.

POST /v1/log_drains/{id}/test sends one sample record ("test": true).

What Datadog gets

Each record is one log entry:

FieldValue
ddsourceafffast
serviceThe service of the config.
ddtagssource, level, livemode and workspace, then your extra tags. A test record has test:true.
statusinfo, warn or error.
messageA short line, for example POST /v1/links 500 80 ms.
dateThe time of the record.
afffastThe full record. Each field is an attribute, for example @afffast.data.path.

The API sends up to 1000 records in one request, and the request is smaller than the limit of Datadog (5 MB). It compresses the request with gzip.

Errors

Answer of DatadogWhat the API does
202The batch is done.
429The API waits and tries again.
401, 403The API stops the log drain (failing). The API key is wrong, or it is for another site.
400, 404The API stops the log drain (failing).
413The API sends the batch in smaller parts.
408, 5xx, other, no answerThe API tries again with a growing wait.

See Log drains for the retry wait and the resume of a log drain that failed.

On this page