千家信息网

怎么编写Prometheus配置文件prometheus.yml

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,小编给大家分享一下怎么编写Prometheus配置文件prometheus.yml,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!默认情况下,二进制执行文件当前目录下,会有promet
千家信息网最后更新 2025年02月01日怎么编写Prometheus配置文件prometheus.yml

小编给大家分享一下怎么编写Prometheus配置文件prometheus.yml,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

默认情况下,二进制执行文件当前目录下,会有prometheus.yml这个配置文件,我们需要做的,就是将exporter的ip和端口号,按照固定格式填写到配置文件中并重启Prometheus。

如下例子,每注册一个exporter可以新增一个job,然后将对应的exporter机器的ip和端口号写到targets下:

scrape_configs:  # The job name is added as a label `job=` 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'    static_configs:      - targets:        - '172.31.182.140:9100'        - '172.31.182.141:9100'        - '172.31.182.142:9100'        - '172.31.182.143:9100'        - '172.31.182.144:9100'        - '172.31.182.145:9100'        - '172.31.182.146:9100'        - '172.31.182.147:9100'

看完了这篇文章,相信你对"怎么编写Prometheus配置文件prometheus.yml"有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!

0