
{{- $Values := (.helm).Values | default .Values }}
{{- $runbookUrl := ($Values.defaultRules).runbookUrl | default "https://runbooks.prometheus-operator.dev/runbooks" }}
{{- $clusterLabel := ($Values.global).clusterLabel | default "cluster" }}
{{- $additionalGroupByLabels := append $Values.defaultRules.additionalGroupByLabels $clusterLabel }}
{{- $groupLabels := join "," (uniq $additionalGroupByLabels) }}
{{- $grafanaAddr := include "vm-k8s-stack.grafana.addr" . }}
name: node-exporter.rules
rules:
- expr: {{ printf "count(node_cpu_seconds_total{job=\"%s\",mode=\"idle\"}) without(cpu,mode)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_num_cpu:sum
- expr: {{ printf "1 - avg(sum(rate(node_cpu_seconds_total{job=\"%s\",mode=~\"idle|iowait|steal\"}[5m])) without(mode)) without(cpu)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_cpu_utilisation:rate5m
- expr: {{ printf "node_load1{job=\"%s\"} / instance:node_num_cpu:sum{job=\"%s\"}" (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_load1_per_cpu:ratio
- expr: {{ printf "1 - ((node_memory_MemAvailable_bytes{job=\"%s\"} or (((node_memory_Buffers_bytes{job=\"%s\"} + node_memory_Cached_bytes{job=\"%s\"}) + node_memory_MemFree_bytes{job=\"%s\"}) + node_memory_Slab_bytes{job=\"%s\"})) / node_memory_MemTotal_bytes{job=\"%s\"})" (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_memory_utilisation:ratio
- expr: {{ printf "rate(node_vmstat_pgmajfault{job=\"%s\"}[5m])" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_vmstat_pgmajfault:rate5m
- expr: {{ printf "rate(node_disk_io_time_seconds_total{job=\"%s\",device=~\"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)\"}[5m])" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance_device:node_disk_io_time_seconds:rate5m
- expr: {{ printf "rate(node_disk_io_time_weighted_seconds_total{job=\"%s\",device=~\"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)\"}[5m])" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance_device:node_disk_io_time_weighted_seconds:rate5m
- expr: {{ printf "sum(rate(node_network_receive_bytes_total{job=\"%s\",device!=\"lo\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_receive_bytes_excluding_lo:rate5m
- expr: {{ printf "sum(rate(node_network_transmit_bytes_total{job=\"%s\",device!=\"lo\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_transmit_bytes_excluding_lo:rate5m
- expr: {{ printf "sum(rate(node_network_receive_drop_total{job=\"%s\",device!=\"lo\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_receive_drop_excluding_lo:rate5m
- expr: {{ printf "sum(rate(node_network_transmit_drop_total{job=\"%s\",device!=\"lo\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_transmit_drop_excluding_lo:rate5m
- expr: {{ printf "sum(rate(node_network_receive_bytes_total{job=\"%s\",device!~\"lo|veth.+\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_receive_bytes_physical:rate5m
- expr: {{ printf "sum(rate(node_network_transmit_bytes_total{job=\"%s\",device!~\"lo|veth.+\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_transmit_bytes_physical:rate5m
- expr: {{ printf "sum(rate(node_network_receive_drop_total{job=\"%s\",device!~\"lo|veth.+\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_receive_drop_physical:rate5m
- expr: {{ printf "sum(rate(node_network_transmit_drop_total{job=\"%s\",device!~\"lo|veth.+\"}[5m])) without(device)" (include "vm-k8s-stack.nodeExporter.name" .) }}
  condition: true
  record: instance:node_network_transmit_drop_physical:rate5m
condition: true
