README
¶
Headers Setter extension
Status | |
---|---|
Stability | alpha |
Distributions | contrib |
Issues | |
Code Owners | @jpkrohling |
The headers_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 required:
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 thevalue
property of the extension configuration.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).
The value
and from_context
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_context
needs to themetadata_keys
of the batch processor. - Receivers must be configured with
include_metadata: true
so that metadata keys are available to the pipeline.
Configuration Example
extensions:
headers_setter:
headers:
- action: insert
key: X-Scope-OrgID
from_context: tenant_id
- action: upsert
key: User-ID
value: user_id
- action: update
key: User-ID
value: user_id
- action: delete
key: Some-Header
receivers:
otlp:
protocols:
http:
include_metadata: true
processors:
batch:
# Preserve the tenant-id metadata.
metadata_keys:
- tenant_id
exporters:
loki:
labels:
resource:
container_id: ""
container_name: ""
endpoint: https://localhost:<port>/loki/api/v1/push
auth:
authenticator: headers_setter
service:
extensions: [ headers_setter ]
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ loki ]
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFactory ¶
NewFactory creates a factory for the headers setter extension.
Types ¶
type ActionValue ¶
type ActionValue string
ActionValue is the enum to capture the four types of actions to perform on a header
const ( // INSERT inserts the new header if it does not exist INSERT ActionValue = "insert" // UPDATE updates the header value if it exists UPDATE ActionValue = "update" // UPSERT inserts a header if it does not exist and updates the header // if it exists UPSERT ActionValue = "upsert" // DELETE deletes the header DELETE ActionValue = "delete" )
type Config ¶
type Config struct {
HeadersConfig []HeaderConfig `mapstructure:"headers"`
}
type HeaderConfig ¶
type HeaderConfig struct { Action ActionValue `mapstructure:"action"` Key *string `mapstructure:"key"` Value *string `mapstructure:"value"` FromContext *string `mapstructure:"from_context"` }