For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Export logs over OTLP
Export agentgateway access logs as OTLP LogRecord objects to an OpenTelemetry Collector or any compatible backend.
Log export happens in addition to stdout output, so you can send logs to a collector without losing local visibility.
This guide walks through setting up an OpenTelemetry Collector to receive access logs from agentgateway.
Run the OTel Collector as a Docker container on the same host as agentgateway.
Create an
otel-collector-config.yamlfile that defines an OTLP receiver and a logs pipeline.cat > otel-collector-config.yaml << 'EOF' receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 processors: batch: exporters: debug: verbosity: detailed service: pipelines: logs: receivers: [otlp] processors: [batch] exporters: [debug] EOFReplace the
debugexporter with the exporter for your logging backend (for example, Loki, Elasticsearch, or an OTLP-compatible storage system).Start the OTel Collector container and mount your config file.
docker run -d --name otel-collector \ -p 4317:4317 \ -v $(pwd)/otel-collector-config.yaml:/etc/otelcol/config.yaml \ otel/opentelemetry-collector:latestConfigure agentgateway to send access logs to the collector.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config frontendPolicies: accessLog: otlp: host: localhost:4317Send a request through agentgateway, then check the collector output to verify that log records are arriving.
docker logs otel-collectorEach proxied request appears as a
LogRecordentry in the collector output. Look for a block that starts withLogRecord #and includes attributes such asgateway,http.method,http.path, andhttp.status.When you are done, remove the OTel Collector container.
docker rm -f otel-collector
Other configurations
Review other common configurations when exporting access logs to an OTLP-compatible backend.
Filter logs before export
You can filter which access logs are exported to your OTLP backend by setting the accessLog.otlp.filter field. When otlp.filter is not set, the top-level filter (frontendPolicies.accessLog.filter) is used as a fallback for OTLP export as well. When otlp.filter is set, it takes precedence over the top-level filter for OTLP export only, so you can send a different subset of logs to your OTLP backend than to stdout and the database.
The following example sends only error responses to the OTLP collector while logging all requests to stdout.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
frontendPolicies:
accessLog:
otlp:
host: localhost:4317
filter: 'response.code >= 400'The following example logs only error responses to stdout, the database, and the OTLP collector. Because no otlp.filter is set, the top-level filter applies to all three backends.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
frontendPolicies:
accessLog:
filter: 'response.code >= 400'
otlp:
host: localhost:4317The following example logs only error responses to stdout and the database, but sends all requests to the OTLP collector. To override the top-level filter for OTLP, set otlp.filter explicitly.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
frontendPolicies:
accessLog:
filter: 'response.code >= 400'
otlp:
host: localhost:4317
filter: 'true'Customize exported fields
You can add or remove fields to the log entry that you export to the OTLP endpoint.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
frontendPolicies:
accessLog:
otlp:
host: localhost:4317
fields:
add:
trace_id: 'request.headers["x-trace-id"]'
remove:
- http.host