简体   繁体   English

从多个电报收集指标到普罗米修斯

[英]Collecting metrics from multiple telegraf to prometheus

Continue on from the question of Sending metrics from telegraf to prometheus , which covers the case of single telegraf agent, what's the suggested setup to collect metrics from multiple telegraf to prometheus?继续从 Telegraf 发送指标到 prometheus的问题,它涵盖了单个电报代理的情况,建议从多个电报收集指标到普罗米修斯的设置是什么?

In the end, I want prometheus to chart (on the same graph), CPU usage of server-1, server-2, ... to server-n, in their own lines.最后,我希望 prometheus 在自己的行中绘制(在同一张图上)、server-1、server-2、...到 server-n 的 CPU 使用情况。

Taking the configuration from the original post, you can simply add targets to you telegraf job;从原始帖子中获取配置,您可以简单地将目标添加到您的电报作业; supposing that the same Telegraf config is used on each server.假设在每台服务器上使用相同的 Telegraf 配置。

scrape_configs:
  - job_name: 'telegraf'
    scrape_interval: 5s
    static_configs:
      - targets: ['server-1:9126','server-2:9126',...]

It will produce the metrics (ex: cpu_time_user) with different instance tag corresponding to the targets configured.它将生成具有与配置的目标相对应的不同instance标签的指标(例如:cpu_time_user)。 Typing the metric name in Prometheus will display all of them.在 Prometheus 中输入指标名称将显示所有指标。

If you really want to see only the name of the server, you can use metric_relabel_configs to generate an additional label:如果你真的只想看服务器的名字,可以使用metric_relabel_configs生成一个额外的label:

scrape_configs:
  - job_name: 'telegraf'
    ...
    metric_relabel_configs:
    - source_labels: [instance]
      regex: '(.*):\d+'
      target_label: server

Automatically adding servers to your Prometheus config is a matter of service discovery.自动将服务器添加到 Prometheus 配置是服务发现的问题。

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

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