Browse Source

Added rules_file management to prometheus

master
Eric Renfro 2 years ago
parent
commit
83f59fa66b
Signed by: psi-jack GPG Key ID: 14977F3A50D9A5BF
  1. 1
      prometheus/defaults.yaml
  2. 18
      prometheus/files/alertmanager.systemd.jinja
  3. 18
      prometheus/files/blackbox_exporter.systemd.jinja
  4. 23
      prometheus/files/node_exporter.systemd.jinja
  5. 18
      prometheus/files/rabbitmq_exporter.systemd.jinja
  6. 14
      prometheus/server.sls

1
prometheus/defaults.yaml

@ -8,6 +8,7 @@ prometheus:
source_hash: https://github.com/prometheus/prometheus/releases/download/v2.9.2/sha256sums.txt
args:
config_file: /etc/prometheus/prometheus.yml
rules_path: /etc/prometheus/rules
storage:
local_path: /var/lib/prometheus/metrics
url: https://prometheus.io/docs/introduction/overview/

18
prometheus/files/alertmanager.systemd.jinja

@ -1,18 +0,0 @@
[Unit]
Description=The Alertmanager handles alerts sent by client applications such as the Prometheus server
Documentation=https://prometheus.io/docs/alerting/alertmanager/
Wants=basic.target
After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
EnvironmentFile=/etc/default/alertmanager
ExecStart=/usr/bin/alertmanager $ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=42s
[Install]
WantedBy=multi-user.target

18
prometheus/files/blackbox_exporter.systemd.jinja

@ -1,18 +0,0 @@
[Unit]
Description=Prometheus blackbox exporter
Documentation=https://github.com/prometheus/blackbox_exporter
Wants=basic.target
After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
EnvironmentFile=/etc/default/blackbox_exporter
ExecStart=/usr/bin/blackbox_exporter $ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=42s
[Install]
WantedBy=multi-user.target

23
prometheus/files/node_exporter.systemd.jinja

@ -1,23 +0,0 @@
[Unit]
Description=Prometheus exporter for machine metrics
Documentation=https://github.com/prometheus/node_exporter
Wants=basic.target
After=basic.target network.target
[Service]
User={{ user }}
Group={{ group }}
EnvironmentFile=/etc/default/node_exporter
ExecStart={{ bin_path }}/node_exporter $ARGS
{%- if args is string %}} {{ args }}{% else %}
{%- for arg in args %}} \
{{ arg }}
{%- endfor %}
{%- endif %}
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=42s
[Install]
WantedBy=multi-user.target

18
prometheus/files/rabbitmq_exporter.systemd.jinja

@ -1,18 +0,0 @@
[Unit]
Description=Prometheus rabbitmq exporter
Documentation=https://github.com/kbudde/rabbitmq_exporter
Wants=basic.target
After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
EnvironmentFile=/etc/default/rabbitmq_exporter
ExecStart=/usr/bin/rabbitmq_exporter
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=42s
[Install]
WantedBy=multi-user.target

14
prometheus/server.sls

@ -27,6 +27,19 @@ prometheus_server_config:
- group: {{ prometheus.group }}
- dataset_pillar: prometheus:server:config
prometheus_rules_path:
file.directory:
- name: {{ prometheus.server.args.rules_path }}
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
prometheus_rules_file:
file.serialize:
- name: {{ prometheus.server.args.rules_path }}/alerts.rules
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
- dataset_pillar: prometheus:server:rules
prometheus_defaults:
file.managed:
- name: /etc/default/prometheus
@ -81,4 +94,5 @@ prometheus_service:
- watch:
- file: prometheus_service_unit
- file: prometheus_server_config
- file: prometheus_rules_file
{# - file: prometheus_bin_link #}
Loading…
Cancel
Save