# Dynatrace

Stream logs to [Dynatrace](https://www.dynatrace.com) by utilizing the `http` plugin to send data to the [Dynatrace generic log ingest API](https://docs.dynatrace.com/docs/analyze-explore-automate/logs/lma-log-ingestion/lma-log-ingestion-via-api).

## Configuration parameters

| Key                        | Description                                                                                                                  | Default                                         |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| `allow_duplicated_headers` | Specifies duplicated header use.                                                                                             | `false`                                         |
| `format`                   | The data format to be used in the HTTP request body.                                                                         | `json`                                          |
| `header`                   | The specific header for content-type.                                                                                        | `Content-Type application/json; charset=utf-8`  |
| `header`                   | The specific header for authorization token, where `{your-API-token-here}` is the Dynatrace API token with log ingest scope. | `Authorization Api-Token {your-API-token-here}` |
| `host`                     | Your Dynatrace environment hostname where `{your-environment-id}` is your environment ID.                                    | `{your-environment-id}.live.dynatrace.com`      |
| `json_date_format`         | Date format standard for JSON.                                                                                               | `iso8601`                                       |
| `json_date_key`            | Field name specifying message timestamp.                                                                                     | `timestamp`                                     |
| `port`                     | TCP port of your Dynatrace host.                                                                                             | `443`                                           |
| `tls`                      | Specify to use TLS.                                                                                                          | `on`                                            |
| `tls.verify`               | TLS verification.                                                                                                            | `on`                                            |
| `uri`                      | Specify the HTTP URI for Dynatrace log ingest API.                                                                           | `/api/v2/logs/ingest`                           |

## Get started

To get started with sending logs to Dynatrace:

1. Get a [Dynatrace API](https://docs.dynatrace.com/docs/dynatrace-api/basics/dynatrace-api-authentication) token with the `logs.ingest` (Ingest Logs) scope.
2. Determine your Dynatrace [environment ID](https://docs.dynatrace.com/docs/shortlink/monitoring-environment#environment-id).
3. In your main Fluent Bit configuration file, append the following `Output` section:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:

  outputs:
    - name: http
      match: '*'
      header:
        - 'Content-Type application/json; charset=utf-8'
        - 'Authorization Api-Token {your-API-token-here}'
      allow_duplicated_headers: false
      host: {your-environment-id}.live.dynatrace.com
      port: 443
      uri: /api/v2/logs/ingest
      format: json
      json_date_format: iso8601
      json_date_key: timestamp
      tls: on
      tls.verify: on
```

{% endtab %}

{% tab title="fluent-bit.conf" %}

```
[OUTPUT]
  Name                     http
  Match                    *
  Header                   Content-Type application/json; charset=utf-8
  Header                   Authorization Api-Token {your-API-token-here}
  Allow_Duplicated_Headers false
  Host                     {your-environment-id}.live.dynatrace.com
  Port                     443
  Uri                      /api/v2/logs/ingest
  Format                   json
  Json_Date_Format         iso8601
  Json_Date_Key            timestamp
  Tls                      On
  Tls.verify               On
```

{% endtab %}
{% endtabs %}

## References

* [Dynatrace Fluent Bit documentation](https://docs.dynatrace.com/docs/shortlink/lma-stream-logs-with-fluent-bit)
* [Fluent Bit integration in Dynatrace Hub](https://www.dynatrace.com/hub/detail/fluent-bit/?filter=log-management-and-analytics)
* [Video: Stream a Log File to Dynatrace using Fluent Bit](https://www.youtube.com/watch?v=JJJNxhtJ6R0)
* [Blog: Easily stream logs from Fluent Bit to Dynatrace](https://docs.dynatrace.com/docs/analyze-explore-automate/logs/lma-log-ingestion/lma-stream-logs-with-fluent-bit)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fluentbit.io/manual/data-pipeline/outputs/dynatrace.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
