Loki label strategy for OpenBao

Use this explainer to choose safe Loki labels for OpenBao logs. It is for operators who need useful log routing and dashboard filters without indexing sensitive or high-cardinality audit fields.

Why this matters

Loki indexes labels, not full log line content. Good labels make log streams easy to route and query. Poor labels create too many streams, make queries expensive, and expose metadata that belongs in restricted investigation views.

OpenBao audit logs are especially sensitive because paths, request IDs, identity fields, token metadata, and client metadata can reveal how the secrets platform is used.

Label model

Use labels for stable source identity and routing. Use query-time parsing or structured metadata for investigation fields.

Stable labels
  -> choose stream and source
Log body or structured metadata
  -> inspect request-specific fields
Query-time parsing
  -> filter sensitive fields in restricted dashboards

Allowed labels

The stream contract allows these labels:

LabelUse
clusterOpenBao or platform cluster identity.
environmentEnvironment such as production or staging.
regionRegion or location.
namespacePlatform namespace when bounded and approved.
appApplication or workload source.
componentComponent such as openbao.
log_streamProject stream such as openbao.audit.
node_idOpenBao node identifier when bounded.
deployment_profileDemo, Kubernetes, VM, or production profile.
podPod identity when your Loki design allows it.
containerContainer identity.
instanceScrape or collector instance identity.

Keep the label set small. Do not add a label because one dashboard needs a temporary filter.

Forbidden labels

The stream contract forbids these labels:

LabelRisk
request_idUnbounded and investigation-specific.
request_pathReveals API, secret, auth, and mount usage.
secret_pathReveals secret naming and business context.
mount_pathReveals mount layout and can grow over time.
namespace_pathReveals tenancy structure.
client_tokenSecurity-sensitive token material.
token_accessorSecurity-sensitive token metadata.
entity_idSecurity-sensitive identity metadata.
auth_accessorSecurity-sensitive auth mount metadata.
client_ipHigh-cardinality and privacy-sensitive value.
remote_addressHigh-cardinality and privacy-sensitive value.
policyReveals authorization model details.
user_nameIdentity metadata.
display_nameIdentity metadata.

Parse these fields at query time in restricted dashboards instead.

Structured metadata

Loki supports structured metadata for data that you need alongside log entries without indexing it as labels. Use it only when your Loki version, schema, and tenant settings support it.

Structured metadata can help with metadata that is too high-cardinality for labels and too expensive to parse repeatedly. It does not remove the need for access control. Sensitive OpenBao fields still need restricted tenants, folders, and dashboards.

Query-time parsing

The generated audit dashboards parse audit JSON fields at query time.

Example pattern:

{log_stream="openbao.audit"}
  | json request_id="request.id", request_path="request.path"
  | request_id=~"${request_id:raw}"
  | request_path=~"${request_path:raw}"

This pattern keeps labels stable while still enabling request ID and path drilldown for approved users.

Label review checklist

Before you add a Loki label, confirm all of these conditions:

  • The value set is bounded for the full retention window.
  • The value does not reveal sensitive OpenBao usage patterns.
  • Multiple dashboards or alerts need the label.
  • Routing or access control benefits from indexing the value.
  • The value does not grow with requests, tokens, entities, clients, or paths.
  • The label is allowed by the stream contract.

If any condition fails, keep the value out of labels.

Common mistakes

  • Labeling every parsed JSON field.
  • Labeling request.path to make one dashboard faster.
  • Using token accessors or entity IDs in alert labels.
  • Treating demo cardinality as production cardinality.
  • Forgetting that labels can leak metadata even when audit values are HMACed.
  • Mixing audit and operational logs in the same log_stream.

What’s next

Source: Loki documents labels and low-cardinality guidance in the Grafana Loki label documentation . Loki documents structured metadata in the Grafana Loki structured metadata documentation . This page also reflects the repository stream contract in contracts/streams/log-streams.yaml.