仅从上次抓取迭代中从普罗米修斯获取数据 [英] Get data from prometheus only from last scrape iteration

查看:54
本文介绍了仅从上次抓取迭代中从普罗米修斯获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用例

我正在创建一个工具来显示 kubernetes 集群中所有 pod 的资源请求.Prometheus 已经抓取了我的 prometheus 指标导出器,并在历史上保存了所有抓取的指标(间隔 10 秒),以便我什至可以看到 10 天前来自所有 Pod 的资源请求.

I am creating a tool to show the resource requests of all pods in a kubernetes cluster. Prometheus already scrapes my prometheus metric exporter and historically saves all the scraped metrics (interval 10s), so that I could even see the resource requests from all pods 10 days ago.

问题

每次重新部署 Pod 时,它都会更改名称.但是我只想显示实际运行的 pod 的资源请求.为此,我显然可以添加一个时间选择器,例如,只显示最多 15 秒的旧结果,但这会有点麻烦.如果可能的话,我想从最新的抓取迭代中获得结果(如果出现问题,可能会超过 15 秒).

Every time a pod has been redeployed it does change the name. However I only want to show the resource requests of actually RUNNING pods. For this purpose I could obviously add a time selector like, show me only max 15s old results, but that would be a little hack. If possible I'd like to get the results from the latest scrape iteration (which in case of problems could be older than 15s).

问题

只获取那些在上次迭代中被刮掉的普罗米修斯指标的最佳方法是什么?

What's the best way to get only those prometheus metrics which have been scraped in the last iteration?

eagle_container_resource_requests_cpu 例如将返回请求的 pod 的 CPU 内核,而这些内核现在已经不存在了.

eagle_container_resource_requests_cpu for instance would return the requested CPU cores of pods which nowadays no longer exist.

旁注:我正在尝试在 Grafana 表中实现这种行为.

Side note: I am trying to achieve this behaviour in a Grafana table.

推荐答案

Staleness 可能是您正在寻找的:https://prometheus.io/docs/prometheus/latest/querying/basics/#staleness

Staleness might be what you are looking for: https://prometheus.io/docs/prometheus/latest/querying/basics/#staleness

所以 5 分钟后,您应该开始看到值消失了.

So after 5 minutes you should begin to see values disappearing.

这篇关于仅从上次抓取迭代中从普罗米修斯获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