Puppet Class: prometheus::frr_exporter

Inherits:
prometheus
Defined in:
manifests/frr_exporter.pp

Summary

This module manages prometheus FRR exporter

Overview

Examples:

configure frr_exporter to monitor BGP peers

class { 'prometheus::frr_exporter':
  peer_descriptions    => true,
  peer_types          => true,
  advertised_prefixes => true,
  frr_socket_dir      => '/var/run/frr',
  web_listen_address  => ':9342',
}

Parameters:

  • arch (String) (defaults to: $prometheus::real_arch)

    Architecture (amd64 or arm64)

  • bin_dir (Stdlib::Absolutepath) (defaults to: $prometheus::bin_dir)

    Directory where binaries are located

  • download_extension (String) (defaults to: 'tar.gz')

    Extension for the release binary archive

  • download_url (Optional[String]) (defaults to: undef)

    Complete URL corresponding to the where the release binary archive can be downloaded

  • download_url_base (Prometheus::Uri) (defaults to: 'https://github.com/tynany/frr_exporter/releases')

    Base URL for the binary archive

  • extra_groups (Array[String]) (defaults to: [])

    Extra groups to add the binary user to

  • extra_options (Optional[String[1]]) (defaults to: undef)

    Extra options added to the startup command

  • frr_socket_dir (String) (defaults to: '/var/run/frr')

    Path to FRR socket directory for BGP monitoring

  • group (String[1]) (defaults to: 'frr-exporter')

    Group under which the binary is running

  • init_style (Prometheus::Initstyle) (defaults to: $prometheus::init_style)

    Service startup scripts style (e.g. rc or systemd)

  • install_method (Prometheus::Install) (defaults to: $prometheus::install_method)

    Installation method: url or package (only url is supported currently)

  • log_level (String) (defaults to: 'info')

    Log level for the exporter

  • manage_group (Boolean) (defaults to: true)

    Whether to create a group for or rely on external code for that

  • manage_service (Boolean) (defaults to: true)

    Should puppet manage the service? (default true)

  • manage_user (Boolean) (defaults to: true)

    Whether to create user or rely on external code for that

  • advertised_prefixes (Boolean) (defaults to: false)

    Enable BGP advertised prefixes collection

  • bgp6 (Boolean) (defaults to: false)

    Enable the bgp6 collector

  • os (String[1]) (defaults to: downcase($facts['kernel']))

    Operating system (linux is the only one supported)

  • package_ensure (String[1]) (defaults to: 'latest')

    If package, then use this for package ensure default ‘latest’

  • package_name (String[1]) (defaults to: 'frr_exporter')

    The binary package name - not available yet

  • peer_descriptions (Boolean) (defaults to: true)

    Enable BGP peer descriptions collection

  • peer_types (Boolean) (defaults to: true)

    Enable BGP peer types collection

  • telemetry_path (String) (defaults to: '/metrics')

    Path to expose metrics

  • purge_config_dir (Boolean) (defaults to: true)

    Purge config files no longer generated by Puppet

  • restart_on_change (Boolean) (defaults to: true)

    Should puppet restart the service on configuration change? (default true)

  • service_enable (Boolean) (defaults to: true)

    Whether to enable the service from puppet (default true)

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')

    State ensured for the service (default ‘running’)

  • service_name (String[1]) (defaults to: 'frr_exporter')

    Name of the FRR exporter service

  • user (String[1]) (defaults to: 'frr-exporter')

    User which runs the service

  • version (String[1]) (defaults to: '1.9.0')

    The binary release version

  • web_listen_address (String) (defaults to: ':9342')

    Address to listen on for web interface and telemetry

  • env_vars (Hash[String[1], Scalar]) (defaults to: {})

    hash with custom environment variables thats passed to the exporter via init script / unit file

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Whether to install or remove the FRR exporter (default ‘present’)

See Also:

Author:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'manifests/frr_exporter.pp', line 84

