From 4cf908d3a6ce14c62514ae6bd1ad3ad46164340d Mon Sep 17 00:00:00 2001 From: Dustin Hooten Date: Sat, 12 Oct 2019 10:33:16 -0600 Subject: [PATCH] Add prom command line args and validation --- manifests/config.pp | 169 ++++++++++++---- manifests/init.pp | 186 +++++++++++++++++- spec/classes/prometheus_spec.rb | 149 +++++++++++++- .../files/cli/prometheus1_all.systemd | 37 ++++ .../files/cli/prometheus1_extra.systemd | 23 +++ .../files/cli/prometheus2_all.systemd | 50 +++++ .../files/cli/prometheus2_extra.systemd | 22 +++ spec/fixtures/files/prometheus1.debian | 4 +- spec/fixtures/files/prometheus1.systemd | 4 +- spec/fixtures/files/prometheus1.sysv | 4 +- spec/fixtures/files/prometheus1.upstart | 4 +- spec/fixtures/files/prometheus2.debian | 4 +- spec/fixtures/files/prometheus2.systemd | 6 +- spec/fixtures/files/prometheus2.sysv | 4 +- spec/fixtures/files/prometheus2.upstart | 6 +- 15 files changed, 611 insertions(+), 61 deletions(-) create mode 100644 spec/fixtures/files/cli/prometheus1_all.systemd create mode 100644 spec/fixtures/files/cli/prometheus1_extra.systemd create mode 100644 spec/fixtures/files/cli/prometheus2_all.systemd create mode 100644 spec/fixtures/files/cli/prometheus2_extra.systemd diff --git a/manifests/config.pp b/manifests/config.pp index 59e0507f8..aa1cba0db 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -7,50 +7,147 @@ $max_open_files = $prometheus::max_open_files if $prometheus::server::init_style { - if( versioncmp($prometheus::server::version, '2.0.0') < 0 ){ - # helper variable indicating prometheus version, so we can use on this information in the template - $prometheus_v2 = false + $prometheus_v2 = versioncmp($prometheus::server::version, '2.0.0') >= 0 + + # Validation + $invalid_args = if $prometheus_v2 { + { + 'alertmanager.url' => $prometheus::alertmanager_url, + 'query.staleness-delta' => $prometheus::query_staleness_delta, + 'web.telemetry-path' => $prometheus::web_telemetry_path, + 'web.enable-remote-shutdown' => $prometheus::web_enable_remote_shutdown, + } + } else { + { + 'web.enable-lifecycle' => $prometheus::web_enable_lifecycle, + 'web.enable-admin-api' => $prometheus::web_enable_admin_api, + 'web.page-title' => $prometheus::web_page_title, + 'web.cors.origin' => $prometheus::web_cors_origin, + 'storage.tsdb.retention.size' => $prometheus::storage_retention_size, + 'storage.tsdb.no-lockfile' => $prometheus::storage_no_lockfile, + 'storage.tsdb.allow-overlapping-blocks' => $prometheus::storage_allow_overlapping_blocks, + 'storage.tsdb.wal-compression' => $prometheus::storage_wal_compression, + 'storage.remote.flush-deadline' => $prometheus::storage_flush_deadline, + 'storage.remote.read-concurrent-limit' => $prometheus::storage_read_concurrent_limit, + 'storage.remote.read-max-bytes-in-frame' => $prometheus::storage_read_max_bytes_in_frame, + 'rules.alert.for-outage-tolerance' => $prometheus::alert_for_outage_tolerance, + 'rules.alert.for-grace-period' => $prometheus::alert_for_grace_period, + 'rules.alert.resend-delay' => $prometheus::alert_resend_delay, + 'query.lookback-delta' => $prometheus::query_lookback_delta + } + } + + $invalid_options = $invalid_args + .filter |$key,$value| { $value or $key in $prometheus::server::extra_options} + .map |$key,$value| { $key } + + unless empty($invalid_options) { + $error_message = if $prometheus_v2 { + 'no longer available in prometheus v2' + } else { + 'require prometheus v2; consider upgrading' + } + $error = "invalid command line arguments: [${join($invalid_options, ', ')}] ${error_message}" + fail($error) + } + unless $prometheus_v2 { if $prometheus::server::remote_read_configs != [] { - fail('remote_read_configs requires prometheus 2.X') + fail('remote_read_configs requires prometheus v2') } if $prometheus::server::remote_write_configs != [] { - fail('remote_write_configs requires prometheus 2.X') - } - $_daemon_flags = [ - '-log.format logger:stdout', - "-config.file=${prometheus::server::config_dir}/${prometheus::server::configname}", - "-storage.local.path=${prometheus::server::localstorage}", - "-storage.local.retention=${prometheus::server::storage_retention}", - "-web.console.templates=${prometheus::shared_dir}/consoles", - "-web.console.libraries=${prometheus::shared_dir}/console_libraries", - ] - if $prometheus::server::extra_options { - $daemon_flags = $_daemon_flags + $prometheus::server::extra_options - } else { - $daemon_flags = $_daemon_flags + fail('remote_write_configs requires prometheus v2') + } + } + if ($prometheus_v2 and $prometheus::log_level == 'fatal') { + fail('fatal is no longer a valid value in prometheus v2') + } + + # Formatting + $v1_log_format = if ($prometheus::log_format == 'json') { '?json=true' } else { undef } + $web_page_title = if ($prometheus::web_page_title) { "\"${prometheus::web_page_title}\"" } else { undef } + $web_cors_origin = if ($prometheus::web_cors_origin) { "\"${prometheus::web_cors_origin}\"" } else { undef } + $command_line_flags = if $prometheus_v2 { + { + 'config.file' => "${prometheus::server::config_dir}/${prometheus::server::configname}", + 'web.listen-address' => $prometheus::web_listen_address, + 'web.read-timeout' => $prometheus::web_read_timeout, + 'web.max-connections' => $prometheus::web_max_connections, + 'web.external-url' => $prometheus::server::external_url, + 'web.route-prefix' => $prometheus::web_route_prefix, + 'web.user-assets' => $prometheus::web_user_assets, + 'web.enable-lifecycle' => $prometheus::web_enable_lifecycle, + 'web.enable-admin-api' => $prometheus::web_enable_admin_api, + 'web.console.templates' => "${prometheus::shared_dir}/consoles", + 'web.console.libraries' => "${prometheus::shared_dir}/console_libraries", + 'web.page-title' => $web_page_title, + 'web.cors.origin' => $web_cors_origin, + 'storage.tsdb.path' => $prometheus::server::localstorage, + 'storage.tsdb.retention.time' => $prometheus::server::storage_retention, + 'storage.tsdb.retention.size' => $prometheus::storage_retention_size, + 'storage.tsdb.no-lockfile' => $prometheus::storage_no_lockfile, + 'storage.tsdb.allow-overlapping-blocks' => $prometheus::storage_allow_overlapping_blocks, + 'storage.tsdb.wal-compression' => $prometheus::storage_wal_compression, + 'storage.remote.flush-deadline' => $prometheus::storage_flush_deadline, + 'storage.remote.read-sample-limit' => $prometheus::storage_read_sample_limit, + 'storage.remote.read-concurrent-limit' => $prometheus::storage_read_concurrent_limit, + 'storage.remote.read-max-bytes-in-frame' => $prometheus::storage_read_max_bytes_in_frame, + 'rules.alert.for-outage-tolerance' => $prometheus::alert_for_outage_tolerance, + 'rules.alert.for-grace-period' => $prometheus::alert_for_grace_period, + 'rules.alert.resend-delay' => $prometheus::alert_resend_delay, + 'alertmanager.notification-queue-capacity' => $prometheus::alertmanager_notification_queue_capacity, + 'alertmanager.timeout' => $prometheus::alertmanager_timeout, + 'query.lookback-delta' => $prometheus::query_lookback_delta, + 'query.timeout' => $prometheus::query_timeout, + 'query.max-concurrency' => $prometheus::query_max_concurrency, + 'query.max-samples' => $prometheus::query_max_samples, + 'log.level' => $prometheus::log_level, + 'log.format' => $prometheus::log_format } } else { - # helper variable indicating prometheus version, so we can use on this information in the template - $prometheus_v2 = true - $daemon_flags_basic = [ - "--config.file=${prometheus::server::config_dir}/${prometheus::server::configname}", - "--storage.tsdb.path=${prometheus::server::localstorage}", - "--storage.tsdb.retention=${prometheus::server::storage_retention}", - "--web.console.templates=${prometheus::server::shared_dir}/consoles", - "--web.console.libraries=${prometheus::server::shared_dir}/console_libraries", - ] - - if $prometheus::server::external_url { - $_daemon_flags = $daemon_flags_basic + "--web.external-url=${prometheus::server::external_url}" - } else { - $_daemon_flags = $daemon_flags_basic + { + 'config.file' => "${prometheus::server::config_dir}/${prometheus::server::configname}", + 'web.listen-address' => $prometheus::web_listen_address, + 'web.read-timeout' => $prometheus::web_read_timeout, + 'web.max-connections' => $prometheus::web_max_connections, + 'web.external-url' => $prometheus::server::external_url, + 'web.route-prefix' => $prometheus::web_route_prefix, + 'web.user-assets' => $prometheus::web_user_assets, + 'web.console.templates' => "${prometheus::shared_dir}/consoles", + 'web.console.libraries' => "${prometheus::shared_dir}/console_libraries", + 'web.telemetry-path' => $prometheus::web_telemetry_path, + 'web.enable-remote-shutdown' => $prometheus::web_enable_remote_shutdown, + 'storage.local.path' => $prometheus::server::localstorage, + 'storage.local.retention' => $prometheus::server::storage_retention, + 'alertmanager.notification-queue-capacity' => $prometheus::alertmanager_notification_queue_capacity, + 'alertmanager.timeout' => $prometheus::alertmanager_timeout, + 'alertmanager.url' => $prometheus::alertmanager_url, + 'query.timeout' => $prometheus::query_timeout, + 'query.max-concurrency' => $prometheus::query_max_concurrency, + 'query.staleness-delta' => $prometheus::query_staleness_delta, + 'log.level' => $prometheus::log_level, + 'log.format' => "\"logger:stdout${v1_log_format}\"" } - if $prometheus::server::extra_options { - $daemon_flags = $_daemon_flags + $prometheus::server::extra_options - } else { - $daemon_flags = $_daemon_flags + } + + $flag_prefix = if ($prometheus_v2) { '--' } else { '-' } + $extra_options = [$prometheus::server::extra_options].filter |$opts| { $opts and $opts != '' } + $flags = $command_line_flags + .filter |$flag, $value| { + $value ? { + Boolean => $value, + String => $value != '', + Undef => false, + default => fail("Illegal value for ${flag} parameter") + } + } + .map |$flag, $value| { + $value ? { + Boolean => "${flag_prefix}${flag}", + String => "${flag_prefix}${flag}=${value}", + default => fail("Illegal value for ${flag} parameter") } } + $daemon_flags = $flags + $extra_options # the vast majority of files here are init-files # so any change there should trigger a full service restart diff --git a/manifests/init.pp b/manifests/init.pp index c9ac78db3..30d27e236 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -149,6 +149,148 @@ # [*usershell*] # if requested, we create a user for prometheus or the exporters. The default # shell is nologin. It can be overwritten to any valid path. +# +# CLI ========================================================== +# The following parameters represent system parameters invoked as command-line flags +# during prometheus startup. Defaults are handled by Prometheus. +# +# [*web_listen_address*] +# --web.listen-address="0.0.0.0:9090" +# Address to listen on for UI, API, and telemetry. +# +# [*web_read_timeout*] +# --web.read-timeout=5m +# Maximum duration before timing out read of the request, and closing idle connections. +# +# [*web_max_connections*] +# --web.max-connections=512 +# Maximum number of simultaneous connections. +# +# [*web_route_prefix*] +# --web.route-prefix= +# Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url. +# +# [*web_user_assets*] +# --web.user-assets= +# Path to static asset directory, available at /user. +# +# [*web_enable_lifecycle*] +# --web.enable-lifecycle +# Enable shutdown and reload via HTTP request +# +# [*web_enable_admin_api*] +# --web.enable-admin-api +# Enable API endpoints for admin control actions. +# +# [*web_page_title*] +# --web.page-title="Prometheus Time Series Collection and Processing Server" +# Document title of Prometheus instance. +# +# [*web_cors_origin*] +# --web.cors.origin=".*" +# Regex for CORS origin. It is fully anchored. Example: 'https?://(domain1|domain2)\.com' +# +# [*storage_retention_size*] +# --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*] +# --storage.tsdb.no-lockfile +# Do not create lockfile in data directory. +# +# [*storage_allow_overlapping_blocks*] +# --storage.tsdb.allow-overlapping-blocks +# [EXPERIMENTAL] Allow overlapping blocks, which in turn enables vertical compaction and +# vertical query merge. +# +# [*storage_wal_compression*] +# --storage.tsdb.wal-compression +# Compress the tsdb WAL. +# +# [*storage_flush_deadline*] +# --storage.remote.flush-deadline= +# How long to wait flushing sample on shutdown or config reload. +# +# [*storage_read_sample_limit*] +# --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*] +# --storage.remote.read-concurrent-limit=10 +# Maximum number of concurrent remote read calls. 0 means no limit. +# +# [*storage_read_max_bytes_in_frame*] +# --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*] +# --rules.alert.for-outage-tolerance=1h +# Max time to tolerate prometheus outage for restoring "for" state of alert. +# +# [*alert_for_grace_period*] +# --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*] +# --rules.alert.resend-delay=1m +# Minimum amount of time to wait before resending an alert to Alertmanager. +# +# [*alertmanager_notification_queue_capacity*] +# --alertmanager.notification-queue-capacity=10000 +# The capacity of the queue for pending Alertmanager notifications. +# +# [*alertmanager_timeout*] +# --alertmanager.timeout=10s +# Timeout for sending alerts to Alertmanager. +# +# [*alertmanager_url*] +# [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*] +# --query.lookback-delta=5m +# The maximum lookback duration for retrieving metrics during expression evaluations. +# +# [*query_timeout*] +# --query.timeout=2m +# Maximum time a query may take before being aborted. +# +# [*query_max_concurrency*] +# --query.max-concurrency=20 +# Maximum number of queries executed concurrently. +# +# [*query_max_samples*] +# --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*] +# [REMOVED, v1 ONLY] -query.staleness-delta=5m0s +# Staleness delta allowance during expression evaluations. +# +# [*web_telemetry_path*] +# [REMOVED, v1 ONLY] -web.telemetry-path="/metrics" +# Path under which to expose metrics +# +# [*web_enable_remote_shutdown*] +# [REMOVED, v1 ONLY] -web.enable-remote-shutdown=false +# Enable remote service shutdown. +# +# [*log_level*] +# --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*] +# --log.format=logfmt +# Output format of log messages. One of: [logfmt, json] # # Actions: # @@ -198,13 +340,45 @@ Optional[String[1]] $extract_command, Boolean $manage_config, Stdlib::Absolutepath $usershell, - Hash $extra_alerts = {}, - Hash $config_hash = {}, - Hash $config_defaults = {}, - String $os = downcase($facts['kernel']), + Optional[String] $web_listen_address = undef, + Optional[String] $web_read_timeout = undef, + Optional[String] $web_max_connections = undef, + Optional[String] $web_route_prefix = undef, + Optional[String] $web_user_assets = undef, + Optional[Boolean] $web_enable_lifecycle = undef, + Optional[Boolean] $web_enable_admin_api = undef, + Optional[String] $web_page_title = undef, + Optional[String] $web_cors_origin = undef, + Optional[String] $storage_retention_size = undef, + Optional[Boolean] $storage_no_lockfile = undef, + Optional[Boolean] $storage_allow_overlapping_blocks = undef, + Optional[Boolean] $storage_wal_compression = undef, + Optional[String] $storage_flush_deadline = undef, + Optional[String] $storage_read_sample_limit = undef, + Optional[String] $storage_read_concurrent_limit = undef, + Optional[String] $storage_read_max_bytes_in_frame = undef, + Optional[String] $alert_for_outage_tolerance = undef, + Optional[String] $alert_for_grace_period = undef, + Optional[String] $alert_resend_delay = undef, + Optional[String] $alertmanager_notification_queue_capacity = undef, + Optional[String] $alertmanager_timeout = undef, + Optional[String] $alertmanager_url = undef, #v1 only + Optional[String] $query_lookback_delta = undef, + Optional[String] $query_timeout = undef, + Optional[String] $query_max_concurrency = undef, + Optional[String] $query_max_samples = undef, + Optional[String] $query_staleness_delta = undef, #v1 only + Optional[String] $web_telemetry_path = undef, #v1 only + Optional[Boolean] $web_enable_remote_shutdown = undef, #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 $os = downcase($facts['kernel']), Optional[Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[1]]] $external_url = undef, - Optional[Array[Hash[String[1], Any]]] $collect_scrape_jobs = [], - Optional[Integer] $max_open_files = undef, + Optional[Array[Hash[String[1], Any]]] $collect_scrape_jobs = [], + Optional[Integer] $max_open_files = undef, ) { case $arch { diff --git a/spec/classes/prometheus_spec.rb b/spec/classes/prometheus_spec.rb index 1265a64a8..2c56affe5 100644 --- a/spec/classes/prometheus_spec.rb +++ b/spec/classes/prometheus_spec.rb @@ -119,7 +119,9 @@ elsif ['centos-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'archlinux-5-x86_64'].include?(os) # init_style = 'systemd' - it { is_expected.to contain_class('systemd') } + it { + is_expected.to contain_class('systemd') + } it { is_expected.to contain_systemd__unit_file('prometheus.service').with( @@ -327,6 +329,151 @@ end end end + context 'command-line flags' do + context 'prometheus v2' do + version = '2.13.0' + context 'with all valid params' do + let(:params) do + { + manage_prometheus_server: true, + version: version, + init_style: 'systemd', + bin_dir: '/usr/local/bin', + config_dir: '/etc/prometheus', + configname: 'prometheus_123.yaml', + shared_dir: '/opt/prometheus', + external_url: 'https://prometheus.reverse-proxy.company.systems', + web_listen_address: '127.0.0.1:9099', + web_read_timeout: '2m', + web_max_connections: '256', + web_route_prefix: 'internal', + web_user_assets: 'static', + web_enable_lifecycle: true, + web_enable_admin_api: true, + web_page_title: 'My Company Prometheus', + web_cors_origin: 'https?://(domain1|domain2)\.com', + localstorage: '/opt/prometheus/data/', + storage_retention: '14d', + storage_retention_size: '50GB', + storage_no_lockfile: true, + storage_allow_overlapping_blocks: true, + storage_wal_compression: true, + storage_flush_deadline: '5m', + storage_read_sample_limit: '5e8', + storage_read_concurrent_limit: '8', + storage_read_max_bytes_in_frame: '1000000', + alert_for_outage_tolerance: '25m', + alert_for_grace_period: '3m', + alert_resend_delay: '2m', + alertmanager_notification_queue_capacity: '10000', + alertmanager_timeout: '10s', + query_lookback_delta: '5m', + query_timeout: '2m', + query_max_concurrency: '30', + query_max_samples: '10000000', + log_level: 'info', + log_format: 'json' + } + end + + it { + is_expected.to contain_file('/etc/systemd/system/prometheus.service').with( + 'ensure' => 'file', + 'mode' => '0444', + 'owner' => 'root', + 'group' => 'root', + 'content' => File.read(fixtures('files/cli', 'prometheus2_all.systemd')) + ) + } + end + context 'with extra args write-in' do + let(:params) do + { + manage_prometheus_server: true, + version: version, + init_style: 'systemd', + bin_dir: '/usr/local/bin', + extra_options: '--web.enable-admin-api' + } + end + + it { + is_expected.to contain_file('/etc/systemd/system/prometheus.service').with( + 'ensure' => 'file', + 'mode' => '0444', + 'owner' => 'root', + 'group' => 'root', + 'content' => File.read(fixtures('files/cli', 'prometheus2_extra.systemd')) + ) + } + end + end + context 'prometheus v1' do + version = '1.7.0' + context 'with extra args write-in' do + let(:params) do + { + manage_prometheus_server: true, + version: version, + init_style: 'systemd', + bin_dir: '/usr/local/bin', + extra_options: '-web.telemetry-path=/metrics' + } + end + + it { + is_expected.to contain_file('/etc/systemd/system/prometheus.service').with( + 'ensure' => 'file', + 'mode' => '0444', + 'owner' => 'root', + 'group' => 'root', + 'content' => File.read(fixtures('files/cli', 'prometheus1_extra.systemd')) + ) + } + end + context 'with all valid params' do + let(:params) do + { + manage_prometheus_server: true, + version: version, + init_style: 'systemd', + bin_dir: '/usr/local/bin', + config_dir: '/etc/prometheus', + configname: 'prometheus_123.yaml', + shared_dir: '/opt/prometheus', + external_url: 'https://prometheus.reverse-proxy.company.systems', + web_listen_address: '127.0.0.1:9099', + web_read_timeout: '2m', + web_max_connections: '256', + web_route_prefix: 'internal', + web_user_assets: 'static', + web_telemetry_path: '/telemetry', + web_enable_remote_shutdown: true, + localstorage: '/opt/prometheus/data/', + storage_retention: '14d', + alertmanager_notification_queue_capacity: '10000', + alertmanager_timeout: '10s', + alertmanager_url: 'https://alertmanager.company.systems', + query_timeout: '2m', + query_max_concurrency: '30', + query_staleness_delta: '5m', + log_level: 'fatal', + log_format: 'json' + } + end + + it { + is_expected.to contain_file('/etc/systemd/system/prometheus.service').with( + 'ensure' => 'file', + 'mode' => '0444', + 'owner' => 'root', + 'group' => 'root', + 'content' => File.read(fixtures('files/cli', 'prometheus1_all.systemd')) + ) + } + end + end + end end end end diff --git a/spec/fixtures/files/cli/prometheus1_all.systemd b/spec/fixtures/files/cli/prometheus1_all.systemd new file mode 100644 index 000000000..8064c28e2 --- /dev/null +++ b/spec/fixtures/files/cli/prometheus1_all.systemd @@ -0,0 +1,37 @@ +# THIS FILE IS MANAGED BY PUPPET +[Unit] +Description=Prometheus Monitoring framework +Wants=basic.target +After=basic.target network.target + +[Service] +User=prometheus +Group=prometheus +ExecStart=/usr/local/bin/prometheus \ + -config.file=/etc/prometheus/prometheus_123.yaml \ + -web.listen-address=127.0.0.1:9099 \ + -web.read-timeout=2m \ + -web.max-connections=256 \ + -web.external-url=https://prometheus.reverse-proxy.company.systems \ + -web.route-prefix=internal \ + -web.user-assets=static \ + -web.console.templates=/opt/prometheus/consoles \ + -web.console.libraries=/opt/prometheus/console_libraries \ + -web.telemetry-path=/telemetry \ + -web.enable-remote-shutdown \ + -storage.local.path=/opt/prometheus/data/ \ + -storage.local.retention=14d \ + -alertmanager.notification-queue-capacity=10000 \ + -alertmanager.timeout=10s \ + -alertmanager.url=https://alertmanager.company.systems \ + -query.timeout=2m \ + -query.max-concurrency=30 \ + -query.staleness-delta=5m \ + -log.level=fatal \ + -log.format="logger:stdout?json=true" +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/spec/fixtures/files/cli/prometheus1_extra.systemd b/spec/fixtures/files/cli/prometheus1_extra.systemd new file mode 100644 index 000000000..396cbfab9 --- /dev/null +++ b/spec/fixtures/files/cli/prometheus1_extra.systemd @@ -0,0 +1,23 @@ +# THIS FILE IS MANAGED BY PUPPET +[Unit] +Description=Prometheus Monitoring framework +Wants=basic.target +After=basic.target network.target + +[Service] +User=prometheus +Group=prometheus +ExecStart=/usr/local/bin/prometheus \ + -config.file=/etc/prometheus/prometheus.yaml \ + -web.console.templates=/usr/local/share/prometheus/consoles \ + -web.console.libraries=/usr/local/share/prometheus/console_libraries \ + -storage.local.path=/var/lib/prometheus \ + -storage.local.retention=360h \ + -log.format="logger:stdout" \ + -web.telemetry-path=/metrics +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/spec/fixtures/files/cli/prometheus2_all.systemd b/spec/fixtures/files/cli/prometheus2_all.systemd new file mode 100644 index 000000000..e1be210e4 --- /dev/null +++ b/spec/fixtures/files/cli/prometheus2_all.systemd @@ -0,0 +1,50 @@ +# THIS FILE IS MANAGED BY PUPPET +[Unit] +Description=Prometheus Monitoring framework +Wants=basic.target +After=basic.target network.target + +[Service] +User=prometheus +Group=prometheus +ExecStart=/usr/local/bin/prometheus \ + --config.file=/etc/prometheus/prometheus_123.yaml \ + --web.listen-address=127.0.0.1:9099 \ + --web.read-timeout=2m \ + --web.max-connections=256 \ + --web.external-url=https://prometheus.reverse-proxy.company.systems \ + --web.route-prefix=internal \ + --web.user-assets=static \ + --web.enable-lifecycle \ + --web.enable-admin-api \ + --web.console.templates=/opt/prometheus/consoles \ + --web.console.libraries=/opt/prometheus/console_libraries \ + --web.page-title="My Company Prometheus" \ + --web.cors.origin="https?://(domain1|domain2)\.com" \ + --storage.tsdb.path=/opt/prometheus/data/ \ + --storage.tsdb.retention.time=14d \ + --storage.tsdb.retention.size=50GB \ + --storage.tsdb.no-lockfile \ + --storage.tsdb.allow-overlapping-blocks \ + --storage.tsdb.wal-compression \ + --storage.remote.flush-deadline=5m \ + --storage.remote.read-sample-limit=5e8 \ + --storage.remote.read-concurrent-limit=8 \ + --storage.remote.read-max-bytes-in-frame=1000000 \ + --rules.alert.for-outage-tolerance=25m \ + --rules.alert.for-grace-period=3m \ + --rules.alert.resend-delay=2m \ + --alertmanager.notification-queue-capacity=10000 \ + --alertmanager.timeout=10s \ + --query.lookback-delta=5m \ + --query.timeout=2m \ + --query.max-concurrency=30 \ + --query.max-samples=10000000 \ + --log.level=info \ + --log.format=json +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/spec/fixtures/files/cli/prometheus2_extra.systemd b/spec/fixtures/files/cli/prometheus2_extra.systemd new file mode 100644 index 000000000..d8373f391 --- /dev/null +++ b/spec/fixtures/files/cli/prometheus2_extra.systemd @@ -0,0 +1,22 @@ +# THIS FILE IS MANAGED BY PUPPET +[Unit] +Description=Prometheus Monitoring framework +Wants=basic.target +After=basic.target network.target + +[Service] +User=prometheus +Group=prometheus +ExecStart=/usr/local/bin/prometheus \ + --config.file=/etc/prometheus/prometheus.yaml \ + --web.console.templates=/usr/local/share/prometheus/consoles \ + --web.console.libraries=/usr/local/share/prometheus/console_libraries \ + --storage.tsdb.path=/var/lib/prometheus \ + --storage.tsdb.retention.time=360h \ + --web.enable-admin-api +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/spec/fixtures/files/prometheus1.debian b/spec/fixtures/files/prometheus1.debian index 559a3e7ac..ec50bf423 100644 --- a/spec/fixtures/files/prometheus1.debian +++ b/spec/fixtures/files/prometheus1.debian @@ -19,10 +19,10 @@ NAME=prometheus DAEMON=/usr/local/bin/$NAME PIDFILE=/var/run/$NAME/$NAME.pid DAEMON_ARGS="-config.file=/etc/prometheus/prometheus.yaml - -storage.local.path=/var/lib/prometheus - -storage.local.retention=360h -web.console.templates=/usr/local/share/prometheus/consoles -web.console.libraries=/usr/local/share/prometheus/console_libraries + -storage.local.path=/var/lib/prometheus + -storage.local.retention=360h " USER=prometheus SCRIPTNAME=/etc/init.d/$NAME diff --git a/spec/fixtures/files/prometheus1.systemd b/spec/fixtures/files/prometheus1.systemd index 7910c347d..26abc1fe3 100644 --- a/spec/fixtures/files/prometheus1.systemd +++ b/spec/fixtures/files/prometheus1.systemd @@ -8,10 +8,10 @@ User=prometheus Group=prometheus ExecStart=/usr/local/bin/prometheus \ -config.file=/etc/prometheus/prometheus.yaml \ - -storage.local.path=/var/lib/prometheus \ - -storage.local.retention=360h \ -web.console.templates=/usr/local/share/prometheus/consoles \ -web.console.libraries=/usr/local/share/prometheus/console_libraries \ + -storage.local.path=/var/lib/prometheus \ + -storage.local.retention=360h \ ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/spec/fixtures/files/prometheus1.sysv b/spec/fixtures/files/prometheus1.sysv index e52abbe06..d7f1cb793 100644 --- a/spec/fixtures/files/prometheus1.sysv +++ b/spec/fixtures/files/prometheus1.sysv @@ -52,10 +52,10 @@ start() { daemon --user=prometheus \ --pidfile="$PID_FILE" \ "$DAEMON" -log.format logger:stdout -config.file=/etc/prometheus/prometheus.yaml \ - -storage.local.path=/var/lib/prometheus \ - -storage.local.retention=360h \ -web.console.templates=/usr/local/share/prometheus/consoles \ -web.console.libraries=/usr/local/share/prometheus/console_libraries \ + -storage.local.path=/var/lib/prometheus \ + -storage.local.retention=360h \ >> "$LOG_FILE" & retcode=$? mkpidfile diff --git a/spec/fixtures/files/prometheus1.upstart b/spec/fixtures/files/prometheus1.upstart index c0eb31e07..6b051c659 100644 --- a/spec/fixtures/files/prometheus1.upstart +++ b/spec/fixtures/files/prometheus1.upstart @@ -23,10 +23,10 @@ script export GOMAXPROCS=${GOMAXPROCS:-2} exec start-stop-daemon --chuid $USER $GROUP --pidfile $PID_FILE --exec $PROMETHEUS --start -- -config.file=/etc/prometheus/prometheus.yaml \ - -storage.local.path=/var/lib/prometheus \ - -storage.local.retention=360h \ -web.console.templates=/usr/local/share/prometheus/consoles \ -web.console.libraries=/usr/local/share/prometheus/console_libraries \ + -storage.local.path=/var/lib/prometheus \ + -storage.local.retention=360h \ end script diff --git a/spec/fixtures/files/prometheus2.debian b/spec/fixtures/files/prometheus2.debian index 89976cf33..9b192039b 100644 --- a/spec/fixtures/files/prometheus2.debian +++ b/spec/fixtures/files/prometheus2.debian @@ -19,10 +19,10 @@ NAME=prometheus DAEMON=/usr/local/bin/$NAME PIDFILE=/var/run/$NAME/$NAME.pid DAEMON_ARGS="--config.file=/etc/prometheus/prometheus.yaml - --storage.tsdb.path=/var/lib/prometheus - --storage.tsdb.retention=360h --web.console.templates=/usr/local/share/prometheus/consoles --web.console.libraries=/usr/local/share/prometheus/console_libraries + --storage.tsdb.path=/var/lib/prometheus + --storage.tsdb.retention.time=360h " USER=prometheus SCRIPTNAME=/etc/init.d/$NAME diff --git a/spec/fixtures/files/prometheus2.systemd b/spec/fixtures/files/prometheus2.systemd index df71a4d17..a1e385f12 100644 --- a/spec/fixtures/files/prometheus2.systemd +++ b/spec/fixtures/files/prometheus2.systemd @@ -9,10 +9,10 @@ User=prometheus Group=prometheus ExecStart=/usr/local/bin/prometheus \ --config.file=/etc/prometheus/prometheus.yaml \ - --storage.tsdb.path=/var/lib/prometheus \ - --storage.tsdb.retention=360h \ --web.console.templates=/usr/local/share/prometheus/consoles \ - --web.console.libraries=/usr/local/share/prometheus/console_libraries + --web.console.libraries=/usr/local/share/prometheus/console_libraries \ + --storage.tsdb.path=/var/lib/prometheus \ + --storage.tsdb.retention.time=360h ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=always diff --git a/spec/fixtures/files/prometheus2.sysv b/spec/fixtures/files/prometheus2.sysv index 46cde890f..b7f904441 100644 --- a/spec/fixtures/files/prometheus2.sysv +++ b/spec/fixtures/files/prometheus2.sysv @@ -52,10 +52,10 @@ start() { daemon --user=prometheus \ --pidfile="$PID_FILE" \ "$DAEMON" --config.file=/etc/prometheus/prometheus.yaml \ - --storage.tsdb.path=/var/lib/prometheus \ - --storage.tsdb.retention=360h \ --web.console.templates=/usr/local/share/prometheus/consoles \ --web.console.libraries=/usr/local/share/prometheus/console_libraries \ + --storage.tsdb.path=/var/lib/prometheus \ + --storage.tsdb.retention.time=360h \ >> "$LOG_FILE" & retcode=$? mkpidfile diff --git a/spec/fixtures/files/prometheus2.upstart b/spec/fixtures/files/prometheus2.upstart index d68c35172..6d8c176e7 100644 --- a/spec/fixtures/files/prometheus2.upstart +++ b/spec/fixtures/files/prometheus2.upstart @@ -23,10 +23,10 @@ script export GOMAXPROCS=${GOMAXPROCS:-2} exec start-stop-daemon --chuid $USER --group $GROUP --pidfile $PID_FILE --exec $PROMETHEUS --start -- --config.file=/etc/prometheus/prometheus.yaml \ - --storage.tsdb.path=/var/lib/prometheus \ - --storage.tsdb.retention=360h \ --web.console.templates=/usr/local/share/prometheus/consoles \ - --web.console.libraries=/usr/local/share/prometheus/console_libraries + --web.console.libraries=/usr/local/share/prometheus/console_libraries \ + --storage.tsdb.path=/var/lib/prometheus \ + --storage.tsdb.retention.time=360h end script respawn