
{{- $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: k8s.rules.container_memory_swap
rules:
- expr: {{ printf "container_memory_swap{job=\"kubelet\",metrics_path=\"/metrics/cadvisor\",image!=\"\"} * on(%s,namespace,pod) group_left(node) topk(1, max(kube_pod_info{node!=\"\"}) by(%s,namespace,pod,node)) by(%s,namespace,pod)" $groupLabels $groupLabels $groupLabels }}
  condition: true
  record: node_namespace_pod_container:container_memory_swap
condition: true
