voxpupuli / puppet-prometheus

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

node_exporter change default port 9100 #708

Closed JJena closed 1 month ago

JJena commented 7 months ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Can't find option to change the default port 9100 where metrics are published. Node_exporter.pp also has no parameter to change the port. Tried scrape_port parameter but that doesn't change the port.

What are you seeing

Can't override default port 9100

What behaviour did you expect instead

Update README how to override default node_exporter port

Output log

Any additional information you'd like to impart

maxkerp commented 2 months ago

I just tripped over this myself today and for any other poor souls out there:

scrape_port is apparently only used for a scrape_job when you use $export_scrape_job, which in turn creates a scrape-job on the "real" prometheus host. That's how I understand it.

See: https://github.com/voxpupuli/puppet-prometheus/blob/master/manifests/daemon.pp#L284

What you wanna do is use --web.listen-address in extra_options to be passed to the binary.

  class { 'prometheus::node_exporter':
    version            => '1.7.0',
    collectors_enable  => ['systemd'],
    extra_options      => '--web.listen-address=":9101" --collector.systemd.unit-include=(.*).service',
  }

This does work and is mentioned for some exporters on the puppet-forge docs page, but it's hard to find and I would have expected it to be a parameter (listen_port?) too.

Unfortunately this isn't a consistent interface for the exporters. If you use the postgres_exporter for example, the parameter you need to use is only options.

class { 'prometheus::postgres_exporter' :
  options              => '--web.listen-address=":9102"',
  group                => 'postgres',
  user                 => 'postgres',
  postgres_auth_method => 'custom',
  data_source_custom   => {
    'DATA_SOURCE_NAME' => 'user=postgres host=/var/run/postgresql/ sslmode=disable',
  },
}
TheMeier commented 1 month ago

Duplicate of #692