class prometheus::frr_exporter (
  String $download_extension = 'tar.gz',
  Prometheus::Uri $download_url_base = 'https://github.com/tynany/frr_exporter/releases',
  Array[String] $extra_groups = [],
  String[1] $group = 'frr-exporter',
  String[1] $package_ensure = 'latest',
  String[1] $package_name = 'frr_exporter',
  String[1] $user = 'frr-exporter',
  # renovate: depName=tynany/frr_exporter
  String[1] $version = '1.9.0',
  Boolean $purge_config_dir = true,
  Boolean $restart_on_change = true,
  Boolean $service_enable = true,
  Stdlib::Ensure::Service $service_ensure = 'running',
  String[1] $service_name = 'frr_exporter',
  Prometheus::Initstyle $init_style = $prometheus::init_style,
  Prometheus::Install $install_method = $prometheus::install_method,
  Boolean $manage_group = true,
  Boolean $manage_service = true,
  Boolean $manage_user = true,
  String[1] $os = downcase($facts['kernel']),
  String $arch = $prometheus::real_arch,
  Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
  Optional[String[1]] $extra_options = undef,
  Optional[String] $download_url = undef,
  String $web_listen_address = ':9342',
  String $telemetry_path = '/metrics',
  String $frr_socket_dir = '/var/run/frr',
  Boolean $peer_descriptions = true,
  Boolean $peer_types = true,
  Boolean $advertised_prefixes = false,
  Boolean $bgp6 = false,
  String $log_level = 'info',
  Hash[String[1], Scalar] $env_vars = {},
  Enum['present', 'absent'] $ensure = 'present',
) inherits prometheus {
  $real_download_url = pick($download_url, "${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

  $notify_service = ($restart_on_change and $manage_service) ? {
    true  => Service[$service_name],
    default => undef,
  }

  # Build FRR-specific options
  $_frr_socket_dir_opt = "--frr.socket.dir-path=${frr_socket_dir}"
  $_listen_address_opt = "--web.listen-address=${web_listen_address}"
  $_telemetry_path_opt = "--web.telemetry-path=${telemetry_path}"
  $_log_level_opt = "--log.level=${log_level}"

  # Build collector options array
  $peer_descriptions_opt = $peer_descriptions ? {
    true  => ['--collector.bgp.peer-descriptions'],
    false => [],
  }
  $peer_types_opt = $peer_types ? {
    true  => ['--collector.bgp.peer-types'],
    false => [],
  }
  $advertised_prefixes_opt = $advertised_prefixes ? {
    true  => ['--collector.bgp.advertised-prefixes'],
    false => [],
  }
  $bgp6_opt = $bgp6 ? {
    true  => ['--collector.bgp6'],
    false => [],
  }
  $all_collector_opts = $peer_descriptions_opt + $peer_types_opt + $advertised_prefixes_opt + $bgp6_opt

  # Combine all options
  $all_opts = [$_frr_socket_dir_opt, $_listen_address_opt, $_telemetry_path_opt, $_log_level_opt] + $all_collector_opts
  $options = "${all_opts.join(' ')} ${extra_options}".strip()

  # Extract port from web_listen_address for scrape configuration
  $scrape_port_int = Integer(split($web_listen_address, ':')[-1])

  prometheus::daemon { $service_name:
    ensure             => $ensure,
    install_method     => $install_method,
    version            => $version,
    download_extension => $download_extension,
    os                 => $os,
    arch               => $arch,
    real_download_url  => $real_download_url,
    bin_dir            => $bin_dir,
    notify_service     => $notify_service,
    package_name       => $package_name,
    package_ensure     => $package_ensure,
    manage_user        => $manage_user,
    user               => $user,
    extra_groups       => $extra_groups,
    group              => $group,
    manage_group       => $manage_group,
    purge              => $purge_config_dir,
    options            => $options,
    init_style         => $init_style,
    service_ensure     => $service_ensure,
    service_enable     => $service_enable,
    manage_service     => $manage_service,
    env_vars           => $env_vars,
    env_file_path      => $prometheus::env_file_path,
    export_scrape_job  => false,
    scrape_host        => $facts['networking']['fqdn'],
    scrape_port        => $scrape_port_int,
    scrape_job_name    => 'frr',
    scrape_job_labels  => {},
    bin_name           => $package_name,
    archive_bin_path   => "/opt/${package_name}-${version}.${os}-${arch}/${package_name}",
  }
}