应用Prometheus指标于特定部署

huangapple go评论59阅读模式
英文:

Apply prometheus metric for specific deployment

问题

这个指标返回特定 Pod 的运行时间:

sum by(namespace, pod) (
  (
    last_over_time(kube_pod_completion_time[1d]) 
    - last_over_time(kube_pod_created{pod="consumer-deployment-697bcc9d8-sl9lj"}[1d])
  ) 
  or 
  (
    time() - kube_pod_created{pod="consumer-deployment-697bcc9d8-sl9lj"}
  )
)

这个代码片段返回所有的 Pod,如何使它只返回特定部署的结果?

英文:

This metrics return the runnig time of specific pod

sum by(namespace, pod) (

   (last_over_time(kube_pod_completion_time[1d]) 
   - last_over_time(kube_pod_created{pod="consumer-deployment-697bcc9d8-sl9lj"}[1d])) 

  or 

    (time() - kube_pod_created{pod="consumer-deployment-697bcc9d8-sl9lj"})

)

and this

kube_pod_created{})

return all pods how can I make it retrun only result from specific deployment ?

答案1

得分: 0

我找到了一个对我有用的解决方案,我已经添加了以下内容:

pod=~"consumer-deployment.*"

所以它只列出以该前缀开头的Pod。

最终查询是:

kube_pod_created{pod=~"consumer-deployment.*"}
英文:

I'v found a solution that worked for me I'v added

pod=~"consumer-deployment.*"

so it list only pods start with that prefix

final query is

kube_pod_created{pod=~"consumer-deployment.*"}

huangapple
  • 本文由 发表于 2023年6月19日 17:31:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505339.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定