Multiple changes in preparation for the "ng" fork.

* Changed references to salt://prometheus-ng/...
* Added generic templates for exporters.
* Added variables passed on to templates.
master
Eric Renfro 4 years ago
parent 5068a65cf5
commit ce7512d643
Signed by: psi-jack
GPG Key ID: 14977F3A50D9A5BF
  1. 8
      prometheus/alertmanager.sls
  2. 30
      prometheus/defaults.yaml
  3. 12
      prometheus/exporter/blackbox.sls
  4. 12
      prometheus/exporter/haproxy.sls
  5. 12
      prometheus/exporter/node.sls
  6. 12
      prometheus/exporter/rabbitmq.sls
  7. 25
      prometheus/files/exporter.systemd.jinja
  8. 30
      prometheus/files/exporter.upstart.jinja
  9. 11
      prometheus/files/node_exporter.systemd.jinja
  10. 6
      prometheus/files/prometheus.systemd.jinja
  11. 11
      prometheus/server.sls

@ -28,7 +28,7 @@ alertmanager_config:
alertmanager_config:
file.managed:
- name: {{ prometheus.alertmanager.args.config_file }}
- source: salt://prometheus/files/config.jinja
- source: salt://prometheus-ng/files/config.jinja
- template: jinja
- user: {{ prometheus.user }}
- group: {{ prometheus.group }}
@ -39,7 +39,7 @@ alertmanager_config:
alertmanager_defaults:
file.managed:
- name: /etc/default/alertmanager
- source: salt://prometheus/files/default-alertmanager.jinja
- source: salt://prometheus-ng/files/default-alertmanager.jinja
- template: jinja
- defaults:
config_file: {{ prometheus.alertmanager.args.config_file }}
@ -58,10 +58,10 @@ alertmanager_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/alertmanager.service
- source: salt://prometheus/files/alertmanager.systemd.jinja
- source: salt://prometheus-ng/files/alertmanager.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/alertmanager.conf
- source: salt://prometheus/files/alertmanager.upstart.jinja
- source: salt://prometheus-ng/files/alertmanager.upstart.jinja
{%- endif %}
- watch:
- file: alertmanager_defaults

@ -2,41 +2,41 @@ prometheus:
user: prometheus
group: prometheus
server:
version: 1.4.1.linux-amd64
version: 2.5.0.linux-amd64
install_dir: /opt
source: https://github.com/prometheus/prometheus/releases/download/v1.4.1/prometheus-1.4.1.linux-amd64.tar.gz
source_hash: sha1=3e78173e7d65623e79e0292da16e6155de947185
source: https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gz
source_hash: https://github.com/prometheus/prometheus/releases/download/v2.5.0/sha256sums.txt
args:
config_file: /etc/prometheus/prometheus.yml
storage:
local_path: /var/lib/prometheus/metrics
alertmanager:
version: 0.5.1.linux-amd64
version: 0.15.3.linux-amd64
install_dir: /opt
source: https://github.com/prometheus/alertmanager/releases/download/v0.5.1/alertmanager-0.5.1.linux-amd64.tar.gz
source_hash: sha1=8f82ccc0db806991256084faee9335353d8e3f0d
source: https://github.com/prometheus/alertmanager/releases/download/v0.15.3/alertmanager-0.15.3.linux-amd64.tar.gz
source_hash: https://github.com/prometheus/alertmanager/releases/download/v0.15.3/sha256sums.txt
args:
config_file: /etc/alertmanager/alertmanager.yml
storage:
path: /var/lib/alertmanager
exporter:
node:
version: 0.13.0.linux-amd64
version: 0.17.0.linux-amd64
install_dir: /opt
source: https://github.com/prometheus/node_exporter/releases/download/v0.13.0/node_exporter-0.13.0.linux-amd64.tar.gz
source_hash: sha1=84ca5f711962319f6f7823208b9d867ab1c0e3e7
source: https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
source_hash: https://github.com/prometheus/node_exporter/releases/download/v0.17.0/sha256sums.txt
blackbox:
version: 0.3.0.linux-amd64
version: 0.14.0.linux-amd64
install_dir: /opt
source: https://github.com/prometheus/blackbox_exporter/releases/download/v0.3.0/blackbox_exporter-0.3.0.linux-amd64.tar.gz
source_hash: sha1=89ac98c062315ba35eda257ca88c8c4b43f38d47
source: https://github.com/prometheus/blackbox_exporter/releases/download/v0.14.0/blackbox_exporter-0.14.0.linux-amd64.tar.gz
source_hash: https://github.com/prometheus/blackbox_exporter/releases/download/v0.14.0/sha256sums.txt
args:
config_file: /etc/prometheus/blackbox_exporter.yml
haproxy:
version: 0.7.1.linux-amd64
version: 0.10.0.linux-amd64
install_dir: /opt
source: https://github.com/prometheus/haproxy_exporter/releases/download/v0.7.1/haproxy_exporter-0.7.1.linux-amd64.tar.gz
source_hash: sha1=56849253e280db3db2aa80f1013ecfe242536d32
source: https://github.com/prometheus/haproxy_exporter/releases/download/v0.10.0/haproxy_exporter-0.10.0.linux-amd64.tar.gz
source_hash: https://github.com/prometheus/haproxy_exporter/releases/download/v0.10.0/sha256sums.txt
args:
scrape_uri: 'unix:/run/haproxy/admin.sock'
rabbitmq:

