groups:
- name: thanos-receive-controller
  rules:
  - alert: ThanosReceiveControllerIsDown
    annotations:
      message: Thanos Receive Controller has disappeared from {{$labels.namespace}}. Prometheus target for the component cannot be discovered.
    expr: |
      absent(up{job=~"thanos-receive-controller.*"} == 1)
    for: 5m
    labels:
      severity: critical
  - alert: ThanosReceiveControllerReconcileErrorRate
    annotations:
      message: Thanos Receive Controller from {{$labels.namespace}} is failing to reconcile changes, {{ $value | humanize }}% of attempts failed.
    expr: |
      (
        sum by (namespace, job) (rate(thanos_receive_controller_reconcile_errors_total{job=~"thanos-receive-controller.*"}[5m]))
      /
        sum by (namespace, job) (rate(thanos_receive_controller_reconcile_attempts_total{job=~"thanos-receive-controller.*"}[5m]))
      ) * 100 >= 10
    for: 5m
    labels:
      severity: warning
  - alert: ThanosReceiveControllerConfigmapChangeErrorRate
    annotations:
      message: Thanos Receive Controller from {{$labels.namespace}} is failing to refresh configmap, {{ $value | humanize }}% of attempts failed.
    expr: |
      (
        sum by (namespace, job) (rate(thanos_receive_controller_configmap_change_errors_total{job=~"thanos-receive-controller.*"}[5m]))
      /
        sum by (namespace, job) (rate(thanos_receive_controller_configmap_change_attempts_total{job=~"thanos-receive-controller.*"}[5m]))
      ) * 100 >= 10
    for: 5m
    labels:
      severity: warning
  - alert: ThanosReceiveConfigInconsistent
    annotations:
      message: The configuration of the instances of Thanos Receive `{{$labels.job}}` from {{$labels.namespace}} are out of sync.
    expr: |
      (
        avg by (namespace, job) (thanos_receive_config_hash{job=~"thanos-receive-default.*"})
      / on (namespace) group_left
        thanos_receive_controller_configmap_hash{job=~"thanos-receive-controller.*"} != 1
      )
    for: 5m
    labels:
      severity: critical
