apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: kube-prometheus-stack-k8s.rules.container-memory-working-set-by
  namespace: kube-prometheus-stack
  labels:
    app: kube-prometheus-stack
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/instance: kube-prometheus-stack
    app.kubernetes.io/version: "81.0.0"
    app.kubernetes.io/part-of: kube-prometheus-stack
    chart: kube-prometheus-stack-81.0.0
    release: "kube-prometheus-stack"
    heritage: "Helm"
spec:
  groups:
    - name: k8s.rules.container_memory_working_set_bytes
      rules:
        - expr: |-
            container_memory_working_set_bytes{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}
            * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) (1,
              max by (cluster, namespace, pod, node) (kube_pod_info{node!=""})
            )
          record: node_namespace_pod_container:container_memory_working_set_bytes
