英文:
How to subtract two Prometheus metrics to calculate the duration of pod execution?
问题
I have this query gives me when pod terminated:
last_over_time(timestamp(kube_pod_status_phase{phase="Succeeded", pod=~"consumer-deployment.*"})[1h:])
and this gives me when pod is created:
last_over_time((kube_pod_created{pod=~"consumer-deployment.*"}[1h]))
but when I put - between them I get empty Empty query result.
What I can do?
英文:
Im trying to get the pods runnig time from the created moment to the termination
after tryin hunderd solution I think Im close
I have this query gives me when pod terminated
last_over_time(timestamp(kube_pod_status_phase{phase="Succeeded",pod=~"consumer-deployment.*"})[1h:])
and this gives me when pod is created
last_over_time((kube_pod_created{pod=~"consumer-deployment.*"}[1h]))
but when I put - between them I get empty Empty query result
What I can do ?
答案1
得分: 0
我认为我找到了一个解决方案,这个查询有效并返回了每个Pod的运行周期。
last_over_time(timestamp(kube_pod_status_phase{phase="Succeeded", pod=~"consumer-deployment.*"})[1h:])
- ignoring(phase) group_right()
last_over_time((kube_pod_created{pod=~"consumer-deployment.*"}[1h:]))
英文:
I think I found a solution this query worked and it return the runnig period for each pod
last_over_time(timestamp(kube_pod_status_phase{phase="Succeeded",pod=~"consumer-deployment.*"})[1h:])
- ignoring(phase) group_right()
last_over_time((kube_pod_created{pod=~"consumer-deployment.*"}[1h:]))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论