我在跑prometheus
and telegraf
在同一主机上。
我正在使用一些输入插件:
我已经配置为prometheus_client
输出插件将数据发送到prometheus
这是我的配置:
[[outputs.prometheus_client]]
## Address to listen on.
listen = ":9126"
## Use HTTP Basic Authentication.
# basic_username = "Foo"
# basic_password = "Bar"
## If set, the IP Ranges which are allowed to access metrics.
## ex: ip_range = ["192.168.0.0/24", "192.168.1.0/30"]
# ip_range = []
## Path to publish the metrics on.
path = "/metrics"
## Expiration interval for each metric. 0 == no expiration
#expiration_interval = "0s"
## Collectors to enable, valid entries are "gocollector" and "process".
## If unset, both are enabled.
# collectors_exclude = ["gocollector", "process"]
## Send string metrics as Prometheus labels.
## Unless set to false all string metrics will be sent as labels.
# string_as_label = true
## If set, enable TLS with the given certificate.
# tls_cert = "/etc/ssl/telegraf.crt"
# tls_key = "/etc/ssl/telegraf.key"
## Export metric collection time.
#export_timestamp = true
Here's my prometheus config
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
# - job_name: 'node_exporter'
# scrape_interval: 5s
# static_configs:
# - targets: ['localhost:9100']
- job_name: 'telegraf'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9126']
如果我要去http://localhost:9090/metrics
我没有看到任何来自 telegraf 的指标。
我也从 telegraf 捕获了一些日志
/opt telegraf --config /etc/telegraf/telegraf.conf --input-filter filestat --test
➜ /opt tail -F /var/log/telegraf/telegraf.log
2019-02-11T17:34:20Z D! [outputs.prometheus_client] wrote batch of 28 metrics in 1.234869ms
2019-02-11T17:34:20Z D! [outputs.prometheus_client] buffer fullness: 0 / 10000 metrics.
2019-02-11T17:34:30Z D! [outputs.file] wrote batch of 28 metrics in 384.672µs
2019-02-11T17:34:30Z D! [outputs.file] buffer fullness: 0 / 10000 metrics.
2019-02-11T17:34:30Z D! [outputs.prometheus_client] wrote batch of 30 metrics in 1.250605ms
2019-02-11T17:34:30Z D! [outputs.prometheus_client] buffer fullness: 9 / 10000 metrics.
我在日志中没有看到问题。
The /metrics
Prometheus 服务器的端点导出有关服务器本身的指标,而不是从 telgraf 导出器等目标中抓取的指标。
Go to http://localhost:9090/targets
,您应该会看到 Prometheus 服务器正在抓取的目标列表。如果配置正确,telegraf 导出器应该是其中之一。
要查询 Prometheus 的 telegraf 导出器生成的指标,请导航到http://localhost:9090/graph
并输入例如cpu_time_user
在查询字段中。如果启用了 CPU 插件,它应该具有该指标和更多指标。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)