Thakurvaibhav/k8s

Kubernetes deployment metrics calculate is wrong

Closed this issue · 2 comments

I have two deployments foo-api and foo-api-stg, when aggregating data from foo-api metrics from foo-api-stg are summed together. This is because of the regex used in the dashboard:

sum (container_memory_working_set_bytes{image!="",name=~"^k8s_.*",pod_name=~"^$Deployment.*$",container_name!="POD"}) by (pod_name)

Anyway thoughts on how truly separate the pod metrics?

Hi @guitcastro
Thanks for reaching out.
You can do multiple things here:

  1. Completely remove the Deployment from scope and group by pods only.
  2. Add Namespace as variable in grafana just like the Deployment and then filter using namespace as well.
    From the information you have provided it is not clear whether the deployments are in same namespace or not but it is highly recommended that deployments of same app for diff env should be in different namespaces if not different clusters. However, if you have 2 deployments of similar name in the same namespace, I would simply update the query to group by pods and ignore the deployment name altogether.
    Does that sound viable ?

@guitcastro I believe you fixed it. Closing it. Let me know if you want me to re-open.