@ -23,7 +23,7 @@ blackbox_exporter_bin_link:
blackbox_exporter_defaults:
file.managed:
- name: /etc/default/blackbox_exporter
- source: salt://prometheus/files/default-blackbox_exporter.jinja
- source: salt://prometheus-ng/files/default-blackbox_exporter.jinja
- template: jinja
- defaults:
config_file: {{ prometheus.exporter.blackbox.args.config_file }}
@ -32,11 +32,17 @@ blackbox_exporter_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/blackbox_exporter.service
- source: salt://prometheus/files/blackbox_exporter.systemd.jinja
- source: salt://prometheus-ng/files/exporter.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/blackbox_exporter.conf
- source: salt://prometheus/files/blackbox_exporter.upstart.jinja
- source: salt://prometheus-ng/files/exporter.upstart.jinja
{%- endif %}
- context:
svc: node_exporter
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- require_in:
- file: blackbox_exporter_service

@ -23,7 +23,7 @@ haproxy_exporter_bin_link:
haproxy_exporter_defaults:
file.managed:
- name: /etc/default/haproxy_exporter
- source: salt://prometheus/files/default-haproxy_exporter.jinja
- source: salt://prometheus-ng/files/default-haproxy_exporter.jinja
- template: jinja
- defaults:
scrape_uri: {{ prometheus.exporter.haproxy.args.scrape_uri }}
@ -32,11 +32,17 @@ haproxy_exporter_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/haproxy_exporter.service
- source: salt://prometheus/files/haproxy_exporter.systemd.jinja
- source: salt://prometheus-ng/files/exporter.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/haproxy_exporter.conf
- source: salt://prometheus/files/haproxy_exporter.upstart.jinja
- source: salt://prometheus-ng/files/exporter.upstart.jinja
{%- endif %}
- context:
svc: node_exporter
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- require_in:
- file: haproxy_exporter_service

@ -23,18 +23,24 @@ node_exporter_bin_link:
node_exporter_defaults:
file.managed:
- name: /etc/default/node_exporter
- source: salt://prometheus/files/default-node_exporter.jinja
- source: salt://prometheus-ng/files/default-node_exporter.jinja
- template: jinja
node_exporter_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/node_exporter.service
- source: salt://prometheus/files/node_exporter.systemd.jinja
- source: salt://prometheus-ng/files/exporter.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/node_exporter.conf
- source: salt://prometheus/files/node_exporter.upstart.jinja
- source: salt://prometheus-ng/files/exporter.upstart.jinja
{%- endif %}
- context:
svc: node_exporter
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- require_in:
- file: node_exporter_service

@ -23,18 +23,24 @@ rabbitmq_exporter_bin_link:
rabbitmq_exporter_defaults:
file.managed:
- name: /etc/default/rabbitmq_exporter
- source: salt://prometheus/files/default-rabbitmq_exporter.jinja
- source: salt://prometheus-ng/files/default-rabbitmq_exporter.jinja
- template: jinja
rabbitmq_exporter_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/rabbitmq_exporter.service
- source: salt://prometheus/files/rabbitmq_exporter.systemd.jinja
- source: salt://prometheus-ng/files/exporter.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/rabbitmq_exporter.conf
- source: salt://prometheus/files/rabbitmq_exporter.upstart.jinja
- source: salt://prometheus-ng/files/exporter.upstart.jinja
{%- endif %}
- context:
svc: node_exporter
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- require_in:
- file: rabbitmq_exporter_service

@ -0,0 +1,25 @@
[Unit]
Description=Prometheus {{ svc }} Exporter
{%- if url is string %}
Documentation={{ url }}
{%- endif %}
Wants=basic.target
After=basic.target network.target
[Service]
User={{ user }}
Group={{ group }}
EnvironmentFile=/etc/default/{{ svc }}
ExecStart={{ bin_path }}/{{ svc }} $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

@ -0,0 +1,30 @@
# Prometheus {{ svc }} (Upstart unit)
description "Prometheus {{ svc }}"
start on runlevel [2345]
stop on runlevel [06]
env EXPORTER={{ bin_path }}/{{ svc }}
env USER={{ user }}
env GROUP={{ group }}
env DEFAULTS=/etc/default/{{ svc }}
env RUNDIR=/var/run/{{ svc }}
env PID_FILE=/var/run/{{ svc }}/{{ svc }}.pid
pre-start script
[ -e $DEFAULTS ] && . $DEFAULTS
mkdir -p $RUNDIR || true
chmod 0750 $RUNDIR || true
chown $USER:$GROUP $RUNDIR || true
end script
script
# read settings like GOMAXPROCS from "/etc/default/{{ svc }}", if available.
[ -e $DEFAULTS ] && . $DEFAULTS
export GOMAXPROCS=${GOMAXPROCS:-2}
exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $EXPORTER -S -- $ARGS
end script
respawn
respawn limit 10 10
kill timeout 10

@ -5,10 +5,15 @@ Wants=basic.target
After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
User={{ user }}
Group={{ group }}
EnvironmentFile=/etc/default/node_exporter
ExecStart=/usr/bin/node_exporter $ARGS
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

@ -5,10 +5,10 @@ Wants=basic.target
After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
User={{ user }}
Group={{ user }}
EnvironmentFile=/etc/default/prometheus
ExecStart=/usr/bin/prometheus $ARGS
ExecStart={{ bin_path }}/prometheus $ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

@ -28,7 +28,7 @@ prometheus_server_config:
prometheus_defaults:
file.managed:
- name: /etc/default/prometheus
- source: salt://prometheus/files/default-prometheus.jinja
- source: salt://prometheus-ng/files/default-prometheus.jinja
- template: jinja
- defaults:
config_file: {{ prometheus.server.args.config_file }}
@ -51,11 +51,16 @@ prometheus_service_unit:
file.managed:
{%- if grains.get('init') == 'systemd' %}
- name: /etc/systemd/system/prometheus.service
- source: salt://prometheus/files/prometheus.systemd.jinja
- source: salt://prometheus-ng/files/prometheus.systemd.jinja
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/prometheus.conf
- source: salt://prometheus/files/prometheus.upstart.jinja
- source: salt://prometheus-ng/files/prometheus.upstart.jinja
{%- endif %}
- context:
user: {{ prometheus.user }}
group: {{ prometheus.group }}
bin_path: {{ prometheus.exporter.node.version_path }}
args: {{ prometheus.exporter.get('args', []) }}
- watch:
- file: prometheus_defaults
- require_in:

Loading…
Cancel
Save