---
name: azion-send-logs-to-datadog
description: >-
  Create a stream that sends the logs of your applications to a Datadog log intake URL, in Azion Console or with the Azion API, and confirm the delivery.
---

# Send logs to Datadog

You can send the logs of a stream to [Datadog](https://www.datadoghq.com/) from Azion Console or with the Azion API.

[Data Stream](/en/documentation/platform/data-stream/) sends each batch of log lines to the log intake URL of your Datadog account and authenticates with a Datadog API key. In the stream form, the endpoint is set in the field labeled **Connector**, and Datadog is its *Datadog* option. For every field and its bounds, refer to [Endpoints](/en/documentation/platform/data-stream/endpoints/#datadog).

In this guide, the stream reads the requests that one workload receives, through the *Applications* data source.

---

Choose Console or API here. Every section of the page follows that choice.

## Prerequisites

- An Azion account with the **Edit Data Stream** permission. For the permissions, refer to [Stream settings](/en/documentation/platform/data-stream/stream-settings/#permissions).
- A [workload](/en/documentation/platform/workloads/) on the account that receives requests.
- A Datadog account.
- The log intake URL of your Datadog account, with its scheme, such as `https://http-intake.logs.datadoghq.com/v1/input`.
- A Datadog API key, created in the Datadog dashboard.

**Console**

- Access to Azion Console. To sign in, refer to [How to access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).

**API**

- A personal token. To create one, refer to [How to manage a personal token](/en/documentation/guides/platform/account-and-billing/personal-tokens/).
- The ID of the workload.
- `curl`.

---

## Create the stream

A workload filter limits the stream to the workload you pick. Unlike a stream with sampling, a stream with a workload filter leaves your other streams active.

**Console**

To create the stream in Azion Console:

1. **Open Data Stream**

   Access [Azion Console](https://console.azion.com/) > **Data Stream**.

2. **Select + Stream**

3. **Name the stream**

   In the **General** section, enter a **Name**. For example: `logs-to-datadog`.

4. **Select the data source**

   In the **Input** section, select *Applications* in **Data Source**.

5. **Turn off Sampling**

   In the **Transform** section, turn off **Sampling** while **Option** is still *All Current and Future Workloads*, its starting value. A stream cannot carry sampling and a workload filter together.

6. **Choose the workload**

   In the **Transform** section, set **Option** to *Filter Workloads*. In **Available Workload**, select your workload and move it to **Chosen Workload** with the arrow.

7. **Select the template**

   In the **Render Template** section, select *Applications Event Collector* in **Template**.

8. **Select the Datadog endpoint**

   In the **Output** section, select *Datadog* in **Connector**.

9. **Enter the intake URL**

   In **URL**, enter the log intake URL of your Datadog account. For example: `https://http-intake.logs.datadoghq.com/v1/input`.

10. **Enter the API key**

    In **API Key**, enter your Datadog API key.

11. **Keep the stream active**

    In the **Status** section, keep **Active** turned on.

12. **Select Save**

The Console shows `Your data stream has been created`. The stream appears in the **Data Stream** list with `Datadog` in the **Connector** column and the **Active** status.

**API**

Send a `POST` request to `https://api.azion.com/v4/workspace/stream/streams`. In the body, put the ID of your workload in place of `<workload-id>`, and your intake URL and API key in the `outputs` entry. Use your personal token in place of `[TOKEN VALUE]`:

```bash
curl -X POST 'https://api.azion.com/v4/workspace/stream/streams' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token [TOKEN VALUE]' \
  -d '{
    "name": "logs-to-datadog",
    "active": true,
    "inputs": [
      { "type": "raw_logs", "attributes": { "data_source": "workloads" } }
    ],
    "transform": [
      { "type": "filter_workloads", "attributes": { "workloads": [<workload-id>] } },
      { "type": "render_template", "attributes": { "template": 2 } }
    ],
    "outputs": [
      {
        "type": "datadog",
        "attributes": {
          "url": "https://http-intake.logs.datadoghq.com/v1/input",
          "api_key": "[API KEY]"
        }
      }
    ]
  }'
```

In the body, `workloads` is the API name of the *Applications* data source, and template `2` is *Applications Event Collector*. A `201` response returns the stream as Azion stored it:

```json
{
  "state": "executed",
  "data": {
    "id": 12354,
    "name": "logs-to-datadog",
    "last_editor": "user@example.com",
    "created": "2026-01-01T12:10:37.000000Z",
    "last_modified": "2026-01-01T12:10:37.000000Z",
    "product_version": "1.0",
    …
    "outputs": [
      {
        "type": "datadog",
        "attributes": {
          "url": "https://http-intake.logs.datadoghq.com/v1/input",
          "api_key": "[API KEY]"
        }
      }
    ]
  }
}
```

The `id` identifies the stream in every later request, such as `/v4/workspace/stream/streams/12354`. For every key of the body, refer to [Stream settings](/en/documentation/platform/data-stream/stream-settings/#stream-object).

Neither the Console nor the API contacts Datadog when you save. A mistyped URL or an invalid API key shows up only as a failed send. The stream starts to send one to two minutes after you activate it.

---

## Confirm the delivery

Each attempt of the stream to send a batch, successful or not, appears in [Real-Time Events](/en/documentation/platform/real-time-events/data-sources/#data-stream) with the status code Datadog returned. Make a few requests to the workload and allow about a minute. The stream sends a batch every 60 seconds, or earlier when the batch holds 2,000 log lines.

**Console**

To find the sends in Azion Console:

1. **Open Real-Time Events**

   Access [Azion Console](https://console.azion.com/) > **Real-Time Events**.

2. **Select the Data Stream data source**

3. **Read the latest sends**

   Each row is one send. Find the rows with `DATADOG` in **Endpoint Type**, and read their **Status Code**.

A **Status Code** of `200` means Datadog accepted the batch. **Streamed Lines** gives the number of log lines in the batch.

**API**

To read the sends with the API, query the `dataStreamedEvents` dataset of the Real-Time Events GraphQL API. Replace the dates with a range that covers the activation of the stream:

```bash
curl -X POST 'https://api.azion.com/v4/events/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token [TOKEN VALUE]' \
  -d '{"query":"query { dataStreamedEvents(limit: 20, filter: {tsRange: {begin: \"2026-01-01T12:00:00\", end: \"2026-01-01T12:45:00\"}}, orderBy: [ts_DESC]) { ts endpointType statusCode streamedLines dataStreamed } }"}'
```

The API answers `200` with one record for each send, the latest first:

```json
{
  "data": {
    "dataStreamedEvents": [
      {
        "ts": "2026-01-01T12:02:04Z",
        "endpointType": "DATADOG",
        "statusCode": 200,
        "streamedLines": 2,
        "dataStreamed": 2797
      }
    ]
  }
}
```

A send to Datadog carries `DATADOG` in `endpointType`. A `statusCode` of `200` means Datadog accepted the batch, and `streamedLines` and `dataStreamed` give its size in log lines and bytes. An empty `dataStreamedEvents` list means the stream has not sent in the range. For every field, refer to [Real-Time Events GraphQL fields](/en/documentation/devtools/graphql/gql-real-time-events-fields/#datastreamedevents-data-stream).

Any status other than `200` is the answer of Datadog, except `503`, which means Data Stream found the endpoint unavailable. For the causes, refer to [Troubleshoot Data Stream](/en/documentation/platform/data-stream/troubleshooting/).

---

## Next steps

- [Endpoints](/en/documentation/platform/data-stream/endpoints.md#datadog): Every field of the Datadog endpoint, with its type, bounds, and API name.
- [Templates and payload](/en/documentation/platform/data-stream/templates-and-payload.md): Choose the variables each log line carries to Datadog.
- [Edit, stop, or delete a stream](/en/documentation/guides/platform/observability/delete-data-stream.md): Replace the API key or the intake URL, turn the stream off, or delete it.
- [Troubleshoot Data Stream](/en/documentation/platform/data-stream/troubleshooting.md): Read what a status other than 200 means and how to fix the stream.
