puppet-prometheus icon indicating copy to clipboard operation
puppet-prometheus copied to clipboard

node_exporter change default port 9100

Open JJena opened this issue 1 year ago • 1 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7
  • Distribution: CentOS 7
  • Module version: 13.4.0

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

JJena avatar Dec 12 '23 16:12 JJena

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',
  },
}

maxkerp avatar Apr 16 '24 14:04 maxkerp

Duplicate of #692

TheMeier avatar May 25 '24 17:05 TheMeier