voxpupuli / puppet-prometheus

Puppet module for prometheus
https://forge.puppet.com/puppet/prometheus
Apache License 2.0
60 stars 242 forks source link

How does file_sd_configs work? #523

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi,

I have a docker instance of Prometheus and I am trying to recreate the config in Puppet. I am having difficulty understanding and implementing the file_sd_configs parameter. how can I define the following for a Prometheus node:

file_sd_configs:
      - files:
        - targets.json
        - puppet_targets.json

Contents:
[
  {
    "targets": [ "rbp01.Domain.com:9100" ],
    "labels": {
      "job": "node"
    }   
  },  
  {
    "targets": [ "rbp02.Domain.com:9100" ],
    "labels": {
      "job": "node"
    }   
  }, 
],

the above is what I currently use in my docker instance when creating those files manually under /etc/prometheus/file_sd_configs they are purged/removed on the next Puppet run

Unfortunately what I am trying to do is not documented

abctaylor commented 1 year ago

+1 for this being properly documented

abctaylor commented 1 year ago

For anyone who needs a solution:

node /^prometheus\d+-lon.core.example.net$/ {

  class { 'prometheus::server':
  version        => '2.4.3',

  global_config  => {
      'external_labels'     => {
        'monitor' => 'cluster',
        'prometheus_replica' => $trusted['hostname']
        },
  },
  scrape_configs => [
    {
      'job_name'        => 'linux_dmz_vm',
      'scrape_interval' => '10s',
      'scrape_timeout'  => '10s',
      'file_sd_configs'  => [
        { 'files' => [ '/etc/prometheus/linux_dmz_vm.yaml' ], }
      ],
    },
  ],
}