Skip to content

Ruler: Support Thanos RuleGroupLabels and Query Offset #8136

@Jakob3xD

Description

@Jakob3xD

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Description

Support Rule Group Labels and query offset for Thanos.
Currently, the version check for that is set to a nonexisting Thanos version.

minVersionQueryOffset = semver.MustParse("100.0.0") // Arbitrary very high major version because it's not yet supported by Thanos.
minVersionRuleGroupLabels = semver.MustParse("100.0.0") // Arbitrary very high major version because it's not yet supported by Thanos.

There is a Query Offset var present in the Thanos ruler:
https://github.com/thanos-io/thanos/blob/c50f95a70a0558bda8631278a61255e92588cf07/cmd/thanos/rule.go#L106

And for the Group Labels, there was an e2e test added to Thanos, to verify that it works.
thanos-io/thanos#8207

Steps to Reproduce

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: test
  namespace: test
spec:
  groups:
  - name: test.rules
    labels:
      namespace: test
      tenant: test
    rules:
    - alert: Test
      expr: vector(1)
      labels:
        severity: warning

Expected Result

data:
  test-test-6c244fbc-9fc6-45e3-b255-52224d15610f.yaml: |
    groups:
    - name: test.rules
      labels:
        namespace: test
        tenant: test
      rules:
      - alert: Test
        expr: vector(1)
        labels:
          severity: warning
kind: ConfigMap

Actual Result

Currently, the group labels are removed when rendering the rule configmap.

data:
  test-test-6c244fbc-9fc6-45e3-b255-52224d15610f.yaml: |
    groups:
    - name: test.rules
      rules:
      - alert: Test
        expr: vector(1)
        labels:
          severity: warning
kind: ConfigMap

Prometheus Operator Version

v0.86.2

Kubernetes Version

1.34.2

Kubernetes Cluster Type

kubeadm

How did you deploy Prometheus-Operator?

helm chart:prometheus-community/kube-prometheus-stack

Manifests

prometheus-operator log output

{"ts":"2025-12-02T08:50:32.863823871Z","level":"warn","caller":{"function":"github.com/prometheus-operator/prometheus-operator/pkg/operator.(*PrometheusRuleSelector).sanitizePrometheusRulesSpec","file":"/workspace/pkg/operator/rules.go","line":156},"msg":"ignoring group labels since not supported by Thanos","component":"thanos-controller","thanos":"platform-thanos-ruler","namespace":"monitoring","prometheusrule":"test","prometheusrule-namespace":"test","minimum_version":"100.0.0"}

Anything else?

No response

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