A destination is where an organisation’s telemetry is written: a
Prometheus remote-write endpoint (Mimir), a Loki push endpoint, or an OTLP endpoint. Org
admins manage them on the Destinations page. Wizards ship to them by name:
the destination a wizard step picks becomes that pipeline’s writer
(prometheus.remote_write or loki.write), including its
authentication.
Enter the full endpoint URL the collector writes to, for example
https://mimir.example.com/api/v1/push or
https://loki.example.com/loki/api/v1/push. Shepherd puts it into the writer
exactly as written and adds no path.
For a multi-tenant Mimir or Loki, set the destination’s Tenant ID.
Wizard pipelines that ship there send it as X-Scope-OrgID: as a header on
prometheus.remote_write, and as loki.write’s own
tenant_id. Leave it empty to send no tenant. It follows Mimir’s rule:
letters, digits and ! - _ . * ' ( ), at most 150 characters, no slashes or
spaces.
A new destination starts with your organisation’s default tenant. Any tenant your backend expects is allowed except one that belongs to another organisation in Shepherd — one of its tenants, or a tenant under one of its tenant prefixes, as an application administrator assigned them on Admin → Organisations. That is refused when you save, and refused again when a wizard pipeline is generated. A destination binding’s tenant follows the same rule. The other way round, an administrator cannot give an organisation a tenant or prefix covering a tenant another organisation’s destination or binding already sends.
This guards a destination’s tenant only. Unless the organisation is in
strict tenant mode, a pipeline you write by hand can set
any header, X-Scope-OrgID included, and Shepherd does not inspect it.
A pipeline picks up a tenant change when it is regenerated: saving a destination regenerates every wizard pipeline that names it. Until then the configuration collectors are served keeps the tenant it was generated with. A pipeline that ships to more than one destination is regenerated as a whole, so saving any one of them also starts sending a tenant already stored on the others.
In strict tenant mode, destinations, destination bindings, tenant routes
and pipelines may only use the organisation’s own tenants — one of its
exact tenants, or a tenant under one of its prefixes. A destination with no tenant is
still allowed. An application administrator turns it on for an organisation on
Admin → Organisations (Edit → Strict tenant mode), or
for every organisation with the server setting tenants.require_owned (chart
config.tenants.require_owned). Organisation admins cannot change it.
Turning it on is refused while the organisation owns no tenant, or while one of its
destinations, bindings, live tenant routes or enabled pipelines uses a tenant it
does not own; the refusal lists each one to fix. With
tenants.require_owned on, Shepherd refuses to start while anything in any
organisation breaks the rule, naming each object. Run
shepherd admin tenant-preflight before turning the setting on: it prints the
same list without starting the server.
Once it is on, the destination form offers only the organisation’s tenants, and a destination whose tenant the organisation stops owning is refused when a wizard pipeline is generated from it. Pipeline text is checked when it is saved, synced from git or enabled, and the rule is refuse what cannot be verified. Strict tenant mode refuses:
X-Scope-OrgID key in a
headers, http_headers or proxy_connect_header map;
loki.write’s and the rules components’ tenant_id;
loki.process’s stage.tenant value (also inside
stage.match); Loki’s __tenant_id__ label (which overrides
loki.write’s tenant per log line) in a labels map or a relabel rule;
an otelcol.auth.headers or otelcol.auth.bearer header named
X-Scope-OrgID;stage.tenant
reading a label or field, stage.labels or a relabel rule computing
__tenant_id__, an OpenTelemetry header copied from the request;$, and a labelmap rule whose replacement is
__tenant_id__. Any other labelmap that could write
__tenant_id__ (the default $1, or a replacement using
$) is allowed: Shepherd serves it with a rule right after it that drops
__tenant_id__, so the chart’s output works as written. Your stored
pipeline is not changed, and a later rule that sets the label to a tenant you own still
applies;loki.source.api, loki.source.heroku,
loki.source.awsfirehose or loki.source.gcplog — which pass
on the tenant the sending client names — unless every path from it to a
loki.write first overwrites __tenant_id__
(stage.static_labels, outside stage.match) or drops it
(stage.label_drop). otelcol.exporter.loki turns OpenTelemetry
attributes named by the loki.resource.labels and
loki.attribute.labels hints into Loki labels, __tenant_id__
included, so Shepherd serves it through an added loki.process
"shepherd_tenant_drop_<label>" that drops __tenant_id__ before
forwarding where you pointed it; the chart’s output works as written. Its
forward_to must be a list such as
[loki.write.<label>.receiver], and that component name must be
free;relabel_rules attribute (on loki.source.syslog,
loki.source.journal, loki.source.kafka and the other Loki
sources that take one) that is not a plain reference such as
loki.relabel.<label>.rules or
discovery.relabel.<label>.rules to a component in the same pipeline
or declare. Write the rules as rule blocks in a
loki.relabel component and refer to its rules: those are
checked, and rules written in place (a list or object, a function call, a
concatenation) are refused;external_labels,
a source’s labels, stage.static_labels’
values or faro.receiver’s
extra_log_labels must be written as a map
({ team = "a" }, where a value may be computed) or come from a module
argument given such maps. A map computed at runtime —
encoding.from_json(…), a file’s content, another
component’s export — could carry __tenant_id__ or
X-Scope-OrgID and is refused. Which attributes are label maps is read from
the component schemas;loki.enrich without a labels_to_copy list that leaves out
__tenant_id__: it copies its targets’ labels onto log lines.
Discovery targets passed to loki.source.file, .docker or
.kubernetes are fine as they are: those drop every label starting with
__;import.file and import.http modules, and an
import.git module unless it is pinned to a commit of an allowed repository
(below) — otherwise inline the module as a
declare or an import.string with literal content, which is
checked the same way. Imports are allowed only at the top level or directly in a
declare; one inside another block, such as a foreach
template, is refused;Components inside a foreach template are checked like any other; a module
argument given from inside a template cannot be read, so a tenant or label map taken from
it is refused. stage.regex and stage.pattern with
labels_from_groups = true need a literal expression with no group named
__tenant_id__, and a stage.truncate rule with
source_type = "label" needs a literal sources list without
__tenant_id__.
Only classified components. The checks above read a component’s
tenant settings attribute by attribute, so a strict organisation may use only components
whose tenant behaviour has been reviewed. Every component Shepherd ships a schema for is
classified: allowed (it cannot set a tenant label or header), checked (it
can, only through settings the checks above read) or refused (it can affect the
tenant in a way the check cannot prove; today only otelcol.auth.google, whose
token_header may name X-Scope-OrgID). A refused component, or one
Shepherd has no classification for, is refused wherever it appears — at the top level,
in a declare, in a foreach template or in a module — and the
message names it. Your own declare components are judged by what is inside
them. prometheus.exporter.blackbox is checked: its modules must be a literal
config that names no X-Scope-OrgID header and has no tcp
query_response (config_file is refused).
Gateway route endpoints. Shepherd’s tenant routes set the tenant
themselves: anything sent to the gateway under /otlp/<segment> arrives
under the route’s tenant, whatever name or address reached the gateway. So in a strict
organisation every exporter, writer, probe or other endpoint, on any host, whose path is under
a route segment must be under one of the organisation’s own tenant routes (active, or
deprecated while its rotation overlap lasts). Other services’ OTLP paths, such as
Grafana Cloud’s /otlp/v1/…, are not affected. Once any tenant route
exists, an endpoint written as anything but a literal — sys.env(…),
a component export, a value given in a foreach template — is refused
unless its literal part completes the path; module and declare arguments are
followed to the values they are given. Shepherd also knows the gateway’s host from
receiver.publicBaseURL, and any other name you list in
config.gateway.routes.hosts: on those hosts every endpoint must be one of the
organisation’s routes, and a proxy or Host header naming them is
refused.
config:
gateway:
routes:
hosts:
- edge-gateway.gateways.svc.cluster.local
An application administrator can allow one more component for an organisation on
Admin → Organisations (Edit → Admin-allowed
components): one of the shipped components classified refused. That lifts only this
refusal: every other check above still applies to
the component, and the page marks it admin-allowed, unreviewed. Both changes are
recorded in the audit log, and an entry cannot be removed while an enabled pipeline uses
the component. An allowed component may also need the collector’s
--stability.level: Alloy refuses a public-preview or experimental component
below its stability level and keeps the previous config, and Shepherd records a
collector.version_warning naming the flag.
Pipelines saved before a check was added are checked when they are
served. Every time a strict organisation’s collectors are given new config,
each enabled pipeline is checked as a save would check it. One that fails is left out of
every collector’s config and listed in the config’s header under
Excluded — strict tenant check with the reason; the pipeline page shows the
matched collectors as excluded, and the collector’s Reconciliation tab
names it. The pipeline stays saved and enabled: save a fix and it is served again. If the
check cannot finish in time, the collector keeps the config it had.
shepherd admin tenant-preflight lists exactly these pipelines. Each change is
recorded once in the audit log.
This is defence in depth, not the boundary: your backend’s own tenant authentication is. The check cannot see a tenant a proxy in front of the backend adds, or one passed some other way, such as a basic-auth username. What holds regardless is the rule on destinations, bindings and tenant routes.
A strict organisation can still use a module kept in a git repository, with
import.git, when two things hold:
revision is a full 40-character commit SHA, in
lower-case. Alloy follows a branch or a tag as it moves, so a branch, a tag, a short SHA
or no revision at all (Alloy then follows main) is refused. A commit cannot
change.repository is on the organisation’s allowed import
repositories. An application administrator keeps that list on
Admin → Organisations (Edit → Allowed import
repositories). A private repository names one of the organisation’s git
credentials (the ones git sync uses); a public one needs none.Shepherd then fetches the file at path at that commit when the pipeline is
saved, synced or enabled, and checks it with the same rules, nested
import.git modules included (up to 4 levels, each pinned and allowed the same
way). repository, revision and path must be plain
string literals, and path must name one file, in ASCII. Each fetch uses git
sync’s limits (gitsync.max_repo_bytes, max_file_bytes,
fetch_timeout); at most 4 fetches run at once, and one save — or one git
sync of a whole commit — spends at most 30 seconds fetching, so a slow repository
fails the save rather than holding it. Shepherd never follows a redirect to another host,
and refuses a commit that a branch or tag of the same name would shadow, and a path that
differs from another file only in case.
Collectors are served the module Shepherd checked. Alloy checks a
revision out as a tag first, so a tag pushed later under the commit’s
name could otherwise change what collectors run. For a strict organisation Shepherd
therefore never serves the import.git block: it serves an
import.string with the same label whose content is the module it fetched and
checked, nested modules included. Your pipeline text keeps the import.git you
wrote, and instances such as label.declare work unchanged. Collectors in a
strict organisation need no network access to module repositories. With the modules
inlined, a pipeline may be at most 1 MiB, like any other; validation, the role check and
the signals the editor shows all use the inlined form. Turning strict mode on or off
switches how the organisation’s collectors are served.
A repository matches its allowed entry however its URL is spelt, within these rules:
the scheme and host are compared in lower-case, a default port (443, 80, 22) is ignored,
git@host:owner/repo is the same as ssh://git@host/owner/repo, and
a trailing / or .git is ignored. The path’s case, the
scheme (http is not https), any other port and the SSH user are
significant. A URL with non-ASCII characters (write an internationalised host in its
xn-- form), percent-encoding, a query, a fragment, a password, credentials in
an https URL, or an empty, . or .. path segment is
refused, as is anything that is not an https, http or
ssh remote.
Each fetched module is kept, so it is never fetched again and later saves keep working if its repository goes away. A module an enabled pipeline uses is always kept; of the rest, each organisation keeps the 128 most recently used. An entry cannot be removed while an enabled pipeline of a strict organisation imports from it, and a git credential an entry uses cannot be deleted.
Shepherd never holds a telemetry backend’s credentials. For an authenticated
destination you name a Kubernetes Secret that already exists on every
cluster whose collectors ship there, and the collector reads it at runtime with
remote.kubernetes.secret. The served config contains the Secret’s
namespace, its name and the key names below, never the values.
| Auth mode | Keys the Secret must hold | What the writer gets |
|---|---|---|
| None | — | no auth block |
| Basic auth (Kubernetes Secret) | username, password |
basic_auth |
| OAuth2 (Kubernetes Secret) | client_id, client_secret, token_url |
oauth2 (client credentials) |
OAuth2 scopes are set on the destination itself (the OAuth2
scopes field, stored as extra.oauth2_scopes), not in the Secret. They are
not sensitive, and because Shepherd never reads the Secret it could not tell whether an
optional key is there.
Create the Secret in the namespace you name on the destination:
kubectl -n monitoring create secret generic mimir-credentials \
--from-literal=username=<user> \
--from-literal=password=<password>
A basic-auth destination named prom-prod pointing at that Secret gives a wizard
pipeline this writer:
remote.kubernetes.secret "metrics_auth" {
namespace = "monitoring"
name = "mimir-credentials"
}
prometheus.remote_write "metrics" {
endpoint {
name = "prom-prod"
url = "https://mimir.example.com/api/v1/push"
basic_auth {
username = convert.nonsensitive(remote.kubernetes.secret.metrics_auth.data["username"])
password = remote.kubernetes.secret.metrics_auth.data["password"]
}
}
}
For a backend behind a private CA, or one that requires a client certificate, open
TLS options on the destination. As with authentication, the certificates
stay on the spoke clusters: you name the objects, and the collector reads them at runtime
with remote.kubernetes.secret or remote.kubernetes.configmap. TLS
options need an https:// URL.
| Option | Object | Keys | What the writer gets |
|---|---|---|---|
| Trusted CA | a ConfigMap or a Secret | ca.crt, or the key you name | tls_config.ca_pem |
| Client certificate | a Secret | tls.crt, tls.key |
cert_pem, key_pem |
| Server name | — | — | server_name |
kubernetes.io/tls Secret, which
is what cert-manager writes. A cert-manager Secret also carries ca.crt, so it
can serve as both CA and client certificate; the collector then reads it once.Bundle target.kube-root-ca.crt ConfigMap in every namespace works as the CA when the
backend’s certificate was issued by the cluster CA.tls.crt or tls.key is caught
earlier — the collector refuses the whole config.The served config holds only the references and key names:
remote.kubernetes.configmap "metrics_tls_ca" {
namespace = "monitoring"
name = "backend-ca"
}
prometheus.remote_write "metrics" {
endpoint {
name = "prom-prod"
url = "https://mimir.example.com/api/v1/push"
tls_config {
ca_pem = remote.kubernetes.configmap.metrics_tls_ca.data["ca.crt"]
server_name = "mimir.internal.example"
}
}
}
The collector’s service account needs get on Secrets in the
Secret’s namespace: remote.kubernetes.secret reads the one named Secret
with a GET when the config loads and again every minute, and never lists or watches. The
Grafana Alloy Helm chart, and so k8s-monitoring’s collectors, grants Secret access
cluster-wide by default; check what your chart version grants for ConfigMaps. If your
collectors run with narrower RBAC, grant it in that one namespace. A destination whose CA
is in a ConfigMap needs get on configmaps in that namespace
(remote.kubernetes.configmap reads the same way) — the second rule
below. The first rule also grants list and watch, which are
not needed:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: alloy-read-destination-secrets
namespace: monitoring
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: alloy-read-destination-secrets
namespace: monitoring
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: alloy-read-destination-secrets
subjects:
- kind: ServiceAccount
name: <collector service account>
namespace: <collector namespace>
Shepherd’s Kubernetes test suite runs a real Alloy with this Role’s Secret rule and checks that its remote-write requests carry the Secret’s credentials.
The writer, auth block included, is generated when a wizard is previewed or committed. It is stored as part of the pipeline, so it passes the same validation as any other line and shows in the editor and its revision history. A wizard that names a destination the organisation does not have, or one of the wrong type, is refused with a message saying which.
Saving a change to a destination regenerates every wizard pipeline in the organisation that ships to it, from the answers stored with the pipeline, in the same step. Each regenerated pipeline passes the full validation gate, gets a new revision and an audit entry under your name, and collectors receive it on their next poll; the confirmation says how many were regenerated (Destination updated — 3 pipelines regenerated). Renaming a destination renames it in those pipelines too. If any of them would fail validation, nothing is saved and the message names the pipeline, the reason and what to do; each pipeline it names links to its page. The same happens when one of them was edited by hand after its wizard generated it: Shepherd never overwrites the edit. Such a pipeline is badged Not following wizard in the pipelines list and Hand-edited in its header, and the editor asks before the save that makes it one (Save a hand edit?). Open the pipeline and do one of three things, then save the destination again:
Running the wizard again does not help: it creates a new pipeline.
Shepherd recognises a hand edit by a fingerprint of the text the wizard last wrote, so a newer version of a wizard does not make older pipelines look edited. A wizard pipeline generated before that fingerprint existed is compared with what its wizard would generate today instead, until its next regeneration records one. If that wizard has changed since, such a pipeline reads Not following wizard although nobody edited it, and Restore last wizard version offers its current revision, which re-attaches it.
A destination a wizard pipeline still ships to cannot be deleted. The refusal lists the pipelines, each linked to its page; detach them from the wizard, or delete them, first.
Wizard pipelines committed before destination auth was rendered read their URL from
sys.env("SHEPHERD_DEST_<NAME>_URL"), which nothing sets, and carry no
auth. Convert them once with shepherd admin rerender-destinations, run with
the server's own configuration, --dry-run first:
kubectl -n shepherd exec svc/shepherd -- /usr/local/bin/shepherd admin rerender-destinations \
--config /etc/shepherd/shepherd.yaml --dry-run
It lists every pipeline it converts and every one it cannot (for example, one naming a destination that was deleted), and is safe to run again. Saving a destination also regenerates the pipelines that use it.
A destination’s tenant ID was stored but not sent before Shepherd rendered it. Such a
tenant reaches a pipeline when the pipeline is next regenerated, which moves that data into
the named backend tenant. To see which destinations carry a tenant and which pipelines would
change, run the same command with --all; it writes nothing until you add
--apply, and never overwrites a pipeline edited by hand:
kubectl -n shepherd exec svc/shepherd -- /usr/local/bin/shepherd admin rerender-destinations \
--config /etc/shepherd/shepherd.yaml --all