# OpenTelemetry (OTLP)

> Send logs over OTLP/HTTP from any OpenTelemetry SDK, Collector or agent.

By the end of this page any OpenTelemetry SDK, the OpenTelemetry Collector, Vector or Fluent Bit sends its logs to dlogify with its standard OTLP exporter.

## Endpoint

| Transport | Endpoint |
|---|---|
| OTLP/HTTP | `POST https://api.dlogify.com/v1/logs`, body `application/x-protobuf` or `application/json`, optionally `Content-Encoding: gzip` |
| OTLP/gRPC | Not available on `api.dlogify.com` yet. Use OTLP/HTTP. |

A successful export returns `200` with an `ExportLogsServiceResponse` in the request's format.

## Authentication

Send your project API key in the `Authorization` header:

```
Authorization: Bearer lgf_live_…
```

## Environment variables

Most OpenTelemetry SDKs and agents read the standard variables. Note that the logs endpoint variable takes the full URL, path included, and that the header value is URL-encoded (`%20` for the space):

```bash
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://api.dlogify.com/v1/logs
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="Authorization=Bearer%20lgf_live_…"
export OTEL_SERVICE_NAME=checkout
```

## Field mapping

Each log record becomes one event:

| dlogify field | From | When missing |
|---|---|---|
| `service` | resource attribute `service.name` | `unknown_service` |
| `environment` | resource attribute `deployment.environment.name`, else `deployment.environment` | `default` |
| `release` | resource attribute `service.version` | empty |
| `timestamp` | `time_unix_nano`, else `observed_time_unix_nano` | the time dlogify received it |
| `level` | `severity_text` (and `severity_number`, see [Level mapping](https://docs.dlogify.com/send-logs/limits.md#level-mapping)) | empty |
| `message` | the record's `body`; a structured body is rendered as JSON | `<exception.type>: <exception.message>` from the record's attributes; without either, the record is rejected |
| `stack_trace` | record attribute `exception.stacktrace` | empty |
| `trace_id`, `span_id` | the record's ids, as lowercase hex | empty |
| `attributes` | record attributes, then resource attributes, then `otel.scope.name`; on a duplicate key the record wins | — |

Values longer than the event limits are cut and the event is flagged as truncated (see [Limits](https://docs.dlogify.com/send-logs/limits.md)).

## Partial success

A record with no body and no `exception.type` or `exception.message` is dropped. The rest of the export is accepted, and the response's `partial_success` reports `rejected_log_records` with an `error_message`. Rejected records do not count toward your rate limit or monthly quota. An export whose records are all rejected returns `400`.

## Errors

Errors are [problems](https://docs.dlogify.com/errors.md) with the same statuses as [REST](https://docs.dlogify.com/send-logs/rest.md#errors). OTLP exporters retry `429`, `502`, `503` and `504`, honoring `Retry-After`, and drop the rest, so watch for [`413 payload-too-large`](https://docs.dlogify.com/errors/payload-too-large.md): it means your batches are too big and the data was not sent.

## OpenTelemetry Collector

To collect the logs of Docker containers or Kubernetes pods, use the ready-made [Collector presets](https://docs.dlogify.com/send-logs/collector.md). To send from a Collector you already run, add an `otlphttp` exporter and keep batches within the limits:

```yaml
exporters:
  otlphttp/dlogify:
    endpoint: https://api.dlogify.com
    headers:
      authorization: Bearer ${env:LOGIFY_API_KEY}
processors:
  batch:
    # At most 1,000 records and 1 MB (decompressed) per request. The default of
    # 8192 records would be rejected with 413 and not retried.
    send_batch_size: 1000
    send_batch_max_size: 1000
service:
  pipelines:
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlphttp/dlogify]
```

The batch processor counts records, not bytes: 1,000 records of about 2 KB each exceed the 1 MB body limit. If your records are large, lower `send_batch_max_size` so the largest batch stays under the limit.

Source: https://docs.dlogify.com/send-logs/otlp
