问题标签 [prometheus-pushgateway]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
427 浏览

prometheus - 多个实例向 pushgateway 发送相同的 prometheus 指标

我的任务在多台机器上运行,对于每台机器,我设置了以下相同的指标:

而且我没有给它分配标签。

我的问题是,以当前使用计数器度量的方式,pushgateway 上收集的值会变得不正确,因为它只保留最后推送的值吗?

0 投票
1 回答
1909 浏览

python - 使用 Prometheus 中的指标监控批处理作业的状态

我们的一些应用程序具有每晚汇总数据的批处理作业。这些批处理作业是 Python 脚本,使用 Prometheus Pushgateway 将指标值推送到 Prometheus,并且我们有规则在这些指标变得无效(例如超过某个阈值)时触发警报(在 Alertmanager 中)。

我们现在还想使用 Prometheus 指标来仔细检查批处理作业本身是否正确运行:例如,作业是否按时开始?是否发生任何错误?作业完成了吗?为此,我们希望更改 Python 脚本,以便在脚本开始和结束以及发生任何错误时推送指标。但这确实引发了一些问题:我们有很多批处理作业,每个批处理作业有 3 个指标为规则/警报创建了很多手动配置;我们还想在 Grafana 中以图形方式显示状态,但并不确定正确的视觉效果是什么样的。

有没有其他人试图解决类似的问题来使用 Prometheus 指标来监控几个批处理作业的状态?您记录了哪些指标以及您的警报/规​​则是什么样的?您是否找到了一种直观的方式来以图形方式显示每个批处理作业的状态?

0 投票
1 回答
1272 浏览

prometheus - 有没有办法使用度量/标签值从推送网关中删除?

我只看到如何使用'curl -X DELETE http://localhost:9091/metrics/job/some_job/instance/some_instance'从 pushgateway 中删除,但我想删除包含特定标签值的指标,我该怎么做那?

更新: 我使用 python 编写脚本,prometheus 有一个带有函数'delete_from_pushgateway()'的 python 客户端

这可以在以下位置找到:https ://github.com/prometheus/client_python

0 投票
2 回答
2235 浏览

prometheus - How to set a retention time for Pushgateway for metrics to expire?

I'm using Pushgateway with Prometheus and everything is OK but after a couple of weeks Pushgateway collapses ... giving it a look there are tons of metrics that are not used anymore and delete them manually is practically impossible ... so ->

There is a way to expire Pushgateway metrics with a TTL or some other retention settings like by size or by time ? ... or maybe both ?

NOTE: I read at the mailing list of Prometheus a lot of people requiring something like this from one year ago or more ... and the only answer so far is -> this is not the Promethean way to do it ... really ? ... common, if this is a real pain for a lot of people maybe there should be a better way (even if it's not the Promethean way)

0 投票
1 回答
187 浏览

prometheus - Prometheus 基于批处理作业的非周期性指标的警报

我有一个 CronJob,它每 20 分钟运行一次,只收集构建持续时间超过特定值的 Jenkins 多分支作业的活动构建,并将这些指标与构建持续时间作为值发布到 Prometheus Pushgateway。因此,如果构建完成,则不会推送此指标。我使用以下 Prometheus 配置设置了警报。

以下是 Prometheus 中存在的一个指标值

使用此配置,一旦创建警报,它将永久保留并且不会被删除。如果给定作业的指标不是周期性的,我该如何处理这个用例,并在指标不再可用时删除警报?

0 投票
1 回答
712 浏览

urllib - 将指标推送到 Prometheus Pushgateway 经常失败

我正在使用Prometheus 客户端库将指标推送到 pushgateway。在推送指标时,我经常遇到错误。我怎样才能找到这个问题的根本原因?

0 投票
0 回答
104 浏览

prometheus - 如何将 CSV 行发送到 Prometheus Pushgateway?

我有一个简单的 csv 文件,其中包含这样的日期列和数字:

日期 | 数数

2020-09-01 | 3

2020-09-02 | 4

2020-09-03 | 2

...

有一个 python 脚本可以逐行读取 csv。

我想做的是,使用 pushgateway,pushgateway 将 python 脚本作为批处理作业运行,它将获取所有 csv 时间序列数据。最后,我将使用 grafana 对其进行监控。

0 投票
1 回答
787 浏览

dockerfile - Newman/postman 将结果发送给 prometheus 进行自动化测试

我的任务是自动化邮递员烟雾测试,在 kubernetes 集群中每 x 分钟运行一次,并将结果推送到 prometheus,后来由 grafana 可视化,并将警报推送到最重要的频道。

我已经使用 newman 和其他软件包创建了一个基于 alpine 的自定义 docker 镜像(我没有使用 newman docker 镜像,因为我无法在其中添加任何我想要的东西),复制了我所有的收藏和环境。文件到 docker 映像中,命令newman run也被打包到 dockerfile 中(否则,如果我从 kubernetes 中的 pod 定义 yaml 调用它,它不起作用)。所需要做的就是运行容器,它会在/newman容器内的文件夹中创建一个报告。

我创建了 kubernetes cronjob 来运行容器,它运行并进入完成状态。如果我使用一些循环命令保持容器打开,我可以登录并确保结果在那里(并且它们是)。由于这项工作是短暂的,并且普罗米修斯没有时间刮掉它,我正试图将结果推送到普罗米修斯推送网关(为此我已经部署了它)。我正在尝试curl将结果放入其中(命令也在 dockerfile 中定义),例如cat myreport.xml | curl --data-binary @- push-prometheus-pushgateway:9091/metrics/job/newman

但是,问题是:我无法以任何有意义的方式将结果格式化为普罗米修斯推送网关接受它。我也没有找到任何可能适合此目的的自定义“记者”。目前我正在使用junit记者,但我没有设法sed/awk将输出由 pushgateway 消化并使其具有任何实际意义......

过去有没有人做过类似的事情并取得了一些成功?

提前谢谢了!

0 投票
2 回答
705 浏览

node.js - Node.js:有没有办法模拟 prometheus pushgateway 服务器?

我正在使用node.jsprom-client尝试将不同的自定义指标推送到Prometheus Pushgateway服务器。

该代码正在运行,现在我正在编写该功能的测试代码。我想知道是否有办法模拟 Prometheus Pushgateway 服务器?

我曾尝试使用普通的 express API 服务器(如下所示)

但它不起作用——当我调用gateway.pushAdd()我的测试代码时,服务器没有收到任何发布消息。

谁能给我一些关于如何做到这一点的提示(模拟普罗米修斯推送网关服务器)?

0 投票
0 回答
26 浏览

prometheus - 是否可以抓取在同一台机器上运行的 prometheus 端点并将它们推送到静态 IP 的推送网关?

我有一个可以随时添加实例的系统。度量收集变得困难,因为它很难收集所有抓取目标的更新信息。我想在静态 IP 上使用推送网关来从所有实例中获取指标。

不幸的是,在这些实例上运行的服务只提供了一个普罗米修斯抓取端点(拉)。我是否可以添加第二个服务来抓取第一个(本地)并将指标推送到静态 IP 的推送网关?这第二项服务将纯粹充当货运代理。