I’m running a multi-tenant Loki setup and sending logs through Grafana Alloy.
I need Alloy to set the X-Scope-OrgID header dynamically so that each log stream is stored under the correct tenant. Specifically, I want the tenant id to be built from a log label: environment:
So if a log has environment=prod, the tenant should be prod.
I’ve seen that Alloy’s loki.write component has a tenant_id field, but it only accepts a static string. I also came across stage.tenant in loki.process, which looks like it might support assigning the tenant from labels.
Question: How can I configure Alloy so that the tenant id is created dynamically from log label (environment) and sent to Loki as X-Scope-OrgID?