Added rules_file management to prometheus

This commit is contained in:
Eric Renfro 2019-05-26 14:21:59 -04:00
parent 4ac8c4f4a7
commit 83f59fa66b
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF
6 changed files with 15 additions and 77 deletions

View file

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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -27,6 +27,19 @@ prometheus_server_config:
- group: {{ prometheus.group }} - group: {{ prometheus.group }}
- dataset_pillar: prometheus:server:config - 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: prometheus_defaults:
file.managed: file.managed:
- name: /etc/default/prometheus - name: /etc/default/prometheus
@ -81,4 +94,5 @@ prometheus_service:
- watch: - watch:
- file: prometheus_service_unit - file: prometheus_service_unit
- file: prometheus_server_config - file: prometheus_server_config
- file: prometheus_rules_file
{# - file: prometheus_bin_link #} {# - file: prometheus_bin_link #}