otel-logs-v0_9 in these examples).
Prerequisites
- A running Rootprint instance and its base URL — you’ll substitute it for
<your-rootprint>. - Node.js 18+ with
npm(the SDK needs nativefetchand top-levelawait). - An ingest API key scoped to your target index. In Settings → API keys, click Create ingest key, give it a name, and pick the index (
otel-logs-v0_9for the examples here). See API keys.
Setup
1
Install
- OTEL SDK
- Pino
- Winston
fetch and top-level await).2
Set environment variables
3
Minimal working example
- OTEL SDK
- Pino
- Winston
4
Verify in Rootprint
Open Search, filter on
service_name:my-node-service, and your record should appear within ~2 seconds.Structured logging
Attributes become log-record attributes on the OTEL side: searchable and filterable in Rootprint.Framework recipe: Express
Initialise the SDK once at process start, then log from anywhere. Keep the setup in a separate module (e.g.otel.js) and import it before your Express app.
Troubleshooting
- 401 / 403: the Bearer token is missing, malformed, or the
%20separator is not URL-encoded. Re-checkOTEL_EXPORTER_OTLP_LOGS_HEADERS. - Nothing in Search: the batch processor buffers records. For short-lived scripts call
await provider.forceFlush()(orawait provider.shutdown()) before exit. fetch is not defined: upgrade to Node.js 18+ or pass a polyfilled fetch to the exporter.- Pino transport not emitting:
pino-opentelemetry-transportreads theOTEL_*env vars itself; make sure they are set in the process that spawns the transport worker. - TLS errors against a self-signed endpoint: set
NODE_EXTRA_CA_CERTS=/path/to/ca.pem.
