Shipping NeMo Guardrails logs through the OpenTelemetry Collector

Route NeMo Guardrails logs through the OpenTelemetry Collector to Loki, Elastic or another backend, correlate them with traces and log the fields security review needs.

On this page

Why NeMo Guardrails logs need a shipping path before production

A team running a NeMo Guardrails server or the Python API has to be able to show which rails fired on a request and why, and that answer usually lives in the application logs rather than in the model output. Before production, decide where those logs go. Local files on a container are lost when the container is replaced, are hard to search across replicas, and give a security reviewer no reliable record of who could read them. A collector pipeline solves this by receiving logs from every guardrails instance, adding resource attributes such as service name and environment, and forwarding them to a backend your security team controls. Confirm with your own test deployment exactly which fields your NeMo Guardrails version emits before you write any parsing rules, because the log format is not something this page assumes.

NeMo Guardrails is an open-source library licensed under Apache 2.0, and the current release is 0.25.0, published on 19 November 2026 to PyPI. Using the library itself carries no license fee, but that does not settle the operating question. NVIDIA has sunset the NeMo Guardrails microservice container, so a team that deployed the microservice needs to decide whether its logging setup still applies to the library or to NVIDIA's newer NeMo Helix control plane, which runs guardrails as an inference gateway plugin. Check that path with your NVIDIA account team and your own architecture review before building a log pipeline around it.

This page covers how to route guardrail logs with the OpenTelemetry Collector to a backend such as Loki or Elastic, how to correlate those logs with traces, and what to record for a security review. It does not explain how to build rails or tune them. Treat the pipeline as part of the production design: name the owner of the backend, the retention period your policy requires, and who can read blocked-request content before the first deployment, since those answers shape the collector configuration more than the choice of exporter does.

How guardrail logs move from the server to the backend

The path starts at the NeMo Guardrails server or Python process, which writes logs to stdout or a file. An OpenTelemetry Collector inside the client's network receives them, applies redaction and attribute handling processors, and exports them to a log backend such as Loki or Elastic. Trace data follows a separate exporter to a trace backend. Check that the collector sits inside the trust boundary, that redaction runs before any export leaves it, and that log and trace records carry the same trace identifiers so they can be correlated.

Log records flow through the collector, while traces take a separate path.

Choosing between Loki, Elastic and other backends

Loki indexes labels rather than the full text of every log line, and it keeps compressed log chunks and its index in object storage. That design suits guardrail logs that are mostly searched by stream labels such as application, configuration or environment, with the content of each event read after a narrower query. The Loki documentation names Amazon S3, Google Cloud Storage and Azure Blob Storage as its recommended production object stores, and notes that S3-compatible stores such as MinIO and the local filesystem are supported but not typically recommended for production.

  • Licensing: Grafana Labs moved Loki from Apache License 2.0 to AGPLv3 in April 2021. Confirm with your legal team what AGPLv3 obligations mean if you modify Loki or expose it to outside users.
  • Deployment modes: Monolithic mode runs as a single binary for smaller volumes, simple scalable mode separates read, write and backend targets, and microservices mode serves very large clusters. Simple scalable mode is being deprecated and will be removed with Loki 4.0, so plan a different mode for a new build.
  • Retention: The compactor applies retention, and it is disabled by default, so logs persist until you set retention_enabled. Retention can be global, per tenant or per stream selector.
  • Authentication: Loki has no built-in authentication layer. Put an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it.
  • Shipping: Grafana Alloy, a vendor-neutral distribution of the OpenTelemetry Collector, is Grafana's supported log shipper for Loki.

Before you commit, confirm the Loki version you will run, the retention period your review policy requires and how the reverse proxy maps identities to the X-Scope-OrgID tenant header.

Collector pipeline options and when each fits

This table compares the common ways to get NeMo Guardrails logs into Loki or another backend, from a per-host agent to direct OTLP delivery. Read each row for the fit, the trade-offs and what the pattern requires you to run and secure.

