Skip to content

All prometheusrules are reported back always for all tenants #8140

Open
@slawekww

Description

@slawekww

Thanos, Prometheus and Golang version used:
image: bitnami/thanos:0.36.1-debian-12-r3
thanos helm chart: thanos-15.8.0

Object Storage Provider:
Azure Storage Account

What happened:
Prometheus operator deploys prometheus instances.
Each prometheus instance has own set of prometheusrules for alerting and use thanos sidecar.
Prometheus rules are correctly inserted to thanos via thanos sidecar.
Thanos query responds with all prometheus rules for all prometheus instances.

1, Thanos query is defined for multi-tenancy:

        query:
          extraFlags:
            - --query.replica-label=replica
            - --query.enforce-tenancy
            - --query.tenant-header=THANOS-TENANT
            - --query.tenant-label-name=tenant
  1. Each prometheus instance has thanos sidecar:
            thanos:
              objectStorageConfig:
                existingSecret:
                  name: thanos-object-shared-storage-account
                  key: objstore.yml
...
            externalLabels:
              env: dev
              tenant: tenant2

Prometheus rules are correctly seen on thanos UI:

alert:AlertmanagerClusterCrashlooping
  expr:(count by (namespace, service, cluster) (changes(process_start_time_seconds{job="prometheus-tenant2- prom-te-alertmanager",namespace="tenant2"}[10m]) > 4) / count by (namespace, service, cluster) (up{job="prometheus-tenant2-prom-te-alertmanager",namespace="tenant2"})) >= 0.5
  for: 5m
  labels:
    cluster: abc
    env: dev
    severity: critical
    tenant: tenant2 # each instance has different tenant value
  1. Grafana datasource is defined to use header:
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
  name: thanos
  namespace: tenant2
spec:
  instanceSelector:
    matchLabels:
      dashboards: "tenant2"
  allowCrossNamespaceImport: false
  datasource:
    name: "Global - Prometheus"
    type: prometheus
    access: proxy
    uid: "global-prometheus"
    url: http://thanos-query-frontend.thanos.svc.cluster.local:9090
    isDefault: true
    jsonData:
      httpHeaderName1: 'THANOS-TENANT'
    secureJsonData:
      httpHeaderValue1: 'tenant2'

Grafana query alert rules like is like curl command:

curl -H 'THANOS-TENANT: tenant2' http://thanos-query-frontend.thanos.svc.cluster.local:9090/api/v1/rules
  1. Output is that all prometheus rules are responded regardless if it is tenant2 or different value.

What you expected to happen:

Thanos query should respond with prometheusrules with specific label

How to reproduce it (as minimally and precisely as possible):

  1. configure thanos with mulitenancy
  2. configure two different prometheus instances using different external labels and thanos sidecar
  3. insert different prometheusrules to each prometheus instance
  4. see thanos rules on UI
  5. see thanos query response via curl or via grafana datasource using tenant header

Full logs to relevant components:

Can deliver if required

Anything else we need to know:

Run on K8S 1.32

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions