Skip to content

Instantly share code, notes, and snippets.

@marzocchi
Created February 15, 2024 12:45
Show Gist options
  • Save marzocchi/05cca27a5e5bd6075aff4d6bffce622d to your computer and use it in GitHub Desktop.
Save marzocchi/05cca27a5e5bd6075aff4d6bffce622d to your computer and use it in GitHub Desktop.
MetricsQL/PromQL to enhance pod/container metrics with the deployment name
sum by (namespace, pod) ( container_memory_working_set_bytes{image!="", container!="POD", container!="", source!="cadvisor", namespace="SOME_NAMESPACE"} )
* on (namespace, pod) group_left(deployment)
(
label_copy(kube_replicaset_owner{namespace="SOME_NAMESPACE", owner_kind="Deployment"}, "owner_name", "deployment")
* on (namespace, replicaset) group_left(pod)
(
label_copy(kube_pod_info{namespace="SOME_NAMESPACE", created_by_kind="ReplicaSet"}, "created_by_name", "replicaset")
* on (namespace, replicaset, pod)
label_copy(kube_pod_owner{namespace="SOME_NAMESPACE", owner_kind="ReplicaSet"}, "owner_name", "replicaset")
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment