---
#==============================================================#
# File      :   minio.yml
# Ctime     :   2023-02-24
# Mtime     :   2023-08-02
# Desc      :   Record rules for minio
# Path      :   /infra/rules/minio.yml
# License   :   Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright :   2018-2026  Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#


groups:
  ################################################################
  #                         MinIO Rules                          #
  ################################################################
  # - name: minio-rules
  #   rules:


  ################################################################
  #                         MinIO Alert                          #
  ################################################################
  - name: minio-alert
    rules:

      #==============================================================#
      #                         Aliveness                            #
      #==============================================================#
      # MinIO server instance down
      - alert: MinioServerDown
        expr: minio_up < 1
        for: 1m
        labels: { level: 0, severity: CRIT, category: minio }
        annotations:
          summary: "CRIT MinioServerDown {{ $labels.ins }}@{{ $labels.instance }}"
          description: |
            minio_up[ins={{ $labels.ins }}, instance={{ $labels.instance }}] = {{ $value }} < 1
            /ui/d/minio-overview

      #==============================================================#
      #                         Error                                #
      #==============================================================#
      # MinIO node offline triggers a p1 alert
      - alert: MinioNodeOffline
        expr: avg_over_time(minio_cluster_nodes_offline_total{job="minio"}[5m]) > 0
        for: 3m
        labels: { level: 1, severity: WARN, category: minio }
        annotations:
          summary: "WARN MinioNodeOffline: {{ $labels.cls }} {{ $value }}"
          description: |
            minio_cluster_nodes_offline_total[cls={{ $labels.cls }}] = {{ $value }} > 0
            /ui/d/minio-overview?from=now-5m&to=now&var-cls={{$labels.cls}}

      # MinIO disk offline triggers a p1 alert
      - alert: MinioDiskOffline
        expr: avg_over_time(minio_cluster_disk_offline_total{job="minio"}[5m]) > 0
        for: 3m
        labels: { level: 1, severity: WARN, category: minio }
        annotations:
          summary: "WARN MinioDiskOffline: {{ $labels.cls }} {{ $value }}"
          description: |
            minio_cluster_disk_offline_total[cls={{ $labels.cls }}] = {{ $value }} > 0
            /ui/d/minio-overview?from=now-5m&to=now&var-cls={{$labels.cls}}
...
