kind: ConfigMap
metadata:
  name: prometheus-alert-rules
apiVersion: v1
data:
  alert.rules.yml: |-
    groups:
    - name: prometheus-alert.rules
      rules:
      - alert: NodeCPUUsage
        expr: (100 - (avg(irate(node_cpu{mode="idle",name="node-exporter"}[5m])) BY (instance) * 100)) > 75
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: CPU usage is above 75% (current value is: {{ $value }})'
          SUMMARY: '{{$labels.instance}}: High CPU usage detected'
      - alert: NodeLowRootDisk
        expr: ((node_filesystem_size{mountpoint="/root-disk"} - node_filesystem_free{mountpoint="/root-disk"}) / node_filesystem_size{mountpoint="/root-disk"} * 100) > 75
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: Root disk usage is above 75% (current value is: {{ $value }})'
          SUMMARY: '{{$labels.instance}}: Low root disk space'
      - alert: NodeLowDataDisk
        expr: ((node_filesystem_size{mountpoint="/data-disk"} - node_filesystem_free{mountpoint="/data-disk"}) / node_filesystem_size{mountpoint="/data-disk"} * 100) > 75
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: Data disk usage is above 75% (current value is: {{ $value }})'
          SUMMARY: '{{$labels.instance}}: Low data disk space'
      - alert: NodeLoadAverage
        expr: ((node_load5 / count(node_cpu{mode="system"}) WITHOUT (cpu, mode)) > 1)
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: LA is high'
          SUMMARY: '{{$labels.instance}}: High Node Load average(5m) detected'
      - alert: NodeSwapUsage
        expr: (((node_memory_SwapTotal - node_memory_SwapFree) / node_memory_SwapTotal) * 100) > 75
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: Swap usage usage is above 75% (current value is: {{ $value }})'
          SUMMARY: '{{$labels.instance}}: High Swap usage detected'
      - alert: NodeMemoryUsage
        expr: (((node_memory_MemTotal - node_memory_MemFree - node_memory_Cached) / (node_memory_MemTotal) * 100)) > 75
        for: 2m
        labels:
          severity: warning
        annotations:
          DESCRIPTION: '{{$labels.instance}}: Memory usage is above 75% (current value is: {{ $value }})'
          SUMMARY: '{{$labels.instance}}: High memory usage detected'
