Logging and Observability
NIM LLM and VLM provides structured logging, Prometheus-compatible metrics, and distributed tracing support to integrate with standard observability stacks.
Structured Logging
NIM outputs logs to stderr. The following environment variables control log behavior:
Set the Log Level
To set the log level, complete the following step. Set NIM_LOG_LEVEL when starting the container:
Default log output uses a human-readable format:
NIM_LOG_LEVEL controls both the NIM and the vLLM backend. If you need to override
the backend log level independently, set VLLM_LOGGING_LEVEL in addition to
NIM_LOG_LEVEL.
Enable JSON Lines Output
When NIM_JSONL_LOGGING=true, all log output from both the NIM and the vLLM
backend is formatted as one JSON object per line using a unified format.
This is recommended for production deployments where logs are ingested by a
collector such as Fluentd, Logstash, or CloudWatch.
To enable JSON Lines output, complete the following step:
Example JSON Lines output:
Both NIM and vLLM logs share the same JSON schema, so a single log parser configuration handles all container output.
Metrics
NIM exposes Prometheus-compatible metrics at the /v1/metrics endpoint.
To retrieve the metrics, run the following command:
Design Principle
NIM passes through the inference backend’s native Prometheus metrics without
modification. The metrics available at /v1/metrics are the same metrics
produced by vLLM, covering request latency, throughput, queue depth, token
counts, and GPU utilization. NIM does not wrap, rename, or abstract these
metrics, so existing vLLM dashboards and alerting rules work without changes.
For the full list of available metrics and their descriptions, refer to the vLLM production metrics documentation.
Prometheus Scrape Configuration
To scrape NIM metrics with Prometheus, add the following job to your prometheus.yml:
Distributed Tracing
NIM supports request correlation and distributed tracing through standard HTTP headers. The proxy layer forwards tracing headers from clients to the inference backend on the following inference endpoints:
/v1/chat/completions/v1/completions/v1/embeddings/v1/responses
Tracing headers are not forwarded on management or health endpoints.
X-Request-Id
Include an X-Request-Id header in your request to tag it with a correlation
identifier. NIM forwards this value to the backend, where the backend adopts
it as the internal request ID. If the header is not present, NIM does not add
one and the response does not carry an X-Request-Id.
When correlating logs across services, the X-Request-Id value appears in
backend log entries associated with that request because it is used as the
request identifier throughout the inference pipeline.
To stamp a custom request header into logs (for example a caller-supplied call
ID), pass an ASGI middleware class as the direct container argument
--middleware <import.path>. Use NIM_PASSTHROUGH_ARGS only when direct
container arguments are unavailable, as described in Advanced Configuration. NIM keeps redirect and request-id
outermost and installs your class innermost, so it can read any caller-supplied
X-Request-Id after NIM records it. Prefer X-Request-Id when a custom class
is not required.
--middleware is not currently supported in NIM with Dynamo deployments
(NIM_DYNAMO_SINGLE / NIM_DYNAMO_WORKER / NIM_DYNAMO_FRONTEND, including
DynamoGraphDeployment): the flag is stripped before dynamo.vllm starts, and
the frontend cannot install operator ASGI classes.
NIM echoes X-Request-Id on the response only when the caller supplied it
on the request. Requests that arrive without an X-Request-Id receive a
response without one; NIM does not synthesize a value.
W3C Traceparent
NIM forwards the
W3C Trace Context traceparent
header to the inference backend. If your application uses OpenTelemetry or
another W3C-compatible tracing system, include the traceparent header to
propagate trace context through NIM:
When OpenTelemetry tracing is enabled on the backend, this allows inference spans to appear in your existing distributed traces alongside upstream and downstream services.
NIM echoes the traceparent header back on the response only when the
caller supplied it on the request. Requests without an inbound traceparent
receive a response without one.
The proxy layer always forwards the traceparent header to the backend.
However, the backend only creates spans for inference requests when vLLM’s
--otlp-traces-endpoint argument is set. Without it, the backend logs a
warning and discards the trace context. Setting only the
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable exports startup and
compilation spans, not inference request spans. For details on configuring
OpenTelemetry in the backend, refer to the
vLLM OpenTelemetry documentation.
To export inference request spans, pass --otlp-traces-endpoint through
NIM_PASSTHROUGH_ARGS:
Setting NIM_PASSTHROUGH_ARGS replaces the value that the container sets by
default. If the model’s container already sets it, include those arguments as
well. For example, the NVIDIA-Nemotron-3.5-Super-VL-120B-A12B container sets
--chat-template /opt/nim/etc/chat_templates/nemotron-3.5-super-vl-reasoning-effort.jinja,
so pass
NIM_PASSTHROUGH_ARGS="--otlp-traces-endpoint http://<collector-host>:4317 --chat-template /opt/nim/etc/chat_templates/nemotron-3.5-super-vl-reasoning-effort.jinja".
Supported Tracing Headers
The following table describes the tracing headers that NIM forwards on inference endpoints:
Tracing headers are forwarded only on inference endpoints. Management
endpoints (/v1/metrics, /v1/models, and so on) and health endpoints do not
propagate tracing headers.
Related Topics
The following pages provide related architecture and configuration detail:
- Architecture for the health, metrics, and proxy layout
- Environment Variables for
NIM_LOG_LEVEL,NIM_JSONL_LOGGING, and related variables - Advanced Configuration for
--middlewareandNIM_PASSTHROUGH_ARGSwhen a custom request-id class is required