PatternFit for guardrail logsTrade-offsWhat it requires
Agent collector per host or podGuardrails servers that write to stdout or files on hosts you manage, where you want local buffering and host metadata added close to the source.More collectors to configure and upgrade. Each agent needs its own credentials and config drift is easy to miss.A deployment pattern on each node (DaemonSet or host service), file or container log access, and a shared config source.
Gateway collectorSeveral guardrails deployments that should send logs through one controlled point for filtering, redaction and tenant routing.A single point of failure unless run highly available. Central redaction helps, but it does not replace limits on what the app logs.A reachable collector service, sizing for peak log volume, and a health check on the gateway itself.
Grafana Alloy as the Loki shipperTeams that want a supported Grafana log shipper with an OpenTelemetry-compatible base for Loki.Adds a Grafana-specific component to the pipeline. Check which Alloy components you need for your log format.Alloy installed where logs originate, a Loki push endpoint, and tenant headers if auth_enabled is true.
Direct OTLP over HTTP to LokiSmall deployments where the guardrails service can send logs itself and you want the fewest moving parts.Less buffering if the backend is slow or unavailable. Application retry behavior and loss handling need review.OTLP log export enabled in the app, a Loki endpoint that accepts OpenTelemetry logs, and an authenticating proxy in front of Loki.
Fluent Bit or FluentdHosts that already run Fluent Bit or Fluentd for other workloads and want guardrail logs in the same path.Adds a parsing layer that must map guardrail fields consistently. Trace correlation fields can get lost in conversion.A pipeline definition per source, parser rules for JSON logs, and a tested label scheme for Loki.

How to correlate guardrail logs with traces

Every guardrail log record should carry the trace ID and span ID of the request that produced it, so that a blocked request can be followed from the log line to the rail span that made the decision. Without those two fields, the log and the trace are separate records that an investigator has to match by timestamp and user, which is slow and unreliable under load. Decide early which application or guardrails server component writes the log lines and confirm that it reads the active OpenTelemetry context when it emits them. Then confirm the exact field names NeMo Guardrails writes for the version you run, because the emitted attributes can change between releases. Check this by sending one known blocked prompt in a test environment and comparing the log line with the span in your trace backend.

The OpenTelemetry Collector and the log backend must preserve those fields end to end. In the Collector, check that the logs pipeline does not drop or rename trace and span fields, and that any transform processor you add keeps them as structured attributes rather than folding them into the message text. In the backend, confirm that the trace ID is indexed or stored as a field you can query exactly, and that a link from a log line to the matching trace is configured in Grafana or your chosen tool. If you use Loki, identify trace IDs as structured metadata or fields, not as labels, because high-cardinality labels make the index expensive. Review the design with your platform team before you rely on it for an investigation.

Correlation is only as good as the span design behind it, so the rail span names, the LLM call spans and the attributes recorded on each one decide which blocked decisions you can follow. The sibling topic on OpenTelemetry tracing for NeMo Guardrails covers those choices. Plan both together, and agree with your security and compliance reviewers which block reasons, rail names and outcome fields must appear in the log line itself so that an analyst can read the decision without opening the trace. Keep the list of fields under version control with your Collector configuration so that an upgrade of NeMo Guardrails triggers a check of the correlation fields as part of the change.

Setting up the log pipeline step by step

This sequence takes a NeMo Guardrails deployment from a confirmed version to a Loki backend where a blocked request can be found by its trace identifier. Each step ends with a check, so the team can confirm the pipeline works before relying on it for security review. Config keys and field names should be confirmed against the release in use.

  1. Confirm the NeMo Guardrails version

    The platform team pins the NeMo Guardrails version it will run and confirms that the Python interpreter is 3.11, 3.12 or 3.13, which is the range that release 0.25.0 requires. The package is published to PyPI under Apache-2.0, so the team can install it with pip and record the version in its deployment inventory. If anyone has considered the NeMo Guardrails microservice from the NGC catalog, note that NVIDIA has sunset that container as of October 1, 2026, so the library or server from PyPI is the path to build on. Done when pip show nemoguardrails reports the pinned version and python --version returns a supported interpreter.

  2. Enable structured log export

    The engineer turns on log export in the guardrails server or in the application that imports the library, so each request writes structured records that carry a trace identifier. Configuration keys and environment variables depend on the release, so confirm them in the NeMo Guardrails documentation for the version you pinned before editing any file. Send records to standard output first, which keeps the collector step independent of the application code. Done when a test request to the guardrails server writes a JSON log line that includes the rail outcome and a trace identifier.

  3. Deploy the OpenTelemetry Collector

    The platform team deploys a collector that receives records from the guardrails process and forwards them to Loki. Grafana Alloy is a vendor-neutral distribution of the OpenTelemetry Collector and is Grafana's supported log shipper for Loki, so teams that already run Grafana often choose it. Teams that prefer a standard build can use the OTLP exporter over HTTP, because Loki accepts OpenTelemetry logs over HTTP. Choose a deployment pattern, such as a sidecar, a node agent or a gateway, based on how the team already runs workloads. Done when the collector starts, validates its configuration and reports a healthy status.

  4. Configure receivers, processors and exporters

    The engineer defines an OTLP receiver for application records, a batch processor to absorb bursts, resource attributes that name the service, environment and configuration version, and an exporter that points at Loki with the tenant header set. Before any prompt or response field reaches the pipeline, add a redaction or attribute filter and confirm that the chosen distribution includes it. Keep fields that support review, such as the rail name, the outcome and the trace identifier, and drop raw content unless the security owner has approved it. Done when the collector's own telemetry shows accepted records, successful exports and no dropped records.

  5. Deploy Loki on object storage with retention

    The team deploys Loki in a mode that matches its expected log volume. Monolithic mode, a single binary, is documented for up to about 20 GB of logs per day, and simple scalable mode is being deprecated and removed with Loki 4.0, so larger deployments should confirm the supported path with Grafana Labs or their support provider. Chunks and the index go to an object store, and Amazon S3, Google Cloud Storage and Azure Blob Storage are the recommended production options. Retention is disabled by default, so set retention_enabled and a retention period for each tenant or stream selector. Done when a test log is queryable and compactor logs show that retention is active.

  6. Put authentication in front of Loki

    Loki has no built-in authentication layer, so the team places an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it. With auth_enabled set to true, Loki operates as a multi-tenant system and expects an X-Scope-OrgID header on every request. The proxy should set that header from the verified identity, so clients cannot choose their own tenant. Give Grafana users and the collector separate credentials and tenants. Done when an unauthenticated request is refused, the collector's authenticated writes succeed, and a read from the security tenant returns only that tenant's records.

  7. Verify a blocked request and its trace

    The team sends a test prompt that a configured input rail should block, then searches Loki for the matching record. The record should carry the same trace identifier as the trace in the tracing backend, along with the rail that blocked the request and the outcome, so an investigator can move between the two signals. Field names can change between releases, so confirm them against the documentation for the pinned version and save the query for the review runbook. Repeat with an allowed prompt to confirm that only blocked requests produce a block record. Done when one search returns the blocked record and its trace identifier opens the matching trace.

