Headerssetter Extension
contrib, k8s
Maintainers: @VihasMakwana
Source: opentelemetry-collector-contrib
Overview
Theheaders_setter extension implements ClientAuthenticator and is used to
set requests headers in gRPC / HTTP exporters with values provided via
extension configurations or requests metadata (context).
Use cases include but are not limited to enabling multi-tenancy for observability
backends such as Tempo, Mimir, Loki and others by setting the X-Scope-OrgID
header to the value extracted from the context.
Configuration
The following settings are available:-
additional_auth(Optional): The ID of another auth extension to chain with. When specified, this extension will call the additional auth extension first, then apply its own headers on top. This allows combining multiple authentication methods, such as OAuth2 for authorization and custom headers for additional metadata. -
headers: a list of header configuration objects that specify headers and their value sources. Each configuration object has the following properties:key: The header name.action(default:upsert): An action to perform on the header. Supported actions are:insert: Inserts the new header if it does not exist.update: Updates the header value if it exists.upsert: Inserts a header if it does not exist and updates the header if it exists.delete: Deletes the header.
value: The header value is looked up from thevalueproperty of the extension configuration.value_file: The header value is read from a file. The file is watched for changes and the header value is automatically updated when the file changes. This is useful for credentials that are rotated, such as Kubernetes secrets.default_value: (Optional) Value used if no entry for header key specified infrom_contextis present in request metadata.from_context: The header value is looked up from the request metadata, such as HTTP headers, using the property value as the key (likely a header name).from_attribute: The header value is taken from the request’s authentication data, may include attributes likesubjectandmembership.
value, value_file, from_context,default_value and from_attribute,default_value properties are mutually exclusive.
In order for from_context to work, other components in the pipeline also need to be configured appropriately:
- If a batch processor is present in the pipeline, it must be configured to preserve client metadata.
Add the value which
from_contextneeds to themetadata_keysof the batch processor. - Receivers must be configured with
include_metadata: trueso that metadata keys are available to the pipeline.
Configuration Example
File-Based Credentials Example
Thevalue_file option allows reading header values from files, which is useful
for credentials that are rotated, such as Kubernetes secrets or other dynamic
credentials:
Chaining with other Auth Extensions
Theheaders_setter extension can be chained with another authentication extension
using the additional_auth parameter. This allows combining multiple authentication
methods, such as OAuth2 for bearer token authentication and custom headers for
additional metadata or routing information.
Example: Combining OAuth2 and Custom Headers
- The
oauth2clientextension provides OAuth2 bearer token authentication - The
headers_setterextension adds custom headers on top of the OAuth2 authentication - When the exporter sends data, both authentication methods are applied:
- OAuth2 adds the
Authorization: Bearer <token>header - Headers setter adds
X-Scope-OrgIDandX-Custom-Headerheaders
- OAuth2 adds the
- The collector ensures the
oauth2clientextension starts beforeheaders_setterdue to the dependency relationship
Configuration
Example Configuration
Last generated: 2026-04-13