voxpupuli / puppet-prometheus

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

Trouble using prometheus::server::collect_tag. #707

Open Lveltmaat opened 10 months ago

Lveltmaat commented 10 months ago

Hi guys,

In our datacenter we have two different environments. Each has it's own prometheus server and can only reach it's own clients. We want to use the prometheus::collect_tag for this reason. We haven't been successfull in doing so.

We tried inspecting the code but were not able to find a way to fill the tag field, for example on a client running node exporter.

In the reference I couldn't find a way to fill in a tag.

A small portion of manifests/config.pp:

$node_tag = $prometheus::server::collect_tag ? {
  Undef   => 'prometheus::scrape_job',
  default => $prometheus::server::collect_tag,
}

Prometheus::Scrape_job <<| job_name == $job_name and tag == $node_tag |>> {
  collect_dir => "${prometheus::config_dir}/file_sd_config.d",
  notify      => Class['prometheus::service_reload'],
}

Are there examples of how the collect tag portion should work?

TheMeier commented 4 months ago

tag is a puppet metaparameter, see https://www.puppet.com/docs/puppet/6/metaparameter#tag. You simply set a costum tag on all exporter-resources eg like this:

class {'prometheus::node_exporter':
  tag => 'mytag',
}

and then set collect_tag to mytag on the prometheus::server that is dedicated to these resources.