Breaking down of one prometheus.yml file?

Viewed 2746

I am using Prometheus for our monitoring and I have a lot of configs (our prometheus.yml main config file is 8000+ lines long).

I would like to divide this out into logical groupings so that it becomes much readable. I came to know that Prometheus doesn't support this and we can use configuration management systems like Ansible.

Has anyone done this with their Prometheus config file? If so, how did you do it?

1 Answers

Assuming you have lots of node to scrape with different tags and such, prometheus support file based discovery which you can use to organize it according to your need. i would go with in prometheus.yml

- job_name: 'dummy' # it's mandatory
    file_sd_configs:
      - files:
        - /etc/prometheus/file_sd/*.json

and json file can contains logical grouping. example.json

[
  {
    "targets": ["host:port"],
    "labels": {
      "job": "job_name",
      "environment": "test_env",
      "service": "test_service"
    }
  }
]

Here is a nice Blog post about it https://www.robustperception.io/using-json-file-service-discovery-with-prometheus

Related