ThanosRuler

The ThanosRuler CRD manages the Thanos Ruler component, which evaluates Prometheus recording and alerting rules using data from Thanos Query and can send alerts to Alertmanager. It provides distributed rule evaluation with high availability and multi-tenancy support.

Overview

Thanos Ruler performs several key functions:

  • Rule Evaluation: Executes Prometheus recording and alerting rules at regular intervals
  • Alert Generation: Sends alerts to Alertmanager based on rule evaluation results
  • Recording Rules: Creates new time series from existing data
  • Multi-tenancy: Supports tenant-specific rule isolation
  • High Availability: Provides leader election and distributed evaluation

Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│ PrometheusRule  │    │ PrometheusRule  │    │   ConfigMap     │
│    (Tenant A)   │    │    (Tenant B)   │    │  (Rule Files)   │
└─────────┬───────┘    └─────────┬───────┘    └─────────┬───────┘
          │                      │                      │
          └──────────────────────┼──────────────────────┘
                                 │ Rule Discovery
                                 ▼
                    ┌─────────────────────┐
                    │    ThanosRuler      │
                    │   StatefulSet       │
                    │                     │
                    │ ┌─────────────────┐ │
                    │ │ Rule Evaluation │ │
                    │ │ Engine          │ │
                    │ └─────────────────┘ │
                    └─────────┬───────────┘
                              │
              ┌───────────────┼───────────────┐
              │               │               │
              ▼               ▼               ▼
    ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
    │  ThanosQuery    │ │  Alertmanager   │ │ Object Storage  │
    │  (Data Source)  │ │  (Alerts)       │ │ (Rule Results)  │
    └─────────────────┘ └─────────────────┘ └─────────────────┘

Basic Configuration

Minimal Example

apiVersion: monitoring.thanos.io/v1alpha1
kind: ThanosRuler
metadata:
  name: example-ruler
spec:
  replicas: 1
  ruleConfigSelector:
    matchLabels:
      operator.thanos.io/rule-file: "true"
      operator.thanos.io/tenant: "thanos"
  queryLabelSelector:
    matchLabels:
      operator.thanos.io/query-api: "true"
      app.kubernetes.io/part-of: "thanos"
  defaultObjectStorageConfig:
    name: thanos-object-storage
    key: thanos.yaml
  alertmanagerURL: "http://alertmanager.example.com:9093"
  externalLabels:
    rule_replica: "$(NAME)"
  evaluationInterval: 1m
  retention: 2h
  storage:
    size: 1Gi
  logFormat: logfmt
  imagePullPolicy: IfNotPresent

Found a typo, inconsistency or missing information in our docs? Help us to improve Thanos Operator documentation by proposing a fix on GitHub here ❤️