当前位置: 首页 > news >正文

node_exporter使用textfile collector收集业务数据

上一篇文章讲了使用Pushgateway收集业务数据的方法,今天讲另外一种方式textfile collector

The textfile collector is similar to the Pushgateway, in that it allows exporting of statistics from batch jobs. The Pushgateway should be used for service-level metrics. The textfile module is for metrics that are tied to a machine.

textfile collector 和 Pushgateway类似,都可以收集监控数据,二者的不同是 Pushgateway是一个独立的组件、textfile collector是node_exporter的附加功能,Pushgateway适用于service-level的job,textfile collector适用于machine-level的job。

textfile collector的功能就是,让node_exporter在收集数据时,顺带把指定目录下文件的内容 也加入到metrics里面


To use it, set the --collector.textfile.directory flag on the node_exporter commandline. The collector will parse all files in that directory matching the glob *.prom using the text format.

要使用textfile collector,需要在node_exporter的启动命令中增加参数--collector.textfile.directory=dir_path

例:./node_exporter --collector.textfile.directory=/root/prometheus/prom 这样node_exporter会把/root/prometheus/prom下所有 .prom 文件的内容一并收集到metrics

.prom 文件的内容格式是这样:

# HELP http_requests_total The total number of HTTP requests.
# TYPE http_requests_total counter
http_requests_total{method="post",code="200"} 1027
http_requests_total{method="post",code="400"}    3# A histogram, which has a pretty complex representation in the text format:
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320# Finally a summary, which has a complex representation, too:
# HELP rpc_duration_seconds A summary of the RPC duration in seconds.
# TYPE rpc_duration_seconds summary
rpc_duration_seconds{quantile="0.01"} 3102
rpc_duration_seconds{quantile="0.05"} 3272
rpc_duration_seconds{quantile="0.5"} 4773
rpc_duration_seconds{quantile="0.9"} 9001
rpc_duration_seconds{quantile="0.99"} 76656
rpc_duration_seconds_sum 1.7560473e+07
rpc_duration_seconds_count 2693

到prometheus页面就能查到上面的指标:

需要注意的是,如果不需要收集指标时,应该将对应的文件删除,否则node_exporter在每次收集数据时,将该文件的内容加入到metrics。(如上图,只要.prom文件没被删除或更新,就会搜到一堆不同时间戳下的重复值)

textfile collector是最简单的业务数据收集方式,不挑语言,只要有文件就行。

更多内容见官方文档


http://www.mrgr.cn/news/42821.html

相关文章:

  • PostgreSQL 创建账号与数据库:从连接到权限配置的完整指南
  • 绝对值得收藏!分享7款ai写作论文免费一键生成网站
  • 基于深度学习的视频生成
  • 算法笔记(九)——栈
  • 泛型编程--模板【C++提升】(特化、类属、参数包的展开、static、模板机制、重载......你想知道的全都有)
  • 10月4日刷题记录
  • C题(八)一个正整数的逆序打印(用循环结构实现)
  • CTK框架(十一):使用的常见问题
  • Pytorch最最适合研究生的入门教程,Q3 开始训练
  • 最新版本SkyWalking【10.1.0】部署
  • 计数相关的题 Python 力扣
  • 简码短链测试用例设计报告
  • Redis数据库与GO完结篇:redis操作总结与GO使用redis
  • 有没有一款软件,可以在二楼电脑直接唤醒三楼的电脑?
  • Java题集(从入门到精通)04
  • 基于Springboot+VUE的二手奢侈品商城的设计与实现
  • Python画笔案例-075 绘制趣味正方形
  • MATLAB|基于多主体主从博弈的区域综合能源系统低碳经济优化调度
  • 关键字:extern
  • 深入浅出:现代JavaScript开发者必知必会的Web性能优化技巧