Created
February 15, 2024 12:45
-
-
Save marzocchi/05cca27a5e5bd6075aff4d6bffce622d to your computer and use it in GitHub Desktop.
MetricsQL/PromQL to enhance pod/container metrics with the deployment name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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