Puppet Class: prometheus

Summary

This module manages prometheus

Overview

Parameters:

  • configname (String[1]) (defaults to: 'prometheus.yaml')

    the name of the configfile, defaults to prometheus.yaml or prometheus.yml on most operating systems

  • manage_user (Boolean) (defaults to: true)

    Whether to create user for prometheus or rely on external code for that

  • user (String) (defaults to: 'prometheus')

    User running prometheus

  • manage_group (Boolean) (defaults to: true)

    Whether to create user for prometheus or rely on external code for that

  • purge_config_dir (Boolean) (defaults to: true)

    Purge config files no longer generated by Puppet

  • group (String) (defaults to: 'prometheus')

    Group under which prometheus is running

  • bin_dir (Stdlib::Absolutepath) (defaults to: '/usr/local/bin')

    Directory where binaries are located

  • shared_dir (Stdlib::Absolutepath) (defaults to: '/usr/local/share/prometheus')

    Directory where shared files are located

  • arch (String[1]) (defaults to: $facts['os']['architecture'])

    Architecture (amd64 or i386)

  • version (String) (defaults to: '2.30.3')

    Prometheus release

  • install_method (String) (defaults to: 'url')

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

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

    Operating system (linux is supported)

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

    Complete URL corresponding to the Prometheus release, default to undef

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

    Base URL for prometheus

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

    Extension of Prometheus binaries archive

  • package_name (String) (defaults to: 'prometheus')

    Prometheus package name - not available yet

  • package_ensure (String) (defaults to: 'latest')

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

  • config_dir (String) (defaults to: '/etc/prometheus')

    Prometheus configuration directory (default /etc/prometheus)

  • localstorage (Stdlib::Absolutepath) (defaults to: '/var/lib/prometheus')

    Location of prometheus local storage (storage.local argument)

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

    Extra options added to prometheus startup command

  • config_hash (Hash) (defaults to: {})

    Startup config hash

  • config_defaults (Hash) (defaults to: {})

    Startup config defaults

  • config_template (String) (defaults to: 'prometheus/prometheus.yaml.erb')

    Configuration template to use (template/prometheus.yaml.erb)

  • config_mode (String) (defaults to: '0640')

    Configuration file mode (default 0660)

  • service_enable (Boolean) (defaults to: true)

    Whether to enable or not prometheus service from puppet (default true)

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

    State ensured from prometheus service (default ‘running’)

  • service_name (String) (defaults to: 'prometheus')

    Name of the prometheus service (default ‘prometheus’)

  • manage_service (Boolean) (defaults to: true)

    Should puppet manage the prometheus service? (default true)

  • restart_on_change (Boolean) (defaults to: true)

    Should puppet restart prometheus on configuration change? (default true) Note: this applies only to command-line options changes. Configuration options are always reloaded without restarting.

  • init_style (Prometheus::Initstyle) (defaults to: $facts['service_provider'])

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

  • global_config (Hash) (defaults to: { 'scrape_interval' => '15s', 'evaluation_interval' => '15s', 'external_labels' => { 'monitor' => 'master' } })

    Prometheus global configuration variables

  • rule_files (Array) (defaults to: [])

    Prometheus rule files

  • scrape_configs (Array) (defaults to: [])

    Prometheus scrape configs

  • include_default_scrape_configs (Boolean) (defaults to: true)

    Include the module default scrape configs

  • remote_read_configs (Array) (defaults to: [])

    Prometheus remote_read config to scrape prometheus 1.8+ instances

  • remote_write_configs (Array) (defaults to: [])

    Prometheus remote_write config to scrape prometheus 1.8+ instances

  • enable_tracing (Boolean) (defaults to: false)

    Prometheus enables experimental tracing in Prometheus config file

  • tracing_config (Hash) (defaults to: {})

    Prometheus tracing configuration for the Prometheus config file

  • alerts (Variant[Array,Hash]) (defaults to: {})

    alert rules to put in alerts.rules

  • extra_alerts (Hash) (defaults to: {})

    Hash with extra alert rules to put in separate files.

  • alert_relabel_config (Array) (defaults to: [])

    Prometheus alert relabel config under alerting

  • alertmanagers_config (Array) (defaults to: [])

    Prometheus managers config under alerting

  • storage_retention (String) (defaults to: '360h')

    How long to keep timeseries data. This is given as a duration like “100h” or “14d”. Until prometheus 1.8.*, only durations understood by golang’s time.ParseDuration are supported. Starting with prometheus 2, durations can also be given in days, weeks and years.

  • external_url (Optional[Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[1]]]) (defaults to: undef)

    The URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If omitted, relevant URL components will be derived automatically.

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

    Custom command passed to the archive resource to extract the downloaded archive.

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

    Only collect scrape jobs tagged with this label. Allowing to split jobs over multiple prometheuses.

  • collect_scrape_jobs (Array[Hash[String[1], Any]]) (defaults to: [])

    Array of scrape_configs. Format, e.g.:

    • job_name: some_exporter scheme: https

    The jobs defined here will be used to collect resources exported via prometheus::daemon, creating the appropriate prometheus scrape configs for each endpoint. All scrape_config options can be passed as hash elements. Only the job_name is mandatory.

  • max_open_files (Optional[Integer]) (defaults to: undef)

    The maximum number of file descriptors for the prometheus server. Defaults to ‘undef`, but set to a large integer to override your default OS limit. Currently only implemented for systemd based service.

  • usershell (Stdlib::Absolutepath) (defaults to: '/usr/bin/nologin')

    if requested, we create a user for prometheus or the exporters. The default shell is nologin. It can be overwritten to any valid path.

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

    –web.listen-address=“0.0.0.0:9090” Address to listen on for UI, API, and telemetry.

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

    –web.read-timeout=5m Maximum duration before timing out read of the request, and closing idle connections.

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

    –web.max-connections=512 Maximum number of simultaneous connections.

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

    –web.route-prefix=<path> Prefix for the internal routes of web endpoints. Defaults to path of –web.external-url.

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

    –web.user-assets=<path> Path to static asset directory, available at /user.

  • web_enable_lifecycle (Boolean) (defaults to: false)

    –web.enable-lifecycle Enable shutdown and reload via HTTP request

  • web_enable_admin_api (Boolean) (defaults to: false)

    –web.enable-admin-api Enable API endpoints for admin control actions.

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

    –web.page-title=“Prometheus Time Series Collection and Processing Server” Document title of Prometheus instance.

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

    –web.cors.origin=“.*” Regex for CORS origin. It is fully anchored. Example: ‘https?://(domain1|domain2).com’

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

    –storage.tsdb.retention.size=STORAGE.TSDB.RETENTION.SIZE

    EXPERIMENTAL

    Maximum number of bytes that can be stored for blocks. Units supported: KB,

    MB, GB, TB, PB. This flag is experimental and can be changed in future releases.

  • storage_no_lockfile (Boolean) (defaults to: false)

    –storage.tsdb.no-lockfile Do not create lockfile in data directory.

  • storage_allow_overlapping_blocks (Boolean) (defaults to: false)

    –storage.tsdb.allow-overlapping-blocks

    EXPERIMENTAL

    Allow overlapping blocks, which in turn enables vertical compaction and

    vertical query merge.

  • storage_wal_compression (Boolean) (defaults to: false)

    –storage.tsdb.wal-compression Compress the tsdb WAL.

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

    –storage.remote.flush-deadline=<duration> How long to wait flushing sample on shutdown or config reload.

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

    –storage.remote.read-sample-limit=5e7 Maximum overall number of samples to return via the remote read interface, in a single query. 0 means no limit. This limit is ignored for streamed response types.

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

    –storage.remote.read-concurrent-limit=10 Maximum number of concurrent remote read calls. 0 means no limit.

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

    –storage.remote.read-max-bytes-in-frame=1048576 Maximum number of bytes in a single frame for streaming remote read response types before marshalling. Note that client might have limit on frame size as well. 1MB as recommended by protobuf by default.

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

    –rules.alert.for-outage-tolerance=1h Max time to tolerate prometheus outage for restoring “for” state of alert.

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

    –rules.alert.for-grace-period=10m Minimum duration between alert and restored “for” state. This is maintained only for alerts with configured “for” time greater than grace period.

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

    –rules.alert.resend-delay=1m Minimum amount of time to wait before resending an alert to Alertmanager.

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

    –alertmanager.notification-queue-capacity=10000 The capacity of the queue for pending Alertmanager notifications.

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

    –alertmanager.timeout=10s Timeout for sending alerts to Alertmanager.

  • alertmanager_url (Optional[String[1]]) (defaults to: undef)
    REMOVED, v1 ONLY

    -alertmanager.url

    Comma-separated list of Alertmanager URLs to send notifications to. In Prometheus v2, Alertmanager must be discovered via service discovery

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

    –query.lookback-delta=5m The maximum lookback duration for retrieving metrics during expression evaluations.

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

    –query.timeout=2m Maximum time a query may take before being aborted.

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

    –query.max-concurrency=20 Maximum number of queries executed concurrently.

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

    –query.max-samples=50000000 Maximum number of samples a single query can load into memory. Note that queries will fail if they try to load more samples than this into memory, so this also limits the number of samples a query can return.

  • query_staleness_delta (Optional[String[1]]) (defaults to: undef)
    REMOVED, v1 ONLY

    -query.staleness-delta=5m0s

    Staleness delta allowance during expression evaluations.

  • web_telemetry_path (Optional[String[1]]) (defaults to: undef)
    REMOVED, v1 ONLY

    -web.telemetry-path=“/metrics”

    Path under which to expose metrics

  • web_enable_remote_shutdown (Boolean) (defaults to: false)
    REMOVED, v1 ONLY

    -web.enable-remote-shutdown=false

    Enable remote service shutdown.

  • log_level (Optional[Enum['debug', 'info', 'warn', 'error', 'fatal']]) (defaults to: undef)

    –log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error] Value of ‘fatal’ is also allowed in prometheus v1

  • log_format (Optional[Enum['logfmt', 'json']]) (defaults to: undef)

    –log.format=logfmt Output format of log messages. One of: [logfmt, json]

  • config_show_diff (Boolean) (defaults to: true)

    Whether to show prometheus configuration file diff in the Puppet logs.

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

    Extra groups of which the user should be a part

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

    Optional proxy server, with port number if needed. ie: example.com:8080

  • proxy_type (Optional[Enum['none', 'http', 'https', 'ftp']]) (defaults to: undef)

    Optional proxy server type (none|http|https|ftp)

  • env_file_path (Stdlib::Absolutepath)
  • manage_config_dir (Boolean) (defaults to: true)
  • manage_init_file (Boolean) (defaults to: true)
  • manage_config (Boolean) (defaults to: true)
  • manage_localstorage (Boolean) (defaults to: true)
  • manage_prometheus_server (Boolean) (defaults to: false)


227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'manifests/init.pp', line 227

class prometheus (
  Stdlib::Absolutepath $env_file_path,
  Array $extra_groups = [],
  Hash $global_config = { 'scrape_interval' => '15s', 'evaluation_interval' => '15s', 'external_labels' => { 'monitor' => 'master' } },
  String $package_ensure = 'latest',
  String $package_name = 'prometheus',
  Array $rule_files = [],
  Array $scrape_configs = [],
  Array $remote_read_configs = [],
  Array $remote_write_configs = [],
  Boolean $enable_tracing = false,
  Hash $tracing_config = {},
  Stdlib::Absolutepath $shared_dir = '/usr/local/share/prometheus',
  String $storage_retention = '360h',
  String $user = 'prometheus',
  Prometheus::Uri $download_url_base = 'https://github.com/prometheus/prometheus/releases',
  Array $alertmanagers_config = [],
  Array $alert_relabel_config = [],
  String $download_extension = 'tar.gz',
  String $config_template = 'prometheus/prometheus.yaml.erb',
  String $config_mode = '0640',
  String $config_dir = '/etc/prometheus',
  Boolean $manage_config_dir = true,
  Boolean $manage_init_file = true,
  Variant[Array,Hash] $alerts = {},
  Boolean $manage_config = true,
  String $group = 'prometheus',
  Stdlib::Absolutepath $localstorage = '/var/lib/prometheus',
  Boolean $manage_localstorage                                                  = true,
  Stdlib::Absolutepath $bin_dir                                                 = '/usr/local/bin',
  String $version                                                               = '2.30.3',
  String $install_method                                                        = 'url',
  String $service_name                                                          = 'prometheus',
  Boolean $manage_prometheus_server                                             = false,
  Optional[String[1]] $extra_options                                            = undef,
  Optional[String] $download_url                                                = undef,
  Optional[String[1]] $extract_command                                          = undef,
  Stdlib::Absolutepath $usershell                                               = '/usr/bin/nologin',
  Optional[String[1]] $web_listen_address                                       = undef,
  Optional[String[1]] $web_read_timeout                                         = undef,
  Optional[String[1]] $web_max_connections                                      = undef,
  Optional[String[1]] $web_route_prefix                                         = undef,
  Optional[String[1]] $web_user_assets                                          = undef,
  Boolean $web_enable_lifecycle                                                 = false,
  Boolean $web_enable_admin_api                                                 = false,
  Optional[String[1]] $web_page_title                                           = undef,
  Optional[String[1]] $web_cors_origin                                          = undef,
  Optional[String[1]] $storage_retention_size                                   = undef,
  Boolean $storage_no_lockfile                                                  = false,
  Boolean $storage_allow_overlapping_blocks                                     = false,
  Boolean $storage_wal_compression                                              = false,
  Optional[String[1]] $storage_flush_deadline                                   = undef,
  Optional[String[1]] $storage_read_sample_limit                                = undef,
  Optional[String[1]] $storage_read_concurrent_limit                            = undef,
  Optional[String[1]] $storage_read_max_bytes_in_frame                          = undef,
  Optional[String[1]] $alert_for_outage_tolerance                               = undef,
  Optional[String[1]] $alert_for_grace_period                                   = undef,
  Optional[String[1]] $alert_resend_delay                                       = undef,
  Optional[String[1]] $alertmanager_notification_queue_capacity                 = undef,
  Optional[String[1]] $alertmanager_timeout                                     = undef,
  Optional[String[1]] $alertmanager_url                                         = undef, #v1 only
  Optional[String[1]] $query_lookback_delta                                     = undef,
  Optional[String[1]] $query_timeout                                            = undef,
  Optional[String[1]] $query_max_concurrency                                    = undef,
  Optional[String[1]] $query_max_samples                                        = undef,
  Optional[String[1]] $query_staleness_delta                                    = undef, #v1 only
  Optional[String[1]] $web_telemetry_path                                       = undef, #v1 only
  Boolean $web_enable_remote_shutdown                                           = false, #v1 only
  Optional[Enum['debug', 'info', 'warn', 'error', 'fatal']] $log_level          = undef,
  Optional[Enum['logfmt', 'json']] $log_format                                  = undef,
  Hash $extra_alerts                                                            = {},
  Hash $config_hash                                                             = {},
  Hash $config_defaults                                                         = {},
  String[1] $os                                                                 = downcase($facts['kernel']),
  Optional[Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[1]]] $external_url = undef,
  Array[Hash[String[1], Any]] $collect_scrape_jobs                              = [],
  Optional[String[1]] $collect_tag                                              = undef,
  Optional[Integer] $max_open_files                                             = undef,
  String[1] $configname                                                         = 'prometheus.yaml',
  Boolean $service_enable                                                       = true,
  Boolean $manage_service                                                       = true,
  Stdlib::Ensure::Service $service_ensure                                       = 'running',
  Boolean $restart_on_change                                                    = true,
  Prometheus::Initstyle $init_style                                             = $facts['service_provider'],
  String[1] $arch                                                               = $facts['os']['architecture'],
  Boolean $manage_group                                                         = true,
  Boolean $purge_config_dir                                                     = true,
  Boolean $manage_user                                                          = true,
  Boolean $config_show_diff                                                     = true,
  Boolean $include_default_scrape_configs                                       = true,
  Optional[String[1]] $proxy_server                                             = undef,
  Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type                    = undef,
) {
  $real_arch = $arch ? {
    'x86_64'  => 'amd64',
    'i386'    => '386',
    'aarch64' => 'arm64',
    'armv7l'  => 'armv7',
    'armv6l'  => 'armv6',
    'armv5l'  => 'armv5',
    default   => $arch,
  }

  if $manage_prometheus_server {
    include prometheus::server
  }
}