commit 3ca0d22ed19aa483eb853dd4e6500438374bd368 Author: Henrik Hautakoski Date: Fri Dec 7 19:29:57 2018 +0100 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea053e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/*/* diff --git a/haproxy_exporter.conf b/haproxy_exporter.conf new file mode 100644 index 0000000..bf3484f --- /dev/null +++ b/haproxy_exporter.conf @@ -0,0 +1,30 @@ +# Options. +# +# --web.listen-address=":9101" +# Address to listen on for web interface and telemetry. +# --web.telemetry-path="/metrics" +# Path under which to expose metrics. +# --haproxy.scrape-uri="http://localhost/;csv" +# URI on which to scrape HAProxy. +# --haproxy.ssl-verify Flag that enables SSL certificate verification for the scrape URI +# --haproxy.server-metric-fields="2,3,4,5,6,7,8,9,13,14,15,16,17,18,21,24,33,35,38,39,40,41,42,43,44" +# Comma-separated list of exported server metrics. See +# http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#9.1 +# --haproxy.timeout=5s Timeout for trying to get stats from HAProxy. +# --haproxy.pid-file="" Path to HAProxy pid file. +# +# If provided, the standard process metrics get exported for the HAProxy +# process, prefixed with 'haproxy_process_...'. The haproxy_process exporter +# needs to have read access to files owned by the HAProxy process. Depends on +# the availability of /proc. +# +# https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics. +# --log.level="info" Only log messages with the given severity or above. Valid levels: [debug, info, warn, +# error, fatal] +# --log.format="logger:stderr" +# Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or +# "logger:stdout?json=true" +# --version Show application version. +# + +HAPROXY_EXPORTER_OPTS= diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..b3207e8 --- /dev/null +++ b/install.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +ARCH=$(dpkg --print-architecture) +VERSION=0.9.0 +INSTALLDIR=/usr/local/bin +CONFIGDIR=/etc/prometheus + +# Download and install the binary. +wget -O- https://github.com/prometheus/haproxy_exporter/releases/download/v${VERSION}/haproxy_exporter-${VERSION}.linux-${ARCH}.tar.gz | tar zxf - +sudo mv haproxy_exporter-${VERSION}.linux-${ARCH}/haproxy_exporter ${INSTALLDIR}/haproxy_exporter-${VERSION} + +# Create User/Group +sudo useradd -M -s /bin/false haproxy_exporter + +# Write config +sudo mkdir -p ${CONFIGDIR} +sudo cp ./haproxy_exporter.conf ${CONFIGDIR}/ + +# Write system service file. +echo "[Unit] +Description=HAProxy Prometheus Exporter +Wants=network-online.target +After=network-online.target + +[Service] +EnvironmentFile=-${CONFIGDIR}/haproxy_exporter.conf +User=haproxy_exporter +Group=haproxy_exporter +Type=simple +ExecStart=/usr/local/bin/haproxy_exporter-${VERSION} \$HAPROXY_EXPORTER_OPTS + +[Install] +WantedBy=multi-user.target" | sudo tee /etc/systemd/system/haproxy_exporter.service > /dev/null