README
ΒΆ
LGTM LBAC Proxy
Label-Based Access Control for the LGTM Stack (Loki, Grafana, Tempo, Mimir/Prometheus)
π’ Notice
Origin and Acknowledgments
This project originated from multena-proxy by Gepardec, which provided the foundational architecture for multi-tenancy proxy with label-based access control.
Original Repository: https://github.com/gepaplexx/multena-proxy
We extend our sincere gratitude to the Gepardec team for their pioneering work in bringing label-based access control to observability stacks. Their original implementation established excellent patterns that influenced our approach.
Why an Independent Project?
LGTM LBAC Proxy has evolved as an independent project with significant architectural changes and new capabilities that go beyond the original scope:
Core Philosophy Differences
| Aspect | Original (multena-proxy) | This Project (lgtm-lbac-proxy) |
|---|---|---|
| Target Stack | OpenShift + Thanos/Loki | Complete LGTM stack (L+G+T+M) |
| Tracing Support | β Not implemented | β Full TraceQL enforcement |
| Label Model | Single-label per user | Multi-label policies with operators |
| Label Storage | MySQL + ConfigMap | File-based (ConfigMap) only |
| Configuration | Fixed auth claims | Configurable JWT claims for any OAuth provider |
| Performance | Standard reverse proxy | Optimized with connection pooling (1000-2000 req/s) |
| Architecture | Simple label mappings | Policy-based with AND/OR logic |
| Development | Upstream maintenance | Independent feature development |
Major Enhancements & Breaking Changes
New Capabilities (not in original):
- β Grafana Tempo Integration: Complete TraceQL query enforcement with resource attribute injection
- β Multi-Label Enforcement: Support multiple labels per user (namespace AND team AND environment)
- β
Flexible Operators: Exact match (
=), regex (=~), negation (!=,!~) - β Policy Logic: AND/OR combinations for complex access rules
- β Configurable JWT Claims: Support any OAuth provider (Keycloak, Azure AD, Auth0, Google, Okta)
- β High-Performance Proxy: Dedicated transports with connection pooling and per-upstream tuning
- β Production Helm Chart: Full Kubernetes deployment with HPA, security contexts, and ServiceMonitor
Architectural Changes (breaking compatibility):
- π Removed MySQL Label Store: File-based ConfigMap only (v0.9.0)
- π Removed Simple Label Format: Extended format with
_rules/_logicrequired (v0.12.0) - π New Label Store Interface:
GetLabelPolicy()instead ofGetLabels() - π Policy-Based Enforcement: Rules and operators instead of simple key-value labels
When to Use Each Project
Use multena-proxy if you need:
- OpenShift-specific integrations
- Simple single-label enforcement (namespace only)
- MySQL label storage
- Minimal changes to existing deployments
Use lgtm-lbac-proxy if you need:
- Complete LGTM stack support (Loki + Grafana + Tempo + Mimir)
- Distributed tracing with Grafana Tempo
- Multi-label policies (namespace + team + environment)
- High-throughput production deployment (1000+ req/s)
- Flexible OAuth provider integration
- Advanced access control with regex and negation
Compatibility Notice
β οΈ Not a Drop-In Replacement: This project has diverged significantly from multena-proxy with breaking changes:
- Configuration format changes (extended label format required)
- Different label storage mechanism (no MySQL support)
- New authentication configuration structure
Migration from multena-proxy requires configuration updates. See MIGRATION.md for detailed instructions.
Overview
LGTM LBAC Proxy is a multi-tenancy authorization proxy designed specifically for the LGTM observability stack. Built with Label-Based Access Control (LBAC) at its core, it ensures secure and granular access to your observability data.
The proxy intercepts queries to Prometheus/Thanos, Loki, and Tempo, validates JWT tokens, enforces tenant label restrictions, and forwards authorized queries to upstream servers.
Key Features
| Feature | Description |
|---|---|
| Complete LGTM Stack | Full support for Metrics (Prometheus/Thanos/Mimir), Logs (Loki), and Traces (Tempo) |
| Multi-Label Policies | Enforce multiple labels per user with AND/OR logic (namespace AND team AND environment) |
| Flexible Operators | Support for exact (=), regex (=~), not-equal (!=), and negative regex (!~) matching |
| Configurable JWT Claims | Compatible with any OAuth provider - configure username, email, and groups claims |
| High-Performance Proxy | Handle 1000-2000 req/s with connection pooling and per-upstream optimization |
| Query Enforcement | Automatic injection of tenant filters into PromQL, LogQL, and TraceQL queries |
| TraceQL Support | Full distributed tracing support with Grafana Tempo integration |
| File-Based Label Store | Simple and portable ConfigMap/file-based label storage (no database required) |
| Admin Bypass | Optional admin group with #cluster-wide access for unrestricted queries |
| Production-Ready Helm Chart | Kubernetes deployment with HPA, security contexts, and ServiceMonitor |
| Secure Communication | JWT/JWKS authentication with mTLS support for upstream connections |
| OAuth Provider Support | Pre-configured examples for Keycloak, Azure AD, Auth0, Google, and Okta |
Currently Supported
- β Metrics: Prometheus, Thanos, Mimir (PromQL enforcement)
- β Logging: Loki (LogQL enforcement)
- β Traces: Tempo (TraceQL enforcement) π
- β Alerting: ruler rules/alerts + Alertmanager API (group-based access) π
- β OTLP ingest: token-authenticated OTLP/HTTP write gateway (opt-in) π
- β³ Profiles: Planned for future release
The ruler and Alertmanager endpoints return whole rule groups, alert instances and
silences rather than a query, so there is no expression to rewrite and no per-tenant
scoping to apply. They are gated by group membership instead β viewer_groups may read,
admin_groups may additionally create and expire silences and write the Alertmanager
configuration β and are off unless alerting.enabled is set:
alerting:
enabled: true
viewer_groups: ["alert-viewer"]
admin_groups: ["alert-admin"]
alertmanager:
url: "http://mimir-gateway.monitoring.svc.cluster.local"
path_prefix: "/alertmanager" # "" for a standalone Alertmanager
A caller in none of those groups reads an empty result set from the rules endpoints rather than an error, so a UI that loads them unprompted renders clean.
The ruler's configuration API is proxied for GET only β a UI needs it to open a
single rule group, since listing groups and opening one are different endpoints β while
the write methods stay unrouted, so rules remain read-only. The Cortex/Mimir
Alertmanager's configuration API is not proxied at all, keeping contact points and the
routing tree as-code. Point Grafana's Alertmanager data source at
<proxy>/alertmanager with implementation: prometheus, which asks for exactly the
/api/v2/* endpoints above; the mimir implementation additionally requests the
configuration API at /api/v1/alerts on the root, where it would collide with the
ruler's endpoint of the same name.
Prometheus health endpoints
GET/HEAD /-/healthy and /-/ready are answered on the proxy port (and the mTLS
port, which serves the same router) for clients that treat the proxy as a Prometheus
server and probe its health before querying. Some refuse to query at all without a
200 from /-/healthy β the MinIO console's dashboard is one.
As in Prometheus they report liveness of the proxy process only: no credentials are
required, no upstream is called, and they share /healthz's state (500 once a
configuration reload has failed). Every query is still authenticated and enforced.
OTLP write gateway
An optional, separate listener accepts OTLP/HTTP pushes from callers holding a token,
and forwards them to an OTLP receiver with the caller's identity attached. It is off
unless ingest.enabled is set, and it serves only:
| Route | Purpose |
|---|---|
POST /v1/metrics, POST /v1/logs, POST /v1/traces |
OTLP/HTTP push, each only when that signal has an upstream |
GET /healthz |
Unauthenticated health probe for an edge or load balancer |
No read route is served on it. How a push is handled:
- JWT only. The token is validated as on the read path (JWKS,
issuer,audiences). Client certificates and the trusted CN header are not identities on this listener. - Writer resolution.
writersmaps a group from the token's groups claim to a writer id. Exactly one distinct id must match. A caller whose groups map to two different ids is refused, and the admin group is not a writer unless listed. - Forwarding. The body is streamed to the signal's upstream unchanged
(
Content-TypeandContent-Encodingpass through, capped atmax_body_bytes). The writer id is sent inwriter_header, replacing any value the client set. The caller's token is not forwarded. The upstream's status and body come back as-is.
The upstream is expected to derive tenancy from the writer header, so it must be reachable only through the gateway, for example a receiver port that a NetworkPolicy admits from the gateway's pods alone. Anything that can reach it directly can claim any writer.
ingest:
enabled: true
port: 8444
server_cert: /etc/secrets/ingest/tls.crt
server_key: /etc/secrets/ingest/tls.key
writer_header: X-Ingest-Writer # default
max_body_bytes: 5242880 # default; the receiver bounds decompressed size
writers:
otlp-writer-app-a: app-a
otlp-writer-app-b: app-b
metrics:
url: http://otel-gateway-receiver.observability.svc:4320 # /v1/metrics is appended
logs:
url: http://otel-gateway-receiver.observability.svc:4320
# traces: { url: ... } # unset = not routed (404)
Upstream options.
A multi-tenant backend can take the writer id as its tenant directly, with no receiver
config. For example, set writer_header: X-Scope-OrgID and point the signals at a
multi-tenant Mimir, Loki or Tempo distributor's OTLP endpoints (e.g.
http://mimir-distributor:8080/otlp).
An OpenTelemetry Collector or Alloy receiver can turn the header into resource
attributes. Copy it from client metadata, drop anything that arrives without it, and
set service.name. In Alloy:
otelcol.receiver.otlp "gateway" {
http {
endpoint = "0.0.0.0:4320"
include_metadata = true // makes request headers available as metadata.*
}
output { metrics = [otelcol.processor.attributes.writer.input] }
}
otelcol.processor.attributes "writer" {
action {
key = "ingest.writer"
from_context = "metadata.x-ingest-writer"
action = "upsert"
}
output { metrics = [otelcol.processor.filter.writer.input] }
}
// Fail closed: no writer header, no data.
otelcol.processor.filter "writer" {
metrics { datapoint = [`attributes["ingest.writer"] == nil`] }
output { metrics = [otelcol.processor.transform.writer.input] }
}
otelcol.processor.transform "writer" {
metric_statements {
context = "datapoint"
statements = [
`set(resource.attributes["service.name"], attributes["ingest.writer"])`,
`delete_key(attributes, "ingest.writer")`,
]
}
output { metrics = [/* your tenancy stamping and exporters */] }
}
Logs follow the same shape, using the log context and filtering on log_record.
Attributes the receiver derives tenancy or labels from belong in that pipeline too,
deleted or overwritten. That is receiver policy, not the gateway's.
Deployment layouts. The Helm chart supports both:
- Co-located: set
ingest.enabledon the read release. One set of pods serves both paths. - Separate (recommended when the ingest listener is widely reachable): install a
second release of the chart with
ingest.enabled: true,ingest.only: trueand its ownnameOverride, and leave ingest disabled on the read release. An ingest-only release has no read routes, read listeners, label store or read RBAC, so the pods writers can reach hold no read access.
# values for the ingest-only release
nameOverride: lgtm-lbac-write
ingest:
enabled: true
only: true
metrics: { url: http://otel-gateway-receiver.observability.svc:4320 }
logs: { url: http://otel-gateway-receiver.observability.svc:4320 }
writers: { otlp-writer-app-a: app-a }
serverSecretName: lgtm-lbac-write-tls
serverCertificate:
enabled: true
dnsNames: ["otlp.example.com"]
issuerRef: { name: example-issuer }
loadBalancer:
enabled: true # a LoadBalancer exposing only the ingest port
auth:
jwksCertUrl: https://login.example.com/keys
claims: { groups: groups }
issuer: https://login.example.com/
audiences: ["api://lgtm"]
Clients. Any OTLP/HTTP exporter that can send a bearer token works: OTel SDKs,
collectors (bearertokenauth / oauth2client), Alloy (otelcol.auth.oauth2). Tokens
expire, so use a mechanism that refreshes them. For example, Claude Code / the Claude
Agent SDK:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://otlp.example.com/v1/metrics
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://otlp.example.com/v1/logs
# Prometheus-style backends store cumulative series; delta metrics may be dropped
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
# plus "otelHeadersHelper" in settings.json printing {"Authorization": "Bearer <token>"}
Metrics on the metrics port:
lgtm_lbac_proxy_ingest_requests_total{writer,signal,code,edge}lgtm_lbac_proxy_ingest_request_bytes_total{writer,signal,edge}lgtm_lbac_proxy_ingest_rejected_total{signal,reason,edge}, where reason is one ofunauthenticated,no_role,ambiguous_role,too_large,upstream_error
Edges (optional). When the gateway is published through more than one path (for
example on an internal load balancer and through a CDN or tunnel), edges says which
path each push took. A push carrying an edge's marker header is labelled with that
edge's name in the metrics above, refusals included. Anything else is direct. With
edge_header set, the upstream also receives the edge name, overwritten like the writer
header:
ingest:
edges:
- name: cloudflare
header: Cf-Ray # added by Cloudflare to every forwarded request
client_ip_header: Cf-Connecting-Ip # optional; logged with the push at debug level
edge_header: X-Ingest-Edge # optional; unset = not forwarded
sum by (writer, edge) (rate(lgtm_lbac_proxy_ingest_requests_total[5m]))
A direct client could send the marker header itself, so the edge is for observing traffic, not for access decisions.
The listener's HTTP metrics carry the ingest_ prefix.
Static keys (optional)
Some callers cannot obtain an expiring token:
- SaaS exporters that only take fixed headers
- a Grafana data source behind publicly shared dashboards, whose queries run with no signed-in user
- scripts on hosts without an identity-provider client
For these, both paths accept optional static keys. They are off unless configured, and JWTs keep working alongside them.
Read path: auth.static_keys |
Write path: ingest.static_keys |
|
|---|---|---|
| Maps | SHA-256 of the key β identity | SHA-256 of the key β writer id |
| Scope | That identity's labels.yaml entry, enforced like any user |
Pushes as that writer only |
| Limits | No groups, so never admin; a #cluster-wide entry is refused |
Cannot read |
The maps are separate: a write key never reads and a read key never writes.
auth:
static_keys:
"<sha256-hex>": public-viewer # a labels.yaml entry named public-viewer scopes it
ingest:
static_keys:
"<sha256-hex>": app-b
Generate a key, and configure only its hash:
KEY=$(openssl rand -base64 32) # give the key to the client
printf %s "$KEY" | sha256sum # put this hex in the config
The hash is 64 lowercase hex characters. A raw key pasted in by mistake fails validation and is never logged in full. Several hashes may map to the same identity or writer, so a key can be rotated with no downtime:
- Add the new key's hash.
- Move the client to the new key.
- Remove the old hash.
Static keys never expire on their own: keep each one narrowly scoped and rotate it.
Grafana publicly shared dashboards. Their queries run without a viewer's token, so a data source that forwards the user's OAuth identity cannot serve them.
- Give them their own data sources that send a static read key, scoped to the data you intend to share. Panels on shared dashboards cannot use template variables.
- Grafana can read the key from an environment variable populated from a Kubernetes Secret:
# Grafana data source provisioning
- name: Metrics (public)
type: prometheus
url: http://lgtm-lbac-proxy.example.svc:8080
jsonData:
httpHeaderName1: Authorization
secureJsonData:
httpHeaderValue1: "Bearer $__env{LBAC_PUBLIC_READ_KEY}"
Grafana OSS has no per-data-source permissions, so every Grafana user can also query these data sources. Grant the identity only what everyone may see.
How It Works
graph TD
A[Receive Request] -->|Extract JWT Token| B{Validate Token?}
B -->|Invalid| E[403 Forbidden]
B -->|Valid| D{Validate Labels?}
D -->|No Labels| E
D -->|Has #cluster-wide| F[Forward to Upstream]
D -->|Has Labels| G{Enforce Query?}
G -->|Unauthorized Label| E
G -->|Success| H[Inject Tenant Filter]
H --> F
F --> I[Stream Response]
Authorization Flow:
- Request Reception: Proxy receives a query request (PromQL, LogQL, or TraceQL)
- JWT Validation: Extracts and validates JWT token from Authorization header
- Label Retrieval: Fetches allowed tenant labels for user/groups from label store
- Admin Bypass Check: Users with
#cluster-widelabel skip enforcement - Query Parsing: Parses query using appropriate parser (PromQL/LogQL/TraceQL)
- Label Validation: Checks if existing tenant labels in query are authorized
- Label Injection: Injects tenant label filters if missing (e.g.,
{namespace="prod"}) - Proxy Forward: Forwards modified query to upstream (Prometheus/Loki/Tempo)
- Response Stream: Streams response back to client
Quick Start
Binary
# Build and install the latest release (Go 1.26+)
go install github.com/at-blacknight-projects/lgtm-lbac-proxy@latest
# Run with config
lgtm-lbac-proxy
Docker
docker run -d \
-p 8080:8080 \
-p 8081:8081 \
-v $(pwd)/configs:/etc/config/config:ro \
ghcr.io/at-blacknight-projects/lgtm-lbac-proxy:<version>
Use a version from the package's tags, e.g. 0.2.0-alpha.13.
Kubernetes (Helm)
# Install from local chart
helm install lgtm-lbac-proxy ./helm/lgtm-lbac-proxy \
--namespace observability \
--create-namespace \
--set proxy.web.jwksCertUrl=https://your-oauth.com/certs \
--set proxy.thanos.url=https://thanos-query:9091 \
--set proxy.loki.url=https://loki-query:3100 \
--set proxy.tempo.url=https://tempo-query:3200
# Create labels ConfigMap
kubectl create configmap lgtm-lbac-proxy-labels \
--from-file=labels.yaml=./configs/labels.yaml \
--namespace observability
See Helm Chart Documentation for detailed configuration options.
Configuration
Basic Configuration
Create config.yaml:
# Authentication configuration
auth:
jwks_cert_url: "https://your-oauth-provider.com/certs"
auth_header: "Authorization"
claims:
username: "preferred_username" # JWT claim for username
email: "email" # JWT claim for email
groups: "groups" # JWT claim for groups
admin:
bypass: true
group: "cluster-admins"
thanos:
url: "https://thanos-querier:9091"
tenant_label: "namespace"
use_mutual_tls: false
loki:
url: "https://loki-query-frontend:3100"
tenant_label: "kubernetes_namespace_name"
actor_header: "X-Loki-Actor"
tempo:
url: "https://tempo-query-frontend:3100"
tenant_label: "resource.namespace"
actor_header: "X-Tempo-User"
Configurable JWT Claims (New in v0.14.0)
Different OAuth providers use different claim names for user identity. You can now configure which JWT claims to use:
auth:
claims:
username: "preferred_username" # Keycloak, Okta
# username: "unique_name" # Azure AD
# username: "nickname" # Auth0
# username: "email" # Google
email: "email" # Most providers
# email: "upn" # Azure AD User Principal Name
groups: "groups" # Keycloak, Okta
# groups: "roles" # Azure AD
# groups: "https://example.com/groups" # Auth0 (namespaced)
Common OAuth Providers:
| Provider | Username | Groups | |
|---|---|---|---|
| Keycloak | preferred_username |
email |
groups |
| Azure AD | unique_name, upn |
email, upn |
roles |
| Auth0 | nickname, name |
email |
https://domain.com/groups |
email, sub |
email |
hd (domain) |
|
| Okta | preferred_username |
email |
groups |
See Configuration Examples for provider-specific setup guides.
High-Performance Proxy Configuration (New in v0.13.0)
Configure proxy performance settings for high-throughput deployments:
# Global proxy defaults (optional - sensible defaults provided)
proxy:
request_timeout: 60s # Maximum request duration
idle_conn_timeout: 90s # Keep-alive for idle connections
tls_handshake_timeout: 10s # TLS handshake timeout
max_idle_conns: 500 # Total idle connections across all upstreams
max_idle_conns_per_host: 100 # Idle connections per upstream
force_http2: true # Enable HTTP/2 when available
# Per-upstream overrides (customize for workload characteristics)
loki:
url: "https://loki-query-frontend:3100"
tenant_label: "kubernetes_namespace_name"
proxy:
request_timeout: 120s # Log queries can be slow
max_idle_conns_per_host: 150 # High log volume needs more connections
tempo:
url: "https://tempo-query-frontend:3100"
tenant_label: "resource.namespace"
proxy:
request_timeout: 300s # Trace queries need longer timeout
max_idle_conns_per_host: 50 # Lower volume, fewer connections
thanos:
url: "https://thanos-querier:9091"
tenant_label: "namespace"
proxy:
request_timeout: 60s
max_idle_conns_per_host: 100
Performance Characteristics:
- Throughput: 1000-2000 req/s with connection pooling
- Connection Reuse: >95% under steady load
- Latency Impact: <1 Β΅s added per request (negligible)
- Configuration Precedence:
upstream-specific > global > built-in defaults
When to Tune:
- High request rate (>500 req/s): Increase
max_idle_conns_per_host - Slow queries: Increase
request_timeoutfor specific upstream - HTTP/2 capable upstreams: Enable
force_http2for multiplexing - Connection exhaustion: Increase
max_idle_connstotal pool size
Label Configuration
Create labels.yaml using the extended multi-label format (required as of v0.12.0):
# Simple single-label policy
alice@example.com:
_rules:
- name: namespace
operator: '='
values: ['prod', 'staging']
_logic: AND
# Multi-label policy with AND logic
bob@example.com:
_rules:
- name: namespace
operator: '='
values: ['prod']
- name: team
operator: '=~'
values: ['backend.*']
- name: environment
operator: '!='
values: ['test']
_logic: AND # All three conditions must be satisfied
# Multi-label policy with OR logic
charlie@example.com:
_rules:
- name: namespace
operator: '='
values: ['dev']
- name: namespace
operator: '='
values: ['staging']
_logic: OR # Either dev OR staging
# Regex matching for complex patterns
engineering-team:
_rules:
- name: namespace
operator: '=~'
values: ['prod-.*', 'staging-.*'] # Matches prod-app1, staging-db, etc.
- name: team
operator: '='
values: ['engineering']
_logic: AND
# Admin access (cluster-wide bypass)
cluster-admins:
_rules:
- name: '#cluster-wide'
operator: '='
values: ['true']
_logic: AND
Extended Format Features:
- Multi-label enforcement: Combine multiple labels with AND/OR logic (e.g., namespace AND team AND environment)
- Rich operators:
=- Exact match!=- Not equal (negation)=~- Regex match (e.g.,backend.*matches backend-api, backend-worker)!~- Negative regex (exclude patterns)
- Logical combinations:
AND- All rules must be satisfied (default)OR- Any rule can be satisfied
- Per-user policies: Different users can have completely different label enforcement rules
Real-World Examples:
# Backend team: only prod namespace + backend services
backend-developers:
_rules:
- name: namespace
operator: '='
values: ['prod']
- name: service
operator: '=~'
values: ['backend-.*', 'api-.*']
_logic: AND
# QA team: staging and test environments, but not production
qa-team:
_rules:
- name: environment
operator: '='
values: ['staging', 'test']
- name: environment
operator: '!='
values: ['production']
_logic: AND
# Multi-region access: only specific regions
us-team:
_rules:
- name: region
operator: '='
values: ['us-east-1', 'us-west-2']
_logic: OR
# Cost center tracking with exclusions
finance-team:
_rules:
- name: cost_center
operator: '='
values: ['finance']
- name: namespace
operator: '!~'
values: ['temp-.*', 'test-.*'] # Exclude temporary/test namespaces
_logic: AND
Migration from MySQL Label Store
If you're upgrading from a version that used MySQL label store:
Step 1: Export labels from MySQL
-- Export user labels
SELECT username, allowed_labels FROM label_mappings;
Step 2: Convert to extended format
Create labels.yaml using the extended multi-label format:
# Convert MySQL rows to extended format
username1:
_rules:
- name: namespace
operator: '='
values: ['namespace1', 'namespace2']
_logic: AND
group1:
_rules:
- name: namespace
operator: '='
values: ['namespace3']
_logic: AND
Step 3: Update configuration
Remove these fields from config.yaml:
web.label_store_kind(no longer needed)db:section (entire section)
Step 4: Deploy labels ConfigMap
kubectl create configmap lgtm-lbac-proxy-labels \
--from-file=labels.yaml=./labels.yaml \
--namespace observability
Note: The label store now automatically uses file-based ConfigMap mode. For custom label store implementations (e.g., external databases, LDAP), see the contrib/labelstores/ directory.
Migration from Simple Format (v0.11 and earlier)
BREAKING CHANGE in v0.12.0: The simple label format has been removed. If you're upgrading from v0.11 or earlier, you must migrate to the extended format.
Old Simple Format (DEPRECATED, removed in v0.12.0):
# β This format is no longer supported
user@example.com:
namespace1: true
namespace2: true
New Extended Format (REQUIRED as of v0.12.0):
# β
Use this format
user@example.com:
_rules:
- name: namespace
operator: '='
values: ['namespace1', 'namespace2']
_logic: AND
Migration Tool:
A migration tool is provided to automatically convert simple format to extended format:
# Build and install the migration tool (Go 1.26+)
go install github.com/at-blacknight-projects/lgtm-lbac-proxy/cmd/migrate-labels@latest
# Convert your labels file
migrate-labels -input labels.yaml -output labels-extended.yaml -tenant-label namespace
# Verify the output
cat labels-extended.yaml
# Deploy the new format
kubectl create configmap lgtm-lbac-proxy-labels \
--from-file=labels.yaml=./labels-extended.yaml \
--namespace observability \
--dry-run=client -o yaml | kubectl apply -f -
Migration Steps:
- Backup: Save your current
labels.yaml - Convert: Use the migration tool to convert to extended format
- Test: Validate the new format works in a test environment
- Deploy: Update your ConfigMap with the new format
- Upgrade: Deploy v0.12.0+ with the extended format
Why This Change?
The extended format provides:
- Multi-label enforcement: Support for complex policies (namespace AND team)
- Flexible operators: Exact match, regex, negation
- Logical combinations: AND/OR logic for rules
- Future-proof: Foundation for advanced RBAC features
Query Examples
Single-Label Enforcement
Metrics (PromQL)
User Policy: namespace="prod"
# Original Query
rate(http_requests_total[5m])
# Enforced Query
rate(http_requests_total{namespace="prod"}[5m])
Logs (LogQL)
User Policy: kubernetes_namespace_name="prod"
# Original Query
{app="nginx"} |= "error"
# Enforced Query
{kubernetes_namespace_name="prod",app="nginx"} |= "error"
Traces (TraceQL)
User Policy: resource.namespace="prod"
# Original Query
{ span.http.status_code >= 500 }
# Enforced Query
{ resource.namespace="prod" && span.http.status_code >= 500 }
Multi-Label Enforcement (New in v0.10.0)
Complex PromQL Query
User Policy: namespace="prod" AND team=~"backend.*" AND environment!="test"
# Original Query
sum(rate(http_requests_total[5m])) by (service)
# Enforced Query
sum(rate(http_requests_total{namespace="prod",team=~"backend.*",environment!="test"}[5m])) by (service)
Multi-Label LogQL
User Policy: namespace="prod" AND service=~"api-.*"
# Original Query
{job="kubernetes-pods"} | json | line_format "{{.message}}"
# Enforced Query
{namespace="prod",service=~"api-.*",job="kubernetes-pods"} | json | line_format "{{.message}}"
Multi-Label TraceQL
User Policy: resource.namespace="prod" AND resource.team="backend"
# Original Query
{ duration > 1s && span.http.status_code = 500 }
# Enforced Query
{ resource.namespace="prod" && resource.team="backend" && duration > 1s && span.http.status_code = 500 }
Regex and Negation Examples
Regex Match Operator (=~)
User Policy: namespace=~"prod-.*" (matches prod-app1, prod-db, etc.)
# Enforced Query
rate(http_requests_total{namespace=~"prod-.*"}[5m])
Negation Operator (!=)
User Policy: environment!="test" (exclude test environment)
# Enforced Query
{environment!="test",app="nginx"} |= "error"
Negative Regex (!~)
User Policy: namespace!~"temp-.*" (exclude temporary namespaces)
# Enforced Query
sum(container_memory_usage_bytes{namespace!~"temp-.*"}) by (pod)
Kubernetes Deployment
Helm Chart
The project includes a production-ready Helm chart for Kubernetes deployment.
Chart Version: 1.8.0+ | App Version: 0.14.0
Features
- β Complete LGTM Stack: Full support for Prometheus/Thanos, Loki, and Tempo
- β Multi-Label Policies: Advanced access control with AND/OR logic and operators
- β High Performance: Connection pooling and per-upstream optimization (1000-2000 req/s)
- β Configurable Auth: Support for Keycloak, Azure AD, Auth0, Google, Okta
- β Production Ready: Resource limits, security contexts, health probes, HPA
- β Security Hardened: Non-root execution, dropped capabilities, seccomp profiles
- β Auto-scaling: Horizontal Pod Autoscaler with CPU/memory metrics
- β Monitoring: ServiceMonitor for Prometheus metrics collection
- β Vanilla Kubernetes: No platform-specific dependencies
Quick Installation
# Install the chart with new auth configuration (v0.14.0+)
helm install lgtm-lbac-proxy ./helm/lgtm-lbac-proxy \
--namespace observability \
--create-namespace \
--set proxy.auth.jwksCertUrl=https://oauth.example.com/certs \
--set proxy.auth.claims.username=preferred_username \
--set proxy.auth.claims.email=email \
--set proxy.auth.claims.groups=groups \
--set proxy.thanos.url=https://thanos-querier.monitoring.svc:9091 \
--set proxy.loki.url=https://loki-query-frontend.logging.svc:3100 \
--set proxy.tempo.url=https://tempo-query-frontend.tracing.svc:3200
# Create labels ConfigMap with extended format
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: lgtm-lbac-proxy-labels
namespace: observability
data:
labels.yaml: |
# Single-label policy
alice@example.com:
_rules:
- name: namespace
operator: '='
values: ['prod', 'staging']
_logic: AND
# Multi-label policy with regex
backend-team:
_rules:
- name: namespace
operator: '='
values: ['prod']
- name: team
operator: '=~'
values: ['backend-.*']
_logic: AND
# Admin with cluster-wide access
admin-group:
_rules:
- name: '#cluster-wide'
operator: '='
values: ['true']
_logic: AND
EOF
Configuration Examples
Minimal Production (v0.14.0+):
# values.yaml
replicas: 2
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
proxy:
# New auth configuration (v0.14.0+)
auth:
jwksCertUrl: https://oauth.example.com/certs
claims:
username: preferred_username
email: email
groups: groups
# Upstream configuration
thanos:
url: https://thanos-querier.monitoring.svc:9091
tenantLabel: namespace
loki:
url: https://loki-query-frontend.logging.svc:3100
tenantLabel: kubernetes_namespace_name
tempo:
url: https://tempo-query-frontend.tracing.svc:3200
tenantLabel: resource.namespace
High Availability with Performance Tuning:
replicas: 3
# HPA for auto-scaling
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
# Resource limits for high throughput
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 2000m
memory: 1Gi
proxy:
auth:
jwksCertUrl: https://oauth.example.com/certs
claims:
username: preferred_username
email: email
groups: groups
# Global proxy performance settings (v0.13.0+)
proxyConfig:
request_timeout: 60s
max_idle_conns: 500
max_idle_conns_per_host: 100
idle_conn_timeout: 90s
force_http2: true
# Per-upstream tuning
loki:
url: https://loki-query-frontend.logging.svc:3100
tenantLabel: kubernetes_namespace_name
proxy:
request_timeout: 120s
max_idle_conns_per_host: 150
tempo:
url: https://tempo-query-frontend.tracing.svc:3200
tenantLabel: resource.namespace
proxy:
request_timeout: 300s
max_idle_conns_per_host: 50
# Topology spread for high availability
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
Azure AD Integration:
proxy:
auth:
jwksCertUrl: https://login.microsoftonline.com/YOUR_TENANT_ID/discovery/v2.0/keys
claims:
username: unique_name # Azure AD specific
email: upn # User Principal Name
groups: roles # Azure AD uses 'roles' for groups
For complete configuration options and deployment examples, see:
Datasource Configuration
Grafana Configuration
Configure Grafana datasources to point to the proxy:
Prometheus/Thanos:
URL: http://lgtm-lbac-proxy:8080/api/v1
Loki:
URL: http://lgtm-lbac-proxy:8080/loki/api/v1
Tempo:
URL: http://lgtm-lbac-proxy:8080/tempo/api
All requests must include valid JWT token in Authorization header.
Building from Source
# Clone repository
git clone https://github.com/at-blacknight-projects/lgtm-lbac-proxy.git
cd lgtm-lbac-proxy
# Build binary
make build
# Run tests
make test
# Build Docker image
make docker-build-full
See BUILD.md for detailed build instructions.
Migration from multena-proxy
If you're migrating from the original multena-proxy, see MIGRATION.md for a comprehensive guide.
Naming Changes
- Binary name:
multena-proxyβlgtm-lbac-proxy - Docker image:
ghcr.io/gepaplexx/multena-proxyβghcr.io/binhnguyenduc/lgtm-lbac-proxy - Helm chart:
gp-multenaβlgtm-lbac-proxy
Breaking Changes Since Fork
β οΈ Important: This project has introduced breaking changes that require configuration updates:
-
Label Format (v0.12.0): Simple label format removed
- Old:
user: {namespace: true} - New: Extended format with
_rulesand_logicrequired - Migration: Use
migrate-labelstool to convert existing labels
- Old:
-
MySQL Label Store (v0.9.0): MySQL support removed
- Old:
label_store_kind: mysqlwithdb:configuration - New: File-based ConfigMap only
- Migration: Export MySQL data and convert to YAML format
- Old:
-
Authentication Configuration (v0.14.0): New auth section (backward compatible)
- Recommended: Move
web.jwks_cert_urlβauth.jwks_cert_url - New: Configurable JWT claims (
auth.claims) - Note: Legacy fields still work with deprecation warnings
- Recommended: Move
What Remains Compatible
β API endpoints: No changes to routing or request handling β JWT authentication: JWKS validation logic unchanged β Core enforcement: Query enforcement patterns preserved
Documentation
Contributing
Contributions are welcome! This is an independent project focused on LGTM stack support.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.
Acknowledgments
- Original Project: multena-proxy by Gepardec
- Contributors: Thank you to everyone who has contributed to making LGTM stack observability more secure
Support
- Issues: GitHub Issues
Documentation
ΒΆ
There is no documentation for this package.