我正在使用Prometheus进行监控,我有很多配置(我们的prometheus.yml主配置文件有8000多行)。
我想把这个文件划分成逻辑分组,这样就变得更易读了。我知道Prometheus不支持这样做,我们可以使用Ansible等配置管理系统。
有人对他们的Prometheus配置文件做了这样的处理吗?如果有,你是怎么做的?
假设你有很多节点要用不同的标签之类的东西去搜刮,prometheus支持基于文件的发现,你可以根据你的需要来组织它。我会在prometheus.yml内
- job_name: 'dummy' # it's mandatory
file_sd_configs:
- files:
- /etc/prometheus/file_sd/*.json
和json文件可以包含逻辑分组.example.json。
[
{
"targets": ["host:port"],
"labels": {
"job": "job_name",
"environment": "test_env",
"service": "test_service"
}
}
]
这里有一篇不错的博客文章 https:/www.robustperception.iousing-json-file-service-discovery-with-prometheus