首页 > 解决方案 > 如何让客户端应用程序事件进入普罗米修斯

问题描述

我们有一个在 ios 和 android 手机上运行的客户端应用程序。我们正在生成当前发送到对讲机的事件。我们希望在普罗米修斯中有这些事件。

有没有一种快速的解决方案可以将它们放在普罗米修斯中,并附有在线示例?如果没有在线解决方案,那么添加端点客户端调用与事件并且服务器将其公开给舞会刮板会是一个坏主意吗?

标签: prometheus

解决方案


为了让 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.14prometheus 仪表板上看到示例中的指标。

echo "some_metric 3.14" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/some_job

推荐阅读