Sending OpenTelemetry logs to Grafana Loki: when the Collector should write to Loki directly
If you already run Loki and want OpenTelemetry Collectors to be the single shipping path for logs, the Collector's otlphttp exporter can send logs to Loki's native OTLP endpoint. That is the decision this section helps you make. OpenTelemetry is not a storage or query backend. It defines how telemetry is generated, processed and exported, so Loki still stores the logs, indexes their labels and serves queries from Grafana. The Collector is the transport and processing layer in between.
Choose this path when your teams want one agent or gateway configuration for traces, metrics and logs, and when the Collector already handles the processing you need, such as redaction, filtering or routing. Grafana Alloy is Grafana's supported log shipper for Loki and is itself a distribution of the OpenTelemetry Collector, so the choice is less about capability than about who owns the configuration and which components your team operates. Promtail and other agents remain valid when your estate already uses them or when you need a specific collection feature the Collector distribution you plan to build does not include. Check the current component list and stability notes in the Collector documentation before you commit.
Before you choose, confirm three things in your own environment: the Loki version you run and whether its OTLP ingestion path matches your plan, whether auth_enabled is set (which determines whether every request must carry the X-Scope-OrgID header), and whether an authenticating reverse proxy sits in front of Loki, because Loki does not provide authentication on its own. Also decide which Collector distribution you will build. Official release artifacts are published with checksums and SBOMs, but you should still build with only the components you need, as the Collector security guidance recommends. These checks determine the rest of the configuration and should be settled before anyone edits an exporter block.
Log flow from applications through the Collector to Loki
The flow starts with applications emitting logs over OTLP to a Collector, which runs either as an agent beside workloads or as a gateway that receives from many sources. The Collector's otlphttp exporter sends logs to an authenticating reverse proxy, which is required because Loki has no built-in authentication layer. The proxy forwards requests to Loki, which identifies tenants with the X-Scope-OrgID header and writes compressed chunks and its index to object storage, while Grafana queries Loki for reads. Check the two trust boundaries: the application network to the Collector, and the proxy to the Loki tier.
Logs flow from applications through the Collector and an authenticating proxy into Loki, with Grafana querying back.
Exporter and tenancy options and when each fits
This table compares the main ways to get OpenTelemetry logs into Loki, along with the tenancy and authentication choices that come with each. Read each row as a decision: the option on the left is the one you would pick if the condition in the last column describes your environment. Confirm every otlphttp key against the current Collector exporter README and the Loki send data docs before you copy any configuration.
| Decision | Option | Trade-off | Choose it when |
|---|---|---|---|
| Shipping path | otlphttp exporter in the Collector | Keeps one OpenTelemetry pipeline for logs, metrics and traces, but you own the batching, retry and attribute mapping settings | Your Collectors already handle traces and metrics and you want one configuration model |
| Shipping path | Grafana Alloy | Grafana's supported log shipper for Loki, with Grafana-specific components, but a second agent to operate beside any existing Collector | Your team already runs Alloy or wants Grafana's supported path for Loki |
| Shipping path | Promtail | Familiar for classic Loki setups, but it is not an OpenTelemetry path and the Loki docs present it as one option among several | You have an existing Promtail estate and no near-term plan to move logs onto OpenTelemetry |
| Tenancy | Single-tenant (auth_enabled false) | Simplest to run and query, but no per-team isolation or per-tenant retention inside one Loki | One team or one trust boundary owns all logs in the cluster |
| Tenancy | Multi-tenant (auth_enabled true) | Every request must carry the X-Scope-OrgID header, so each Collector pipeline and each Grafana data source needs the right tenant value | Several business units or data classes need separate access and retention |
| Authentication | Basic auth through an authenticating reverse proxy | Loki has no built-in authentication layer, so the proxy in front of it becomes the access control point you must harden and monitor | You want a familiar, well-understood gate in front of Loki and can run the proxy with TLS |
| Authentication | oauth2client extension or another authenticator extension | Adds credentials to exporter requests inside the Collector, which suits token-based identity but needs the extension and its stability level checked | Your identity provider issues tokens and your Collector build includes the required extension |
| Label mapping | Resource attributes kept as Loki labels | Fast label-based selection, but high-cardinality values create many streams and hurt query and ingest performance | Attributes are few, stable and useful as stream selectors, such as service or environment |
| Label mapping | Resource attributes sent as structured metadata | Keeps stream count low while still allowing filtering on the value, with its own query and configuration behavior to test | Attributes vary per request or per pod and you still need to filter on them |
| Retention | Retention enabled in the compactor | Retention is off by default, so logs are kept until you set it, and rules can differ per tenant or stream selector | You have decided how long each tenant or data class must be kept |
How resource attributes map to Loki labels and structured metadata
Loki indexes only stream labels, so the decision about which OpenTelemetry resource attributes become labels shapes both query speed and storage cost. Everything else an attribute carries, such as a request ID, user ID or pod UID, can travel as structured metadata attached to each log entry without creating a new stream. The rule of thumb is that labels should have a small, bounded set of values that operators filter on, such as service name, namespace, environment or cluster. High-cardinality attributes should not become labels, because every unique combination creates another stream that the ingester must track and the index must hold. Confirm the current attribute-to-label rules in the Loki OTLP documentation for the exact Loki version you run, since the default mapping has changed across releases and should not be assumed.
Run a review before the pipeline goes to production. Export a sample of logs from the Collector with the debug exporter or a temporary file exporter, and list every resource attribute and log attribute that arrives, including those added by processors such as resourcedetection and k8sattributes. For each one, record its expected cardinality and the questions teams will ask of it. Mark the few attributes that qualify as stream labels and decide whether the rest should stay as structured metadata or be dropped with the attributes or transform processor. Then query the result in Grafana Explore against the Loki data source, filtering by each proposed label and by a structured metadata field, and confirm that the queries return the expected entries and that the number of active streams stays within what the team planned. Record the decisions in the pipeline configuration so the next change is reviewed against the same list.
Configure the Collector and Loki to accept OTLP logs
This sequence connects an OpenTelemetry Collector to Loki's native OTLP endpoint with tenant isolation and authentication in place. The result is a tested path where a log record leaves the Collector, passes through an authenticating proxy, and appears under the correct tenant in Grafana.
Enable authentication and tenancy in Loki
The Loki administrator sets
auth_enabled: truein the Loki configuration so that every request must carry anX-Scope-OrgIDheader identifying a tenant. Decide the tenant names before you start, because each Collector exporter will send one of them. Restart Loki with the change and confirm that a push request without the header is rejected, while a request with a test tenant header is accepted. Loki has no built-in authentication layer, so this step only controls tenant separation, not who may write.Deploy the reverse proxy that enforces authentication
Place an authenticating reverse proxy in front of Loki, such as nginx, HAProxy, OAuth2 Proxy or Pomerium, as the Loki authentication documentation requires. Configure it to require credentials on the push and query paths, terminate TLS, and forward the tenant header only for identities allowed to use that tenant. Confirm that an unauthenticated request to the OTLP logs path returns an authentication failure, and that the proxy reaches Loki on the internal network. Loki should not be reachable directly from client networks.
Create the Collector credentials and secret store entries
Create a dedicated username and password, or a token, for the Collector that is permitted to write only to its tenant through the proxy. Store the values in your secrets manager or as environment variables supplied at runtime, not in the Collector YAML file. Confirm that the Collector configuration file contains references to the secret rather than the value, and that file permissions restrict who can read it. The OpenTelemetry security guidance recommends secure storage of Collector configuration, so this check should be part of the review.
Configure the otlphttp logs exporter
In the Collector configuration, add an
otlphttpexporter underexporterswith the proxy endpoint, the Loki OTLP logs path, and anheadersblock that setsX-Scope-OrgIDto the tenant name. Add the credentials through theauthsetting, either a basic authentication extension or theoauth2clientextension, whichever matches your proxy. Wire the exporter into alogspipeline. Validate the file with the Collector's configuration check before deployment, and confirm that the exporter starts without errors in the Collector logs.Add the batch and resource processors
Add a
batchprocessor to the logs pipeline so records are sent in groups rather than one request at a time. Add aresourceprocessor to set or remove resource attributes that Loki will turn into labels, keeping label values to a small set such as service name, environment and namespace. Review the attributes that reach the exporter and remove any that carry personal or regulated data, using the redaction processor where needed. Confirm the final pipeline order is receivers, processors, then exporters, by reading the effective configuration.Send a test log through the debug exporter
Before enabling the production exporter, add a
debugexporter to the same logs pipeline and send one test record from an application or a telemetry generator. The debug output should show the record body, severity, and resource attributes exactly as the Collector will send them. Compare these attributes with the labels you expect in Loki, and correct the resource processor if any high-cardinality value would become a label. Remove or disable the debug exporter once the record content looks correct, since it can print sensitive data to logs.Query the tenant in Grafana
Add Loki to Grafana as a data source with the same tenant header configured, so Grafana queries only the intended tenant. Run a label query for the service name used in the test, and confirm that the test record appears with the expected labels and structured metadata. Then query from a second tenant and confirm the test record does not appear there. The test is complete when records appear under the correct tenant, isolation holds, and the exporter logs show no authentication or retry errors over a sustained run.
Securing the Loki OTLP path and the Collector
The OTLP path from the Collector to Loki carries log content that often includes credentials, personal data and internal hostnames, so it needs protection at both ends. Loki itself does not authenticate requests, so the controls below cover the proxy in front of Loki, the Collector that sends data and the configuration that holds the secrets.
Put an authenticating proxy in front of Loki
Loki has no built-in authentication layer, and its documentation says to run an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it. Decide which proxy your team will operate, then confirm that it terminates TLS, validates the credentials your Collector sends and forwards the X-Scope-OrgID header unchanged. Test that a request without credentials is rejected before you rely on the proxy.
Loki authentication docsAuthenticate the exporter to Loki
The otlphttp exporter can add credentials to outgoing requests, and the Collector authenticator extensions, such as oauth2client, handle token-based schemes. Use a dedicated service account for each Collector or pipeline so access can be revoked without affecting other senders. Keep the secret out of the configuration file itself, and confirm which auth method your chosen proxy accepts before you configure the exporter.
Protect the receiver with TLS and authentication
Apply the same discipline to the OTLP receiver that accepts telemetry from applications. Enable TLS on the receiver endpoint and use a Collector authenticator extension, such as OIDC, so only known senders can push logs. Without this, any host that can reach the port can write to your log tenants, which affects both data integrity and the audit trail.
Build the Collector with only needed components
Use the Collector Builder to compile a distribution that includes only the receivers, processors, exporters and extensions your pipelines use. A smaller binary has less code to patch and fewer components that can expose endpoints. Verify each component's stability level in its README before adopting it, because core components have mixed stability. Track the Collector release that you build against, and confirm the signed artifacts and SBOM for the version you deploy.
Redact sensitive attributes before export
Add the redaction processor to the logs pipeline so that tokens, card numbers, personal identifiers and similar attributes are removed before they reach Loki. Labels are indexed and read by many people, so a value that reaches a label is harder to remove later than one that stays in the log body. Test your redaction rules with sample records that contain real-format but fake values, and review what the Loki query interface shows.
Secure configuration and bind-address defaults
Store Collector configuration in a secrets manager or restricted file system path, and keep it encrypted at rest where your platform supports it. Since v0.110.0, server components bind to localhost by default, so any listener you open to other hosts is a deliberate change. Document each exposed port, its bind address and its authentication setting in your change record so reviewers can check them.
Collector best practicesRunning retention, tenants and upgrades after go-live
Retention in Loki is off until you turn it on. The compactor applies retention, and it is disabled by default, so logs accumulate indefinitely until retention_enabled is set to true in the compactor and limits configuration. Before go-live, decide the retention period for each class of log and write it down. Retention can be set globally, per tenant, or per stream selector, and each stream rule must be at least 24 hours. Confirm in your own environment how the compactor is deployed and that it has access to the object store, because a compactor that cannot run means retention silently does nothing. Check the Loki retention documentation for the exact keys for your Loki version, and test deletion on a non-production tenant before enabling it for regulated data.
Tenants are separated by the X-Scope-OrgID header, which Loki reads on every request once auth_enabled is true. Onboarding a tenant means agreeing on the tenant identifier, setting the header in the Collector's otlphttp exporter for that pipeline, and confirming that the authenticating reverse proxy in front of Loki maps each user or service account to the correct tenant so a client cannot choose another one. Per-tenant limits, such as ingestion rate, stream counts and retention, should be reviewed when a tenant is added and again when its volume changes. Ask your team to confirm which limits they need per tenant and who approves changes to them.
Plan upgrades on two separate tracks. Loki and the OpenTelemetry Collector each release on their own schedule, and the Collector has recently shipped new versions in quick succession, so pin versions and track release notes for both. Grafana follows its own schedule: major releases come once a year, minor releases every other month, and patch releases at least monthly, according to its upgrade guidance. Each minor release is supported for 9 months, and the last minor release of a major version for 15 months. Schedule a recurring review against those windows, and test each upgrade in a staging environment that mirrors your object store and reverse proxy configuration before production.
Questions teams ask before sending OpenTelemetry logs to Loki
What does this work cost, and what drives the effort up?
The cost is mostly the engineering time to configure the Collector, the Loki deployment, object storage, access control and Grafana access, so the effort depends on how many pieces you already have. The main drivers are the number of log sources, whether Loki is multi-tenant, how you will authenticate writes and reads, how you design labels, and how much retention you need. Loki's deployment modes range from a single monolithic binary, which the documentation sizes at up to about 20 GB of logs per day, to simple scalable and microservices layouts for larger volumes. Ask any partner for a quote that lists each source, the deployment mode, the object store, the auth proxy, the tenant model and the retention rules as separate line items, with one-time build work and recurring operations shown apart.
Can our team do this alone, and what skills does it need?
Yes, many teams can, provided they have people who can operate each layer. You will need Collector configuration experience for the otlphttp exporter, someone who can run Loki on object storage with its compactor and retention settings, and an engineer who can put an authenticating reverse proxy in front of Loki, since Loki has no built-in authentication layer. Grafana administration and basic identity integration are also needed to give teams query access. Teams without one of these skills often underestimate the auth and tenant work, which is where most access problems show up. A useful test is whether someone on your team can explain how a log line gets its tenant header and its labels from source to query.
How long does the work take, and what depends on existing pipelines?
Duration depends mostly on what already exists: an existing Collector deployment, a running Loki instance, an identity provider and object storage shorten the work, while building any of them first lengthens it. Ask for a timeline in the written scope, split into Collector changes, Loki and storage setup, the authenticating proxy, label and tenant design, and verification. If you already ship logs through Promtail, Fluent Bit or Grafana Alloy, plan how the switch to OTLP will run alongside those agents so logs are not lost or duplicated during cutover. No public duration is given here, so confirm the estimate against your own environment and your change calendar.
What do we need to provide before the work starts?
The work needs network paths from your Collectors to the Loki write endpoint, a decision on where Loki runs, and access to the object storage bucket Loki will use. It also needs your identity provider or credential source for the proxy in front of Loki, along with the team names and tenant IDs that will be mapped to X-Scope-OrgID. Expect to provide Grafana access for query testing and a list of log sources with their owners. Confirm with your security team which network zones may carry logs and whether logs contain personal or regulated data that must be redacted before export. Agree these inputs in writing so the scope reflects what you can actually provide.
Does Grafana Cloud or Grafana Enterprise change the picture?
Yes, the choice affects licensing, feature access and what you operate. Loki and Grafana are licensed under AGPLv3, which Grafana Labs adopted on April 20, 2021, and Grafana Enterprise is offered as a non-AGPL commercial option. According to the Grafana authentication docs, SAML, team sync, active sync and SCIM provisioning are available only in Grafana Enterprise and Grafana Cloud, so an identity requirement may decide the edition. Grafana Cloud has a free tier, a Pro tier that starts with a 19 US dollar monthly platform fee plus usage, and an Enterprise tier with a minimum commitment of 25,000 US dollars per year, according to the Grafana pricing page. Hosted options move operations to the vendor, so check data residency, retention and the audit evidence you need before choosing.
How should we handle tenants, authentication and label design?
Decide these before the first log is shipped, because changing them later means re-ingesting or accepting mixed data. Loki is multi-tenant when auth_enabled is true and identifies each tenant with the X-Scope-OrgID header on every request, so the Collector or the proxy must set that header consistently. Resource attributes become labels or structured metadata, so keep labels to low-cardinality values such as service and environment, and move high-cardinality fields into structured metadata. Use the Collector authenticator extensions, such as oauth2client for outgoing requests, to add credentials, and put an authenticating proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of Loki. Have a reviewer test a sample of records against the label list before rollout.
What should we check once logs are flowing?
Verify that each source arrives under the expected tenant, that labels stay within a small, agreed set, and that no sensitive fields reach Loki. Confirm the redaction processor removes the attributes your policy forbids, and that Collector configuration and credentials are stored securely, as OpenTelemetry's security guidance recommends. Check retention: it is disabled by default, so logs are kept indefinitely until retention_enabled is set, and each stream rule must be at least 24 hours. Test a query from each team's Grafana view and confirm that a user in one tenant cannot read another tenant's logs. Record these checks as evidence for your operations and compliance reviews.
How DeployOpen scopes and delivers Loki log pipelines
DeployOpen plans, builds and hands over the path that sends OpenTelemetry logs from your Collectors to Loki inside infrastructure you control. Each engagement starts from a written scope that sets the Loki deployment, tenancy model, authentication layer and Grafana access before any pipeline configuration is written.
How we scope
- Confirm which applications and hosts emit logs, and which Collector deployment pattern will forward them to Loki
- Agree the Loki deployment mode, object storage target and whether multi-tenant headers are required
- Define the authenticating reverse proxy, credential ownership and where the basic auth secret is stored
- Record retention requirements per tenant or stream and who approves them, in the written scope
How we build
- Configure the otlphttp exporter with the Loki endpoint, headers and authentication for each Collector tier
- Map resource attributes to Loki labels and structured metadata, keeping label cardinality under control
- Apply redaction processing to remove sensitive attributes before logs leave the Collector
- Test ingestion, tenant isolation and query results in Grafana against a staging environment before go-live
How we hand over
- Deliver the Collector configuration, exporter settings and label mapping documented for your team to review
- Provide the reverse proxy, secrets and retention settings with a record of who owns each item
- Document the verification steps and the known limits of the chosen deployment mode
- Walk your operations and security staff through the runbook and the upgrade path for Loki and the Collector
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing are available as a retainer
- Confirm with your team which version upgrades and retention changes will be handled under the retainer
- Ask for a quote built from the written scope, since DeployOpen does not publish a price list

