# OpenTelemetry

The OpenTelemetry plugin allows you to ingest telemetry data as per the OTLP specification, from various OpenTelemetry exporters, the OpenTelemetry Collector, or Fluent Bit's OpenTelemetry output plugin.

## Configuration <a href="#configuration" id="configuration"></a>

| Key                        | Description                                                                                                                                     | default |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| listen                     | The address to listen on                                                                                                                        | 0.0.0.0 |
| port                       | The port for Fluent Bit to listen on                                                                                                            | 4318    |
| tag\_key                   | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key.                                             |         |
| raw\_traces                | Route trace data as a log message                                                                                                               | false   |
| buffer\_max\_size          | Specify the maximum buffer size in KB to receive a JSON message.                                                                                | 4M      |
| buffer\_chunk\_size        | This sets the chunk size for incoming incoming JSON messages. These chunks are then stored/managed in the space available by buffer\_max\_size. | 512K    |
| successful\_response\_code | It allows to set successful response code. `200`, `201` and `204` are supported.                                                                | 201     |

Important note: Raw traces means that any data forwarded to the traces endpoint (`/v1/traces`) will be packed and forwarded as a log message, and will NOT be processed by Fluent Bit. The traces endpoint by default expects a valid protobuf encoded payload, but you can set the `raw_traces` option in case you want to get trace telemetry data to any of Fluent Bit's supported outputs.

## Getting started

The OpenTelemetry plugin currently supports the following telemetry data types:

| Type    | HTTP/JSON     | HTTP/Protobuf |
| ------- | ------------- | ------------- |
| Logs    | Stable        | Stable        |
| Metrics | Unimplemented | Stable        |
| Traces  | Unimplemented | Stable        |

A sample config file to get started will look something like the following:

```
[INPUT]
	name opentelemetry
	listen 127.0.0.1
	port 4318

[OUTPUT]
	name stdout
	match *
```

With the above configuration, Fluent Bit will listen on port `4318` for data. You can now send telemetry data to the endpoints `/v1/metrics`, `/v1/traces`, and `/v1/logs` for metrics, traces, and logs respectively.

A sample curl request to POST json encoded log data would be:

```
curl --header "Content-Type: application/json" --request POST --data '{"resourceLogs":[{"resource":{},"scopeLogs":[{"scope":{},"logRecords":[{"timeUnixNano":"1660296023390371588","body":{"stringValue":"{\"message\":\"dummy\"}"},"traceId":"","spanId":""}]}]}]}'   http://0.0.0.0:4318/v1/logs
```


---

# 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/2.1/pipeline/inputs/opentelemetry.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.
