prometheus - 如何让客户端应用程序事件进入普罗米修斯
问题描述
我们有一个在 ios 和 android 手机上运行的客户端应用程序。我们正在生成当前发送到对讲机的事件。我们希望在普罗米修斯中有这些事件。
有没有一种快速的解决方案可以将它们放在普罗米修斯中,并附有在线示例?如果没有在线解决方案,那么添加端点客户端调用与事件并且服务器将其公开给舞会刮板会是一个坏主意吗?
解决方案
为了让 prometheus 从您的应用程序中提取数据,您必须使用 prometheus 的客户端库。有一个由您可以使用的编程语言组织的列表https://prometheus.io/docs/instrumenting/clientlibs/。
但是,如果您不想或不能让您的应用程序使用这些库公开事件,您可以将事件推送到 Pushgateway 并让 Prometheus 从中提取数据。“Pushgateway 是一种中介服务,它允许您从无法抓取的作业中推送指标。有关详细信息,请参阅推送指标。” 来自https://prometheus.io/docs/practices/pushing/
您可以在prometheus.yml
配置文件中配置它
scrape_configs:
- job_name: 'pushgateway'
scrape_interval: 10s
honor_labels: true
static_configs:
- targets: ['127.0.0.1:9091']
curl
并使用或其他 rest api推送指标。然后,您将在some_metric 3.14
prometheus 仪表板上看到示例中的指标。
echo "some_metric 3.14" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/some_job
推荐阅读
- fortran - gprof 不显示呼叫信息
- sql - 有条件地插入到雪花中的表中
- python - 从数据numpy数组中删除一个字符
- reactjs - Redux 操作有效,但 reducer 无效
- javascript - 反应从输入字段填充下拉列表
- java - 如何在可滚动的 ImageView 中设置按钮?
- ios - 圆形图像在第一个表刷新时是方形的
- javascript - React 无法显示 json - 数据被分配了一个值但从未使用过
- node.js - express JS 应用程序 - 我们如何在 express 中使用普通 HTML 而不是模板引擎
- javascript - 在 php 中选择其他搜索选择标签时填充其他文本框