What to log so security review can follow a decision

A reviewer who asks why a request was blocked or allowed needs a short chain of facts: which rail ran, what it decided, under which configuration, and who made the call. The cards below list the fields that let that chain be rebuilt from the Collector pipeline, and the checks to run before those fields reach a backend such as Loki or Elastic.

Rail name and type

Record which rail produced the decision and its category: input, dialog, retrieval, execution or output. A log line that says only "blocked" cannot show whether the user message, a retrieved chunk, a custom action or the model's answer triggered it. Use stable rail names taken from the configuration so that the same rail can be found again after a change. Check that the Collector keeps these as attributes rather than dropping them during parsing, since reviewers will filter on them first.

NeMo Guardrails docs

Decision and block reason

Log the outcome (allowed, modified or blocked) together with the reason the rail gave. Reviewers need this to separate a deliberate policy block from a failed safety model call that defaulted to a block, which is an availability problem rather than a policy event. Confirm with your own tests which reason strings your version emits, then map them to fixed values in the pipeline so that dashboards and alerts do not break when wording changes.

Configuration version

Attach an identifier for the guardrail configuration that was loaded, such as a version label from your configuration repository or a content hash of the config.yml folder. Without it, a reviewer cannot tell whether a decision came from the policy in force on that day or from a later edit. Record the NeMo Guardrails package version alongside it, since upgrades can change rail behavior, and keep the mapping between configuration versions and deployments in version control.

Timestamp and trace identifier

Keep the event time in UTC and include the trace ID and span ID from the active OpenTelemetry context. Correlation depends on these fields being present on every log record, not only on the trace itself. Check that the Collector preserves them when it sets resource attributes and that the log backend indexes the trace ID so a reviewer can jump from a blocked decision to the full request path.

Caller identity

Record which user, service account or application made the request, taken from the authenticated session at your gateway or application, not from text the user supplied. Pass a stable pseudonymous user identifier rather than an email address where your policy requires it. Confirm how identity reaches the guardrails server, because an unauthenticated internal caller will otherwise appear as a single shared account in every review.

Excluded and masked content

State in each log record which content was left out or masked, rather than logging the raw prompt or response by default. Raw prompts and responses carry personal data, and copies in a log backend are often kept longer and read by more people than the application database. Treat raw content as a separate decision governed by the content capture topic, with its own access and retention controls. Test the Collector processors that redact fields before you rely on them.

Questions teams ask before shipping guardrail logs

How much does it cost to ship guardrail logs through the OpenTelemetry Collector?

The cost depends mostly on the backend you choose and what your team already runs, not on the Collector itself, which is open source. Expect one-time costs for design, pipeline configuration, parsing and dashboards, and recurring costs for storage, compute, retention and on-call time. Storage grows with log volume, the fields you capture and how long you keep them, so ask for a quote that states the assumed daily volume, retention period and which backend and object store are in scope. Licensing also matters: Loki is licensed under AGPLv3, which your legal team should review against your use. Ask the partner to separate fixed-scope build work from any ongoing support.

How long does a pilot for guardrail log shipping take?

A pilot's length is driven by the number of log sources, the backend, and how many approvals you need before production data can flow. A single configuration with one backend and existing identity and access controls is a much smaller job than several guardrail configurations feeding a multi-tenant store with retention rules. The main schedule risks are agreeing which fields are logged, confirming how prompts and responses are handled, and provisioning the object storage and reverse proxy. Confirm the timeline in the written scope before work starts, and ask which milestones require your security or compliance sign-off.

What does the work need from our internal team?

You need named people who can decide, not only who can run commands. Typically that means a platform owner for the Collector and backend, a security reviewer who defines the log fields and retention, an identity contact for access to the log interface, and an application owner who can confirm which guardrail events matter. Your team should also provide the Python and Kubernetes or VM environment where NeMo Guardrails runs, the network paths between components, and the object storage. Agree on who receives alerts and who approves changes to the Collector configuration before the build starts.

Can our team build this without a partner?

Yes, if you have engineers who already operate OpenTelemetry pipelines and a log backend, and enough time to test redaction and access controls. The hardest parts are rarely the first pipeline. They are deciding which fields to capture, keeping prompts and personal data out of logs where policy requires, correlating log records with traces through shared identifiers, and proving retention and access rules work. A partner is most useful when those decisions are unfamiliar or when a security review is due soon. Compare the internal effort against the scope you would otherwise write, and use the same list of deliverables for both options.

Is Loki or Elastic the better backend for guardrail logs?

Choose Loki when you want label-indexed log storage on object storage with Grafana for queries, and Elastic when your team already runs Elasticsearch for full-text search and analytics. Loki's deployment modes scale from a single binary to larger simple scalable and microservices layouts, and it needs an authenticating reverse proxy in front of it because it has no built-in authentication layer. Elastic brings its own search and access features but a different operating model and licensing. Decide based on query patterns, the security team's tooling, retention needs and existing skills, and test both with a sample of your real guardrail events before committing.

What fields should guardrail logs capture for a security review?

Log enough to reconstruct a decision without storing sensitive content by default. Useful fields include a timestamp, a request or trace identifier shared with the traces, the configuration name, the rail type that fired, the outcome (allowed, blocked or modified), a reason code, the model or endpoint identifier, and the caller's authenticated identity. Keep raw prompts and responses out of the default pipeline and enable content capture only under a documented policy with retention and access limits. Ask your security reviewer to sign off on the field list before the pipeline is built, because that list becomes evidence for later reviews.

What breaks most often when logs and traces are correlated?

The most common failure is missing or inconsistent identifiers, so logs and traces cannot be joined during an investigation. Check that the trace and span identifiers are written into each log record, that the Collector does not drop or rename those fields, and that time zones and clock sources match across services. Also verify that multi-tenant backends receive the correct tenant header on every request, because a missing tenant identifier can send records to the wrong place or reject them. Test the join with a deliberately blocked request before you call the pipeline finished.

How DeployOpen scopes and supports guardrail logging

DeployOpen treats guardrail logging as part of the platform you run, not an add-on. We scope the log pipeline from NeMo Guardrails through the OpenTelemetry Collector to your chosen backend, then build, test and document it inside infrastructure you control.

How we scope

  • Written scope covers which guardrail events, block reasons and trace IDs get logged and where they are routed.
  • We confirm the target backend, retention needs and who in your organization may read guardrail logs.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • We identify which fields may contain personal data and agree redaction rules before any pipeline goes live.

How we build

  • We deploy and configure the OpenTelemetry Collector pipelines that receive, process and export guardrail logs.
  • We set up log-to-trace correlation so each blocked request can be followed across rails and model calls.
  • We test pipelines with sample blocked and allowed requests to confirm fields, labels and tenant routing behave as specified.
  • We verify that logs leave the application without raw prompt content unless your written policy allows it.

How we hand over

  • You receive configuration files, pipeline diagrams, a field dictionary and documented log retention settings.
  • Runbooks explain how to trace a blocked request from a log entry back to the rail that stopped it.
  • Access controls, authentication in front of the backend and audit logging settings are documented for your security review.
  • We walk your platform and security teams through the build so they can operate and review the pipeline themselves.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers for the logging pipeline.
  • Retainers can cover collector version upgrades and changes to NeMo Guardrails releases that alter log output.
  • We can rerun pipeline tests after configuration changes so evidence for reviewers stays current.
  • Ask in your quote which upgrade and retest work is included, and how change requests are priced and approved.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.