Skip to main content
This page tails nginx’s access and error logs and ships them to Rootprint over OTLP with the OpenTelemetry Collector or Vector. Records land in otel-logs-v0_9 with service.name: nginx, and access-log fields arrive as OpenTelemetry HTTP attributes.

Prerequisites

  • A running Rootprint instance. Substitute its host for <your-rootprint>.
  • An ingest API key scoped to otel-logs-v0_9. Create one in Settings → API keys with Create ingest key, then substitute it for <your-ingest-api-key>. See API keys.
  • nginx writing its stock combined access log to /var/log/nginx/access.log and its error log to /var/log/nginx/error.log. These are the Debian/Ubuntu defaults, and no nginx.conf changes are needed.
  • The OpenTelemetry Collector or Vector installed on the nginx host. The agent pages cover installation.
1

Write the agent config

Replace <your-rootprint> and <your-ingest-api-key>.
Save this as /etc/otelcol-contrib/config.yaml.
The Collector config (start_at: end) reads only lines written after each start, so it skips lines written while it was stopped. Vector (read_from: end) skips existing lines on first start only, then resumes from its checkpoint.
2

Grant read access to /var/log/nginx

Set AGENT_USER to the user your agent runs as, then run the lines for your distro. On RHEL, Fedora, and Amazon Linux the logs are nginx:root with mode 0640, so grant access with ACLs.
The default ACL (-d) covers files logrotate creates later.
3

Restart the agent

Run sudo systemctl restart otelcol-contrib or sudo systemctl restart vector. The agent’s log should show no config or exporter errors.
4

Send a test request

Hit any site nginx serves:
5

Verify in Rootprint

Open Logs, pick otel-logs-v0_9 from the index selector, and search for service_name:nginx. Records typically appear within 5–10 seconds.

What you get in Rootprint

Access-log entries get the HTTP attributes below, and error-log entries get process and connection attributes. nginx.format tells the two apart.
  • Log level: access-log entries are always INFO, because the combined format has no level. Search on http.response.status_code to find server errors. Error-log levels map to DEBUG, INFO (info, notice), WARN, ERROR, and FATAL (crit, alert, emerg).
  • Timestamp: taken from each log line, with the agent’s read time as a fallback.
  • Error-log context: Vector also extracts client.address, server.address, nginx.server, and nginx.upstream from error lines. The Collector leaves them in body.

Useful searches

Troubleshooting

  • body is a raw nginx line and access entries have no http.* attributes: nginx.conf sets a custom log_format. The parsers expect the stock combined format. Remove the custom format or extend the parser.
  • 401/403/413/415: see Response codes.