From 2ec4fbdd265280c822192dd576900a88ed716643 Mon Sep 17 00:00:00 2001 From: Witek Bedyk Date: Thu, 22 Aug 2024 17:10:30 +0200 Subject: [PATCH] [exporters] Refactor systemd configuration --- Makefile | 2 +- .../prometheus-exporters-formula.changes | 7 + .../prometheus-exporters-formula.spec | 2 +- .../files/apache-exporter-config.Debian | 15 -- .../files/apache-exporter-config.RedHat | 9 -- .../files/apache-exporter-config.Suse | 9 -- .../files/apache-exporter-systemd.config | 3 + .../files/node-exporter-config.Debian | 128 ------------------ .../files/node-exporter-config.RedHat | 9 -- .../files/node-exporter-config.Suse | 9 -- .../files/node-exporter-systemd.config | 1 + .../files/postgres-exporter-config.RedHat | 27 ---- .../files/postgres-exporter-config.Suse | 27 ---- ...ebian => postgres-exporter-systemd.config} | 0 .../prometheus-exporters/init.sls | 10 +- .../prometheus-exporters/map.jinja | 6 +- 16 files changed, 23 insertions(+), 241 deletions(-) delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Debian delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.RedHat delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Suse create mode 100644 prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-systemd.config delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Debian delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.RedHat delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Suse create mode 100644 prometheus-exporters-formula/prometheus-exporters/files/node-exporter-systemd.config delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.RedHat delete mode 100644 prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Suse rename prometheus-exporters-formula/prometheus-exporters/files/{postgres-exporter-config.Debian => postgres-exporter-systemd.config} (100%) diff --git a/Makefile b/Makefile index f4fde56..5e26c08 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ LOCALE_VERSION=0.3 CPU_MITIGATIONS_VERSION=0.5.0 PROMETHEUS_VERSION=0.8.0 -PROMETHEUS_EXPORTERS_VERSION=1.4.1 +PROMETHEUS_EXPORTERS_VERSION=1.5.0 GRAFANA_VERSION=0.11.0 VIRTUALIZATION_VERSION=0.6.2 SYSTEM_LOCK_VERSION=0.1 diff --git a/prometheus-exporters-formula/prometheus-exporters-formula.changes b/prometheus-exporters-formula/prometheus-exporters-formula.changes index c1e0655..d0c7627 100644 --- a/prometheus-exporters-formula/prometheus-exporters-formula.changes +++ b/prometheus-exporters-formula/prometheus-exporters-formula.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Aug 22 13:49:43 UTC 2024 - Witek Bedyk + +- Version 1.5.0 + * Set Environment= instead of EnvironmentFile= in systemd + configuration files + ------------------------------------------------------------------- Tue Jun 25 13:19:00 UTC 2024 - Witek Bedyk diff --git a/prometheus-exporters-formula/prometheus-exporters-formula.spec b/prometheus-exporters-formula/prometheus-exporters-formula.spec index 05afdef..92421fb 100644 --- a/prometheus-exporters-formula/prometheus-exporters-formula.spec +++ b/prometheus-exporters-formula/prometheus-exporters-formula.spec @@ -18,7 +18,7 @@ %define fname prometheus-exporters %define fdir %{_datadir}/susemanager/formulas Name: prometheus-exporters-formula -Version: 1.4.1 +Version: 1.5.0 Release: 0 Summary: Salt formula for installing and configuring Prometheus exporters License: Apache-2.0 diff --git a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Debian b/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Debian deleted file mode 100644 index d09f1e3..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Debian +++ /dev/null @@ -1,15 +0,0 @@ -# Set the command-line arguments to pass to the server. -ARGS={{ args }} - -#Usage of prometheus-apache-exporter: -# -host_override string -# Override for HTTP Host header; empty string for no override. -# -insecure -# Ignore server certificate if using https. -# -scrape_uri string -# URI to apache stub status page. (default -# "http://localhost/server-status/?auto") -# -telemetry.address string -# Address on which to expose metrics. (default ":9117") -# -telemetry.endpoint string -# Path under which to expose metrics. (default "/metrics") diff --git a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.RedHat b/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.RedHat deleted file mode 100644 index aeb2377..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.RedHat +++ /dev/null @@ -1,9 +0,0 @@ -## Path: Applications/ApacheExporter -## Description: Prometheus exporter for apache metrics -## Type: string() -## Default: "" -## ServiceRestart: prometheus-apache_exporter -# -# Arguments for running prometheus-apache_exporter -# -ARGS={{ args }} diff --git a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Suse b/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Suse deleted file mode 100644 index aeb2377..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-config.Suse +++ /dev/null @@ -1,9 +0,0 @@ -## Path: Applications/ApacheExporter -## Description: Prometheus exporter for apache metrics -## Type: string() -## Default: "" -## ServiceRestart: prometheus-apache_exporter -# -# Arguments for running prometheus-apache_exporter -# -ARGS={{ args }} diff --git a/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-systemd.config b/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-systemd.config new file mode 100644 index 0000000..06be3fd --- /dev/null +++ b/prometheus-exporters-formula/prometheus-exporters/files/apache-exporter-systemd.config @@ -0,0 +1,3 @@ +[Service] +EnvironmentFile= +Environment="ARGS={{ args }}" diff --git a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Debian b/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Debian deleted file mode 100644 index 5d6924d..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Debian +++ /dev/null @@ -1,128 +0,0 @@ -# Set the command-line arguments to pass to the server. -# Due to shell scaping, to pass backslashes for regexes, you need to double -# them (\\d for \d). If running under systemd, you need to double them again -# (\\\\d to mean \d), and escape newlines too. -ARGS={{ args }} - -# Prometheus-node-exporter supports the following options: -# -# --collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$" -# Regexp of devices to ignore for diskstats. -# --collector.filesystem.ignored-mount-points="^/(dev|proc|run|sys|mnt|media|var/lib/docker)($|/)" -# Regexp of mount points to ignore for filesystem -# collector. -# --collector.filesystem.ignored-fs-types="^(autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$" -# Regexp of filesystem types to ignore for -# filesystem collector. -# --collector.netdev.ignored-devices="^lo$" -# Regexp of net devices to ignore for netdev -# collector. -# --collector.netstat.fields="^(.*_(InErrors|InErrs)|Ip_Forwarding|Ip(6|Ext)_(InOctets|OutOctets)|Icmp6?_(InMsgs|OutMsgs)|TcpExt_(Listen.*|Syncookies.*)|Tcp_(ActiveOpens|PassiveOpens|RetransSegs|CurrEstab)|Udp6?_(InDatagrams|OutDatagrams|NoPorts))$" -# Regexp of fields to return for netstat -# collector. -# --collector.ntp.server="127.0.0.1" -# NTP server to use for ntp collector -# --collector.ntp.protocol-version=4 -# NTP protocol version -# --collector.ntp.server-is-local -# Certify that collector.ntp.server address is the -# same local host as this collector. -# --collector.ntp.ip-ttl=1 IP TTL to use while sending NTP query -# --collector.ntp.max-distance=3.46608s -# Max accumulated distance to the root -# --collector.ntp.local-offset-tolerance=1ms -# Offset between local clock and local ntpd time -# to tolerate -# --path.procfs="/proc" procfs mountpoint. -# --path.sysfs="/sys" sysfs mountpoint. -# --collector.qdisc.fixtures="" -# test fixtures to use for qdisc collector -# end-to-end testing -# --collector.runit.servicedir="/etc/service" -# Path to runit service directory. -# --collector.supervisord.url="http://localhost:9001/RPC2" -# XML RPC endpoint. -# --collector.systemd.unit-whitelist=".+" -# Regexp of systemd units to whitelist. Units must -# both match whitelist and not match blacklist to -# be included. -# --collector.systemd.unit-blacklist=".+(\\.device|\\.scope|\\.slice|\\.target)" -# Regexp of systemd units to blacklist. Units must -# both match whitelist and not match blacklist to -# be included. -# --collector.systemd.private -# Establish a private, direct connection to -# systemd without dbus. -# --collector.textfile.directory="/var/lib/prometheus/node-exporter" -# Directory to read text files with metrics from. -# --collector.vmstat.fields="^(oom_kill|pgpg|pswp|pg.*fault).*" -# Regexp of fields to return for vmstat collector. -# --collector.wifi.fixtures="" -# test fixtures to use for wifi collector metrics -# --collector.arp Enable the arp collector (default: enabled). -# --collector.bcache Enable the bcache collector (default: enabled). -# --collector.bonding Enable the bonding collector (default: enabled). -# --collector.buddyinfo Enable the buddyinfo collector (default: -# disabled). -# --collector.conntrack Enable the conntrack collector (default: -# enabled). -# --collector.cpu Enable the cpu collector (default: enabled). -# --collector.diskstats Enable the diskstats collector (default: -# enabled). -# --collector.drbd Enable the drbd collector (default: disabled). -# --collector.edac Enable the edac collector (default: enabled). -# --collector.entropy Enable the entropy collector (default: enabled). -# --collector.filefd Enable the filefd collector (default: enabled). -# --collector.filesystem Enable the filesystem collector (default: -# enabled). -# --collector.hwmon Enable the hwmon collector (default: enabled). -# --collector.infiniband Enable the infiniband collector (default: -# enabled). -# --collector.interrupts Enable the interrupts collector (default: -# disabled). -# --collector.ipvs Enable the ipvs collector (default: enabled). -# --collector.ksmd Enable the ksmd collector (default: disabled). -# --collector.loadavg Enable the loadavg collector (default: enabled). -# --collector.logind Enable the logind collector (default: disabled). -# --collector.mdadm Enable the mdadm collector (default: enabled). -# --collector.meminfo Enable the meminfo collector (default: enabled). -# --collector.meminfo_numa Enable the meminfo_numa collector (default: -# disabled). -# --collector.mountstats Enable the mountstats collector (default: -# disabled). -# --collector.netdev Enable the netdev collector (default: enabled). -# --collector.netstat Enable the netstat collector (default: enabled). -# --collector.nfs Enable the nfs collector (default: enabled). -# --collector.nfsd Enable the nfsd collector (default: enabled). -# --collector.ntp Enable the ntp collector (default: disabled). -# --collector.qdisc Enable the qdisc collector (default: disabled). -# --collector.runit Enable the runit collector (default: disabled). -# --collector.sockstat Enable the sockstat collector (default: -# enabled). -# --collector.stat Enable the stat collector (default: enabled). -# --collector.supervisord Enable the supervisord collector (default: -# disabled). -# --collector.systemd Enable the systemd collector (default: enabled). -# --collector.tcpstat Enable the tcpstat collector (default: -# disabled). -# --collector.textfile Enable the textfile collector (default: -# enabled). -# --collector.time Enable the time collector (default: enabled). -# --collector.uname Enable the uname collector (default: enabled). -# --collector.vmstat Enable the vmstat collector (default: enabled). -# --collector.wifi Enable the wifi collector (default: enabled). -# --collector.xfs Enable the xfs collector (default: enabled). -# --collector.zfs Enable the zfs collector (default: enabled). -# --collector.timex Enable the timex collector (default: enabled). -# --web.listen-address=":9100" -# Address on which to expose metrics and web -# interface. -# --web.telemetry-path="/metrics" -# Path under which to expose metrics. -# --log.level="info" Only log messages with the given severity or -# above. Valid levels: [debug, info, warn, error, -# fatal] -# --log.format="logger:stderr" -# Set the log target and format. Example: -# "logger:syslog?appname=bob&local=7" or -# "logger:stdout?json=true" diff --git a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.RedHat b/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.RedHat deleted file mode 100644 index 77528d7..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.RedHat +++ /dev/null @@ -1,9 +0,0 @@ -## Path: Applications/NodeExporter -## Description: Prometheus exporter for machine metrics -## Type: string() -## Default: "" -## ServiceRestart: prometheus-node_exporter -# -# Arguments for running prometheus-node_exporter -# -ARGS={{ args }} diff --git a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Suse b/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Suse deleted file mode 100644 index 77528d7..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-config.Suse +++ /dev/null @@ -1,9 +0,0 @@ -## Path: Applications/NodeExporter -## Description: Prometheus exporter for machine metrics -## Type: string() -## Default: "" -## ServiceRestart: prometheus-node_exporter -# -# Arguments for running prometheus-node_exporter -# -ARGS={{ args }} diff --git a/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-systemd.config b/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-systemd.config new file mode 100644 index 0000000..0eb4cd2 --- /dev/null +++ b/prometheus-exporters-formula/prometheus-exporters/files/node-exporter-systemd.config @@ -0,0 +1 @@ +ARGS={{ args }} diff --git a/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.RedHat b/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.RedHat deleted file mode 100644 index 777bcdf..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.RedHat +++ /dev/null @@ -1,27 +0,0 @@ -{%- set source_name = salt['pillar.get']('exporters:postgres_exporter:data_source_name') %} - -{%- set host = salt['pillar.get']('exporters:postgres_exporter:data_source_hostname') %} -{%- if not host and source_name %} -{%- set host = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@([^\/\?\s]+):\d{1,5}/[^?\s]*') | first %} -{%- endif %} - -{%- set port = salt['pillar.get']('exporters:postgres_exporter:data_source_port') %} -{%- if not port and source_name %} -{%- set port = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@[^\/\?\s]+:(\d{1,5})/[^?\s]*') | first %} -{%- endif %} - -{%- set db = salt['pillar.get']('exporters:postgres_exporter:data_source_database') %} -{%- if not db and source_name %} -{%- set db = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@[^\/\?\s]+:\d{1,5}/([^?\s]*)') | first %} -{%- endif %} - -{%- set user = salt['pillar.get']('exporters:postgres_exporter:data_source_user') %} -{%- if not user and source_name %} -{%- set user = source_name | regex_search('postgresq?l?:\/\/([^:@\s]*):[^@\s]*@[^\/\?\s]+:\d{1,5}/[^?\s]*') | first %} -{%- endif %} -[Service] -EnvironmentFile= -Environment="DATA_SOURCE_URI={{ host }}:{{ port }}/{{ db }}?sslmode=disable" -Environment="DATA_SOURCE_USER={{ user }}" -Environment="DATA_SOURCE_PASS_FILE={{ password_file }}" -Environment="POSTGRES_EXPORTER_PARAMS={{ args }}" diff --git a/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Suse b/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Suse deleted file mode 100644 index 777bcdf..0000000 --- a/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Suse +++ /dev/null @@ -1,27 +0,0 @@ -{%- set source_name = salt['pillar.get']('exporters:postgres_exporter:data_source_name') %} - -{%- set host = salt['pillar.get']('exporters:postgres_exporter:data_source_hostname') %} -{%- if not host and source_name %} -{%- set host = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@([^\/\?\s]+):\d{1,5}/[^?\s]*') | first %} -{%- endif %} - -{%- set port = salt['pillar.get']('exporters:postgres_exporter:data_source_port') %} -{%- if not port and source_name %} -{%- set port = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@[^\/\?\s]+:(\d{1,5})/[^?\s]*') | first %} -{%- endif %} - -{%- set db = salt['pillar.get']('exporters:postgres_exporter:data_source_database') %} -{%- if not db and source_name %} -{%- set db = source_name | regex_search('postgresq?l?:\/\/[^:@\s]*:[^@\s]*@[^\/\?\s]+:\d{1,5}/([^?\s]*)') | first %} -{%- endif %} - -{%- set user = salt['pillar.get']('exporters:postgres_exporter:data_source_user') %} -{%- if not user and source_name %} -{%- set user = source_name | regex_search('postgresq?l?:\/\/([^:@\s]*):[^@\s]*@[^\/\?\s]+:\d{1,5}/[^?\s]*') | first %} -{%- endif %} -[Service] -EnvironmentFile= -Environment="DATA_SOURCE_URI={{ host }}:{{ port }}/{{ db }}?sslmode=disable" -Environment="DATA_SOURCE_USER={{ user }}" -Environment="DATA_SOURCE_PASS_FILE={{ password_file }}" -Environment="POSTGRES_EXPORTER_PARAMS={{ args }}" diff --git a/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Debian b/prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-systemd.config similarity index 100% rename from prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-config.Debian rename to prometheus-exporters-formula/prometheus-exporters/files/postgres-exporter-systemd.config diff --git a/prometheus-exporters-formula/prometheus-exporters/init.sls b/prometheus-exporters-formula/prometheus-exporters/init.sls index 65ee370..3c40ebe 100644 --- a/prometheus-exporters-formula/prometheus-exporters/init.sls +++ b/prometheus-exporters-formula/prometheus-exporters/init.sls @@ -88,7 +88,7 @@ node_exporter: - name: {{ exporters.node_exporter_package }} file.managed: - name: {{ exporters.node_exporter_service_config }} - - source: {{ 'salt://prometheus-exporters/files/node-exporter-config.' ~ salt['grains.get']('os_family') }} + - source: salt://prometheus-exporters/files/node-exporter-systemd.config - makedirs: True - template: jinja - user: root @@ -144,7 +144,7 @@ apache_exporter: - name: {{ exporters.apache_exporter_package }} file.managed: - name: {{ exporters.apache_exporter_service_config }} - - source: {{ 'salt://prometheus-exporters/files/apache-exporter-config.' ~ salt['grains.get']('os_family') }} + - source: salt://prometheus-exporters/files/apache-exporter-systemd.config - makedirs: True - template: jinja - user: root @@ -167,6 +167,10 @@ apache_exporter: - pkg: apache_exporter - watch_in: - service: apache_exporter + module.run: + - name: service.systemctl_reload + - onchanges: + - file: {{ exporters.apache_exporter_service_config }} service.running: - name: {{ exporters.apache_exporter_service }} - enable: True @@ -208,7 +212,7 @@ postgres_exporter: file.managed: - names: - {{ exporters.postgres_exporter_service_config }}: - - source: {{ 'salt://prometheus-exporters/files/postgres-exporter-config.' ~ salt['grains.get']('os_family') }} + - source: salt://prometheus-exporters/files/postgres-exporter-systemd.config - {{ exporters.postgres_exporter_password_file }}: - source: salt://prometheus-exporters/files/postgres-exporter-password - user: prometheus diff --git a/prometheus-exporters-formula/prometheus-exporters/map.jinja b/prometheus-exporters-formula/prometheus-exporters/map.jinja index 0559634..7829ea6 100644 --- a/prometheus-exporters-formula/prometheus-exporters/map.jinja +++ b/prometheus-exporters-formula/prometheus-exporters/map.jinja @@ -5,7 +5,7 @@ 'node_exporter_service_config': '/etc/sysconfig/prometheus-node_exporter', 'apache_exporter_package': 'golang-github-lusitaniae-apache_exporter', 'apache_exporter_service': 'prometheus-apache_exporter', - 'apache_exporter_service_config': '/etc/sysconfig/prometheus-apache_exporter', + 'apache_exporter_service_config': '/etc/systemd/system/prometheus-apache_exporter.service.d/60-suse-salt-formula.conf', 'postgres_exporter_package': 'prometheus-postgres_exporter', 'postgres_exporter_service': 'prometheus-postgres_exporter', 'postgres_exporter_service_config': '/etc/systemd/system/prometheus-postgres_exporter.service.d/60-suse-salt-formula.conf', @@ -20,7 +20,7 @@ 'node_exporter_service_config': '/etc/default/prometheus-node-exporter', 'apache_exporter_package': 'prometheus-apache-exporter', 'apache_exporter_service': 'prometheus-apache-exporter', - 'apache_exporter_service_config': '/etc/default/prometheus-apache-exporter', + 'apache_exporter_service_config': '/etc/systemd/system/prometheus-apache-exporter.service.d/60-suse-salt-formula.conf', 'postgres_exporter_package': 'prometheus-postgres-exporter', 'postgres_exporter_service': 'prometheus-postgres-exporter', 'postgres_exporter_service_config': '/etc/systemd/system/prometheus-postgres-exporter.service.d/60-suse-salt-formula.conf', @@ -35,7 +35,7 @@ 'node_exporter_service_config': '/etc/sysconfig/prometheus-node_exporter', 'apache_exporter_package': 'golang-github-lusitaniae-apache_exporter', 'apache_exporter_service': 'prometheus-apache_exporter', - 'apache_exporter_service_config': '/etc/sysconfig/prometheus-apache_exporter', + 'apache_exporter_service_config': '/etc/systemd/system/prometheus-apache_exporter.service.d/60-suse-salt-formula.conf', 'postgres_exporter_package': 'prometheus-postgres_exporter', 'postgres_exporter_service': 'prometheus-postgres_exporter', 'postgres_exporter_service_config': '/etc/systemd/system/prometheus-postgres_exporter.service.d/60-suse-salt-formula.conf',