Add blackbox_exporter

This commit is contained in:
Ricardo Hernandez 2016-12-12 12:43:05 +00:00
parent d0e7fcda8b
commit d8e1cc6ef4
4 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,48 @@
{% from "prometheus/map.jinja" import prometheus with context %}
{%- set version_path = prometheus.exporters.blackbox.install_dir ~ "/blackbox_exporter-" ~ prometheus.exporters.blackbox.version %}
include:
- prometheus.user
blackbox_exporter_tarball:
archive.extracted:
- name: {{ prometheus.exporters.blackbox.install_dir }}
- source: {{ prometheus.exporters.blackbox.source }}
- source_hash: {{ prometheus.exporters.blackbox.source_hash }}
- archive_format: tar
- if_missing: {{ version_path }}
blackbox_exporter_bin_link:
file.symlink:
- name: /usr/bin/blackbox_exporter
- target: {{ version_path }}/blackbox_exporter
- require:
- archive: blackbox_exporter_tarball
blackbox_exporter_defaults:
file.managed:
- name: /etc/default/blackbox_exporter
- source: salt://prometheus/files/default-blackbox_exporter.jinja
- template: jinja
- defaults:
config_file: {{ prometheus.exporters.blackbox.args.config_file }}
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
{%- elif grains.get('init') == 'upstart' %}
- name: /etc/init/blackbox_exporter.conf
- source: salt://prometheus/files/blackbox_exporter.upstart.jinja
{%- endif %}
- require_in:
- file: blackbox_exporter_service
blackbox_exporter_service:
service.running:
- name: blackbox_exporter
- enable: True
- reload: True
- watch:
- file: blackbox_exporter_defaults

View file

@ -0,0 +1,18 @@
[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

@ -0,0 +1,30 @@
# Prometheus Blackbox exporter (Upstart unit)
description "Prometheus Blackbox exporter"
start on runlevel [2345]
stop on runlevel [06]
env BLACKBOX_EXPORTER=/usr/bin/blackbox_exporter
env USER=prometheus
env GROUP=prometheus
env DEFAULTS=/etc/default/blackbox_exporter
env RUNDIR=/var/run/blackbox_exporter
env PID_FILE=/var/run/blackbox_exporter/blackbox_exporter.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/blackbox_exporter", if available.
[ -e $DEFAULTS ] && . $DEFAULTS
export GOMAXPROCS=${GOMAXPROCS:-2}
exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $BLACKBOX_EXPORTER -S -- $ARGS
end script
respawn
respawn limit 10 10
kill timeout 10

View file

@ -0,0 +1,7 @@
# Set the command-line arguments to pass to the blackbox_exporter service.
ARGS="-config.file {{config_file}}"
# Blackbox exporter supports the following options:
# -config.file string
# Blackbox exporter configuration file name.
# (default "/etc/prometheus/blackbox_exporter.yml)