--collector.textfile.directory 是 Prometheus 的 node_exporter 中的一个配置项,用来指定一个目录,node_exporter 将从该目录读取以文件形式存储的自定义指标。
这个功能非常有用,特别是在需要从本地或外部程序生成指标并将其暴露给 Prometheus 时。node_exporter 会定期扫描指定的目录,并且读取目录下的所有文本文件,这些文件的内容是符合 Prometheus 指标格式的。
这里写目录标题
示例
在/var/lib/prometheus/custom_metrics/创建my_customer_metric.prom文件,内容如下:
# HELP my_custom_metric Some custom metric
# TYPE my_custom_metric gauge
my_custom_metric 1234
你可以将这个文件保存在 /var/lib/prometheus/custom_metrics/ 目录下。然后在启动 node_exporter 时,通过配置 --collector.textfile.directory 参数来指定这个目录:
/usr/local/bin/node_exporter --web.listen-address=:9102 --collector.textfile.directory=/var/lib/prometheus/custom_metrics/
这时,node_exporter 会定期读取 /var/lib/prometheus/custom_metrics/ 目录下的所有.prom文件,并将其中的指标暴露给 Prometheus。
验证能够查询到自定义指标
[root@localhost ~]# curl -s http://192.168.188

最低0.47元/天 解锁文章
1277

被折叠的 条评论
为什么被折叠?



