rule_files:
  - examples/alerts.yaml
  - examples/rules.yaml

evaluation_interval: 1m

tests:
- interval: 1m
  input_series:
  - series: 'thanos_receive_controller_reconcile_errors_total{namespace="production", job="thanos-receive-controller", pod="thanos-receive-controller-pod-0"}'
    values: '2 7 15 15 24 25'
  - series: 'thanos_receive_controller_reconcile_attempts_total{namespace="production", job="thanos-receive-controller", pod="thanos-receive-controller-pod-1"}'
    values: '10 20 30 40 50 60'
  - series: 'thanos_receive_controller_configmap_change_errors_total{namespace="production", job="thanos-receive-controller", pod="thanos-receive-controller-pod-0"}'
    values: '1 2 3 4 5 6'
  - series: 'thanos_receive_controller_configmap_change_attempts_total{namespace="production", job="thanos-receive-controller", pod="thanos-receive-controller-pod-1"}'
    values: '10 20 30 40 50 60'
  - series: 'thanos_receive_config_last_reload_success_timestamp_seconds{namespace="production", job="thanos-receive-default", pod="thanos-controller-pod-0"}'
    values: '1566910000 1566910000 1566910000 1566910000 1566910000 1566910000'
  - series: 'thanos_receive_controller_configmap_last_reload_success_timestamp_seconds{namespace="production", job="thanos-receive-controller", pod="thanos-receive-controller-pod-1"}'
    values: '1566910547 1566910547 1566910547 1566910547 1566910547 1566910547'
  - series: 'thanos_receive_config_hash{namespace="production", job="thanos-receive-default", pod="thanos-receive-pod-0"}'
    values: '1 1 1 1 1 1 1'
  - series: 'thanos_receive_controller_configmap_hash{namespace="production", job="thanos-receive-controller"}'
    values: '1 2 2 2 2 2 2'
  promql_expr_test:
    - expr: time()
      eval_time: 1m
      exp_samples:
        - labels: '{}'
          value: 60
  alert_rule_test:
  - eval_time: 4m
    alertname: ThanosReceiveControllerReconcileErrorRate
  - eval_time: 4m
    alertname: ThanosReceiveControllerConfigmapChangeErrorRate
  - eval_time: 4m
    alertname: ThanosReceiveConfigInconsistent
  - eval_time: 6m
    alertname: ThanosReceiveControllerReconcileErrorRate
    exp_alerts:
    - exp_labels:
        severity: warning
        job: 'thanos-receive-controller'
        namespace: 'production'
      exp_annotations:
        message: 'Thanos Receive Controller from production is failing to reconcile changes, 45% of attempts failed.'
  - eval_time: 6m
    alertname: ThanosReceiveControllerConfigmapChangeErrorRate
    exp_alerts:
    - exp_labels:
        severity: warning
        job: 'thanos-receive-controller'
        namespace: 'production'
      exp_annotations:
        message: 'Thanos Receive Controller from production is failing to refresh configmap, 10% of attempts failed.'
  - eval_time: 6m
    alertname: ThanosReceiveConfigInconsistent
    exp_alerts:
    - exp_labels:
        severity: critical
        job: 'thanos-receive-default'
        namespace: 'production'
      exp_annotations:
        message: 'The configuration of the instances of Thanos Receive `thanos-receive-default` from production are out of sync.'
