From 979021f5c40c812d7a9edf22bf8945f691badeed Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 15 Feb 2023 20:23:49 +0100 Subject: Import Prometheus server configuration * add new roles: - monitoring.prometheus - monitoring.prometheus-alertmanager - monitoring.prometheus-exporter-blackbox * add common Prometheus and Prometheus Alertmanager pillar data * add moni.lysergic.dev specific Prometheus pillar data Signed-off-by: Georg Pfuetzenreuter --- salt/role/monitoring/prometheus-alertmanager.sls | 2 ++ salt/role/monitoring/prometheus-exporter-blackbox.sls | 2 ++ salt/role/monitoring/prometheus.sls | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 salt/role/monitoring/prometheus-alertmanager.sls create mode 100644 salt/role/monitoring/prometheus-exporter-blackbox.sls create mode 100644 salt/role/monitoring/prometheus.sls (limited to 'salt') diff --git a/salt/role/monitoring/prometheus-alertmanager.sls b/salt/role/monitoring/prometheus-alertmanager.sls new file mode 100644 index 0000000..017d914 --- /dev/null +++ b/salt/role/monitoring/prometheus-alertmanager.sls @@ -0,0 +1,2 @@ +include: + - .prometheus diff --git a/salt/role/monitoring/prometheus-exporter-blackbox.sls b/salt/role/monitoring/prometheus-exporter-blackbox.sls new file mode 100644 index 0000000..017d914 --- /dev/null +++ b/salt/role/monitoring/prometheus-exporter-blackbox.sls @@ -0,0 +1,2 @@ +include: + - .prometheus diff --git a/salt/role/monitoring/prometheus.sls b/salt/role/monitoring/prometheus.sls new file mode 100644 index 0000000..adf0b70 --- /dev/null +++ b/salt/role/monitoring/prometheus.sls @@ -0,0 +1,2 @@ +include: + - prometheus.config -- cgit v1.2.3 From 2bafbeedd72e4d3c02da56cf361f98e50382ce13 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 15 Feb 2023 20:59:46 +0100 Subject: Manage Prometheus targets Signed-off-by: Georg Pfuetzenreuter --- salt/profile/prometheus/targets.sls | 18 ++++++++++++++++++ salt/role/monitoring/prometheus-alertmanager.sls | 2 +- salt/role/monitoring/prometheus-exporter-blackbox.sls | 2 +- salt/role/monitoring/prometheus.sls | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 salt/profile/prometheus/targets.sls (limited to 'salt') diff --git a/salt/profile/prometheus/targets.sls b/salt/profile/prometheus/targets.sls new file mode 100644 index 0000000..5f29e73 --- /dev/null +++ b/salt/profile/prometheus/targets.sls @@ -0,0 +1,18 @@ +{%- set mypillar = salt['pillar.get']('profile:prometheus:targets') %} +{%- set targetsdir = '/etc/prometheus/targets' %} + +{%- if mypillar | length %} +{{ targetsdir }}: + file.directory: + - group: prometheus + +{%- for group, nodes in mypillar.items() %} +{{ targetsdir }}/{{ group }}.json: + file.serialize: + - dataset: {{ nodes }} + - serializer: json +{%- endfor %} + +{%- else %} +{%- do salt.log.debug('profile.prometheus: no targets defined') %} +{%- endif %} diff --git a/salt/role/monitoring/prometheus-alertmanager.sls b/salt/role/monitoring/prometheus-alertmanager.sls index 017d914..adf0b70 100644 --- a/salt/role/monitoring/prometheus-alertmanager.sls +++ b/salt/role/monitoring/prometheus-alertmanager.sls @@ -1,2 +1,2 @@ include: - - .prometheus + - prometheus.config diff --git a/salt/role/monitoring/prometheus-exporter-blackbox.sls b/salt/role/monitoring/prometheus-exporter-blackbox.sls index 017d914..adf0b70 100644 --- a/salt/role/monitoring/prometheus-exporter-blackbox.sls +++ b/salt/role/monitoring/prometheus-exporter-blackbox.sls @@ -1,2 +1,2 @@ include: - - .prometheus + - prometheus.config diff --git a/salt/role/monitoring/prometheus.sls b/salt/role/monitoring/prometheus.sls index adf0b70..9a96176 100644 --- a/salt/role/monitoring/prometheus.sls +++ b/salt/role/monitoring/prometheus.sls @@ -1,2 +1,3 @@ include: - prometheus.config + - profile.prometheus.targets -- cgit v1.2.3 From 8016f86164450f4eda4f1488f48cf44de0d4655f Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 15 Feb 2023 21:02:04 +0100 Subject: p.node_exporter->p.prometheus.node_exporter Since the last commit introduced a new Prometheus targets profile, it makes sense to move node_exporter underneath the Prometheus tree as well. Signed-off-by: Georg Pfuetzenreuter --- salt/common/suse.sls | 2 +- salt/profile/node_exporter/init.sls | 36 ------------------------------- salt/profile/prometheus/node_exporter.sls | 36 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 salt/profile/node_exporter/init.sls create mode 100644 salt/profile/prometheus/node_exporter.sls (limited to 'salt') diff --git a/salt/common/suse.sls b/salt/common/suse.sls index e260c77..764517e 100644 --- a/salt/common/suse.sls +++ b/salt/common/suse.sls @@ -2,7 +2,7 @@ include: - firewalld - profile.seccheck - profile.zypp - - profile.node_exporter + - profile.prometheus.node_exporter - users - .ssh - postfix.config diff --git a/salt/profile/node_exporter/init.sls b/salt/profile/node_exporter/init.sls deleted file mode 100644 index 1e46b3d..0000000 --- a/salt/profile/node_exporter/init.sls +++ /dev/null @@ -1,36 +0,0 @@ -{%- set header = salt['pillar.get']('managed_header_pound') -%} -{%- set sysconfig = '/etc/sysconfig/prometheus-node_exporter' -%} - -node_exporter_packages: - pkg.installed: - - pkgs: - - golang-github-prometheus-node_exporter - -node_exporter_sysconfig_header: - file.prepend: - - name: {{ sysconfig }} - - text: '{{ header }}' - - require: - - pkg: node_exporter_packages - -node_exporter_sysconfig: - file.replace: - - name: {{ sysconfig }} - - pattern: | - ^ARGS=.*$ - - repl: | - ARGS="--web.listen-address=:9200 --collector.filesystem.fs-types-exclude='^(fuse.s3fs|fuse.cryfs|tmpfscgroup2?|debugfs|devpts|devtmpfs|fusectl|overlay|proc|procfs|pstore)\$' --no-collector.zfs --no-collector.thermal_zone --no-collector.powersupplyclass" - - require: - - pkg: node_exporter_packages - - file: node_exporter_sysconfig_header - -node_exporter_service: - service.running: - - name: prometheus-node_exporter.service - - enable: True - - full_restart: True - - require: - - pkg: node_exporter_packages - - file: node_exporter_sysconfig - - watch: - - file: node_exporter_sysconfig diff --git a/salt/profile/prometheus/node_exporter.sls b/salt/profile/prometheus/node_exporter.sls new file mode 100644 index 0000000..1e46b3d --- /dev/null +++ b/salt/profile/prometheus/node_exporter.sls @@ -0,0 +1,36 @@ +{%- set header = salt['pillar.get']('managed_header_pound') -%} +{%- set sysconfig = '/etc/sysconfig/prometheus-node_exporter' -%} + +node_exporter_packages: + pkg.installed: + - pkgs: + - golang-github-prometheus-node_exporter + +node_exporter_sysconfig_header: + file.prepend: + - name: {{ sysconfig }} + - text: '{{ header }}' + - require: + - pkg: node_exporter_packages + +node_exporter_sysconfig: + file.replace: + - name: {{ sysconfig }} + - pattern: | + ^ARGS=.*$ + - repl: | + ARGS="--web.listen-address=:9200 --collector.filesystem.fs-types-exclude='^(fuse.s3fs|fuse.cryfs|tmpfscgroup2?|debugfs|devpts|devtmpfs|fusectl|overlay|proc|procfs|pstore)\$' --no-collector.zfs --no-collector.thermal_zone --no-collector.powersupplyclass" + - require: + - pkg: node_exporter_packages + - file: node_exporter_sysconfig_header + +node_exporter_service: + service.running: + - name: prometheus-node_exporter.service + - enable: True + - full_restart: True + - require: + - pkg: node_exporter_packages + - file: node_exporter_sysconfig + - watch: + - file: node_exporter_sysconfig -- cgit v1.2.3