multiple Prometheus.yml file in single machine

30 views
Skip to first unread message

karthigaa M

unread,
Sep 18, 2020, 5:58:07 AM9/18/20
to Prometheus Users
Is it possible to create multiple target file(prometheus.yml) file for a single prometheus machine?

My use case is I have one prometheus machne and configuring 5 projects in a single machine. Is it possible to split up their configurations into 5 prometheus.yml files?

Or any othey way to tackle this to split a file?

sayf.eddi...@gmail.com

unread,
Sep 18, 2020, 6:51:25 AM9/18/20
to Prometheus Users
Hello, You can simply run 5 instances of Prometheus each with its own configuration file, just make sure every instance is listening on a different port

Brian Candler

unread,
Sep 18, 2020, 1:42:53 PM9/18/20
to Prometheus Users
On Friday, 18 September 2020 10:58:07 UTC+1, karthigaa M wrote:
Is it possible to create multiple target file(prometheus.yml) file for a single prometheus machine?


Yes.  If you are currently using static_sd_configs in prometheus.yml, use file_sd_configs to put the targets in different files.  For example:

  - job_name: node
    file_sd_configs:
      - files:
        - /etc/prometheus/targets.d/nodes_east.yml
        - /etc/prometheus/targets.d/nodes_west.yml

The format of the target files is:

- targets:
    - 1.1.1.1
    - 2.2.2.2
  labels:
    foo: bar
- targets:
    - 3.3.3.3
    - 4.4.4.4
  labels:
    baz: qux

(labels are optional; if you include them, they are applied to all targets in that group)

Another advantage of target files is that if you change them, prometheus re-reads them automatically.  You don't need to send a HUP signal to prometheus.

karthigaa M

unread,
Sep 23, 2020, 2:24:51 AM9/23/20
to Prometheus Users

Do I have to create a  prometheus and targets.d folder in the /etc path (/etc/prometheus/targets.d).

Brian Candler

unread,
Sep 23, 2020, 4:21:26 AM9/23/20
to Prometheus Users
No, you can create the prometheus config and target files wherever you like on the filesystem.  (Wherever they are, the uid that prometheus is running as needs to have read access to them)
Reply all
Reply to author
Forward
0 new messages