Adapters

OTLP

Send logs via OpenTelemetry Protocol to Grafana, Datadog, Honeycomb, and any OTLP-compatible backend.

The OTLP (OpenTelemetry Protocol) adapter sends logs in the standard OpenTelemetry format. This works with any OTLP-compatible backend including:

  • Grafana Cloud (Loki)
  • Datadog
  • Honeycomb
  • Jaeger
  • Splunk
  • New Relic
  • Self-hosted OpenTelemetry Collector

Installation

The OTLP adapter is included in the main evlog package:

import { createOTLPDrain } from 'evlog/otlp'

Quick Start

1. Set your OTLP endpoint

.env
NUXT_OTLP_ENDPOINT=http://localhost:4318

2. Create the drain plugin

server/plugins/evlog-drain.ts
import { createOTLPDrain } from 'evlog/otlp'

export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('evlog:drain', createOTLPDrain())
})

Configuration

The adapter reads configuration from multiple sources (highest priority first):

  1. Overrides passed to createOTLPDrain()
  2. Runtime config at runtimeConfig.evlog.otlp
  3. Runtime config at runtimeConfig.otlp
  4. Environment variables (NUXT_OTLP_* or OTEL_*)

Environment Variables

VariableDescription
NUXT_OTLP_ENDPOINTOTLP HTTP endpoint (e.g., http://localhost:4318)
NUXT_OTLP_SERVICE_NAMEOverride service name
NUXT_OTLP_HEADERSCustom headers (format: Key=Value,Key2=Value2)
NUXT_OTLP_AUTHShortcut for Authorization header

Standard OpenTelemetry variables are also supported:

VariableDescription
OTEL_EXPORTER_OTLP_ENDPOINTOTLP endpoint (fallback)
OTEL_EXPORTER_OTLP_HEADERSHeaders in OTEL format
OTEL_SERVICE_NAMEService name (fallback)

Runtime Config

nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    otlp: {
      endpoint: '', // Set via NUXT_OTLP_ENDPOINT
    },
  },
})

Override Options

server/plugins/evlog-drain.ts
import { createOTLPDrain } from 'evlog/otlp'

export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('evlog:drain', createOTLPDrain({
    endpoint: 'http://localhost:4318',
    serviceName: 'my-api',
    headers: {
      'Authorization': 'Bearer xxx',
    },
    resourceAttributes: {
      'deployment.environment': 'staging',
    },
  }))
})

Full Configuration Reference

OptionTypeDefaultDescription
endpointstring-OTLP HTTP endpoint (required)
serviceNamestringFrom eventOverride service.name resource attribute
headersobject-Custom HTTP headers for authentication
resourceAttributesobject-Additional OTLP resource attributes
timeoutnumber5000Request timeout in milliseconds

Provider-Specific Setup

Grafana Cloud

  1. Go to your Grafana Cloud portal
  2. Navigate to Connections > Collector > OpenTelemetry
  3. Copy your OTLP endpoint and generate credentials
.env
NUXT_OTLP_ENDPOINT=https://otlp-gateway-prod-us-central-0.grafana.net/otlp
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic%20base64-encoded-credentials
Grafana uses URL-encoded headers. The %20 is a space character. The adapter automatically decodes this format.

Datadog

.env
NUXT_OTLP_ENDPOINT=https://http-intake.logs.datadoghq.com
NUXT_OTLP_HEADERS=DD-API-KEY=your-api-key

Local OpenTelemetry Collector

For development and testing, run a local collector:

otel-collector.yaml
receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [debug]
docker run --rm -p 4318:4318 \
  -v $(pwd)/otel-collector.yaml:/etc/otelcol/config.yaml \
  otel/opentelemetry-collector:latest
.env
NUXT_OTLP_ENDPOINT=http://localhost:4318

OTLP Log Format

evlog maps wide events to the OTLP log format:

evlog FieldOTLP Field
levelseverityNumber / severityText
timestamptimeUnixNano
serviceResource attribute service.name
environmentResource attribute deployment.environment
versionResource attribute service.version
regionResource attribute cloud.region
traceIdtraceId
spanIdspanId
All other fieldsLog attributes

Severity Mapping

evlog LevelOTLP Severity NumberOTLP Severity Text
debug5DEBUG
info9INFO
warn13WARN
error17ERROR

Troubleshooting

Missing endpoint error

[evlog/otlp] Missing endpoint. Set NUXT_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_ENDPOINT

Make sure your endpoint environment variable is set and the server was restarted.

401 Unauthorized

Your authentication headers may be missing or incorrect. Check:

  1. The OTEL_EXPORTER_OTLP_HEADERS format is correct
  2. Credentials are valid and not expired
  3. The endpoint URL is correct

404 Not Found

The adapter sends to /v1/logs. Make sure your endpoint:

  • Supports OTLP HTTP (not gRPC)
  • Is the base URL without /v1/logs suffix

Logs not appearing

  1. Check the server console for [evlog/otlp] error messages
  2. Test with a local collector first to verify the format
  3. Check your backend's ingestion delay (some have 1-2 minute delays)

Direct API Usage

For advanced use cases:

import { sendToOTLP, sendBatchToOTLP, toOTLPLogRecord } from 'evlog/otlp'

// Send a single event
await sendToOTLP(event, {
  endpoint: 'http://localhost:4318',
})

// Send multiple events
await sendBatchToOTLP(events, {
  endpoint: 'http://localhost:4318',
})

// Convert event to OTLP format (for inspection)
const otlpRecord = toOTLPLogRecord(event)
Copyright © 2026