new type: __prometheus_exporter

This commit is contained in:
kamila 2017-09-02 14:47:56 +02:00
parent 0043b3f4b0
commit 50b7ebf3b0
6 changed files with 178 additions and 0 deletions

View file

@ -0,0 +1,63 @@
modules:
http_2xx:
prober: http
timeout: 3s
http:
method: GET
no_follow_redirects: false
fail_if_ssl: false
fail_if_not_ssl: false
# http_post_2xx:
# prober: http
# timeout: 5s
# http:
# method: POST
# headers:
# Content-Type: application/json
# body: '{}'
# tcp_connect_v4_example:
# prober: tcp
# timeout: 5s
# tcp:
# protocol: "tcp4"
# irc_banner_example:
# prober: tcp
# timeout: 5s
# tcp:
# query_response:
# - send: "NICK prober"
# - send: "USER prober prober prober :prober"
# - expect: "PING :([^ ]+)"
# send: "PONG ${1}"
# - expect: "^:[^ ]+ 001"
# icmp_example:
# prober: icmp
# timeout: 5s
# icmp:
# protocol: "icmp"
# preferred_ip_protocol: "ip4"
# dns_udp_example:
# prober: dns
# timeout: 5s
# dns:
# query_name: "www.prometheus.io"
# query_type: "A"
# valid_rcodes:
# - NOERROR
# validate_answer_rrs:
# fail_if_matches_regexp:
# - ".*127.0.0.1"
# fail_if_not_matches_regexp:
# - "www.prometheus.io.\t300\tIN\tA\t127.0.0.1"
# validate_authority_rrs:
# fail_if_matches_regexp:
# - ".*127.0.0.1"
# validate_additional_rrs:
# fail_if_matches_regexp:
# - ".*127.0.0.1"
# dns_tcp_example:
# prober: dns
# dns:
# protocol: "tcp" # accepts "tcp/tcp4/tcp6/udp/udp4/udp6", defaults to "udp"
# preferred_ip_protocol: "ip4" # used for "udp/tcp", defaults to "ip6"
# query_name: "www.prometheus.io"

View file

@ -0,0 +1,63 @@
cdist-type__prometheus_exporter(7)
==================================
NAME
----
cdist-type__prometheus_exporter - install some Prometheus exporters
DESCRIPTION
-----------
Install and configure some exporters to be used by the Prometheus monitoring system (https://prometheus.io/).
This type creates a daemontools-compatible service directory under /service/$__object_id.
Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable).
This type installs and builds the latest version from git, using go get. A recent version of golang as well
as build tools (make, g++, etc.) must be available.
REQUIRED PARAMETERS
-------------------
None
OPTIONAL PARAMETERS
-------------------
exporter
Which exporter to install and configure. Default: $__object_id.
Currently supported: node, blackbox, ceph
BOOLEAN PARAMETERS
------------------
add-consul-service
Add this exporter as a Consul service for automatic service discovery.
EXAMPLES
--------
.. code-block:: sh
__daemontools
__golang_from_vendor --version 1.9 # required for prometheus and many exporters
require="__daemontools __golang_from_vendor" __prometheus_exporter node
SEE ALSO
--------
:strong:`cdist-type__prometheus_server`\ (7), :strong:`cdist-type__daemontools`\ (7),
:strong:`cdist-type__golang_from_vendor`\ (7),
Prometheus documentation: https://prometheus.io/docs/introduction/overview/
AUTHORS
-------
Kamila Součková <kamila--@--ksp.sk>
COPYING
-------
Copyright \(C) 2017 Kamila Součková. You can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -0,0 +1,50 @@
#!/bin/sh
export GOBIN=/opt/gocode/bin # where to find go binaries
exporter="$(cat $__object/parameter/exporter)"
[ -z "$exporter" ] && exporter="$__object_id"
__user prometheus --system
case $exporter in
node)
TEXTFILES=/service/node-exporter/textfiles # path for the textfiles collector
port=9100
run="setuidgid prometheus $GOBIN/node_exporter -web.listen-address :$port -collector.textfile.directory=$TEXTFILES"
require="__golang_from_vendor" __go_get github.com/prometheus/node_exporter
__directory $TEXTFILES --parents --mode 777
;;
blackbox)
port=9115
run="setuidgid prometheus $GOBIN/blackbox_exporter -config.file=/service/blackbox-exporter/blackbox.yml"
require="__daemontools_service/blackbox-exporter __user/prometheus" __config_file "/service/blackbox-exporter/blackbox.yml" \
--source $__type/files/blackbox.yml \
--group prometheus --mode 640 \
--onchange "svc -h /service/blackbox-exporter"
require="__golang_from_vendor" __go_get github.com/prometheus/blackbox_exporter
;;
ceph)
port=9128
run="setuidgid ceph $GOBIN/ceph_exporter -ceph.config /etc/ceph/ceph.conf -telemetry.addr :$port"
__package librados-dev # dependency of ceph_exporter
require="__golang_from_vendor __package/librados-dev" __go_get github.com/digitalocean/ceph_exporter
;;
*)
echo "Unknown exporter: $exporter." >&2
exit 1
;;
esac
require="__daemontools" __daemontools_service ${exporter}-exporter --run "$run"
if [ -f "$__object/parameter/add-consul-service" ]; then
__consul_service ${exporter}-exporter --port $port --check-http "http://localhost:$port/metrics" --check-interval 10s
fi
#__daemontools --install-init-script
__daemontools
__golang_from_vendor --version 1.8.1 # required for many exporters

View file

@ -0,0 +1 @@
add-consul-service

View file

@ -0,0 +1 @@
exporter