简体   繁体   English

每小时或每天向 Prometheus 报告一个指标

[英]Report a metric to Prometheus every hour, or every day

I'm using Prometheus to report metrics about my system.我正在使用 Prometheus 报告有关我的系统的指标。 I wanted to ask what is the best way to report a counter which is an output of an hourly/daily job.我想问一下报告每小时/每日工作输出的计数器的最佳方法是什么。

For example I have an hourly job with a numeric output and I would like to monitor the number and raise an alert if it is under a specific threshold.例如,我有一个带有数字输出的小时工,我想监控该数字并在低于特定阈值时发出警报。

Thanks, Ori谢谢,奥利

I think what you are looking for is inside the node_exporter collector, if you read the doc you will see a textfile collector option inside it.我认为您正在寻找的是 node_exporter 收集器内部,如果您阅读文档,您将在其中看到一个文本文件收集器选项。

If you use cron job, I suggest you store the attended result inside a file and use this collector to get the datas.如果您使用 cron 作业,我建议您将参与的结果存储在一个文件中并使用此收集器来获取数据。

You will find a bit more detail about how to do it here: https://www.robustperception.io/using-the-textfile-collector-from-a-shell-script您可以在此处找到有关如何执行此操作的更多详细信息: https : //www.robustperception.io/using-the-textfile-collector-from-a-shell-script

You can use push gateway and push the metrics into prometheus at end of your hourly / daily job (if it is not running as a service).您可以使用推送网关并在每小时/每日工作结束时将指标推送到普罗米修斯(如果它没有作为服务运行)。 If it is running as a service i hope you are aware of scrape interval configuration.如果它作为服务运行,我希望您了解抓取间隔配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM