# OpenTelemetry

Loglark accepts OpenTelemetry logs over OTLP/HTTP. The OTLP base URL is
`https://api.loglark.io/otlp`; exporters append the standard `/v1/logs`
path themselves, so the logs endpoint is
`https://api.loglark.io/otlp/v1/logs`. OTLP ingestion is always on —
there is nothing to enable. The request is routed by two headers:

- `Authorization: Bearer <token>` — an ingest token (create one under
  Settings → Tokens)
- `X-Loglark-Topic: <topic>` — the topic to write to; it is created on
  first use if it doesn't exist

Certificates are publicly trusted, so no CA setup is needed.

## Send from an OpenTelemetry SDK

Point the exporter at the base URL. Replace `lrk_...` with your token
and `mytopic` with the topic name.

```
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.loglark.io/otlp
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer lrk_...,X-Loglark-Topic=mytopic"
```

If you set the logs-specific variable instead, give it the full path —
the SDK uses it as-is:

```
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://api.loglark.io/otlp/v1/logs
```

## Send from an OpenTelemetry Collector

Add an `otlphttp` exporter and route your logs pipeline through it:

```yaml
exporters:
  otlphttp/loglark:
    endpoint: https://api.loglark.io/otlp
    headers:
      Authorization: Bearer lrk_...
      X-Loglark-Topic: mytopic

service:
  pipelines:
    logs:
      exporters: [otlphttp/loglark]
```
