test(centos): verified on CentosOS

This commit is contained in:
N 2019-06-20 01:36:58 +01:00
parent d43033a0fd
commit 731198dd4d
No known key found for this signature in database
GPG Key ID: 55A292EAB4E54067
35 changed files with 699 additions and 655 deletions

View File

@ -2,24 +2,31 @@
# vim: ft=yaml # vim: ft=yaml
--- ---
prometheus: prometheus:
wanted:
- prometheus
- pushgateway
- node_explorer
use_upstream_archive: True
pkg: pkg:
name: prometheus prometheus:
use_upstream_archive: False archive_version: 2.10.0
archive: archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
source: https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz alertmanager:
source_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7 archive_version: '0.17.0'
archive_format: tar archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
enforce_toplevel: False
config_file: /etc/prometheus/prometheus.yml
environ_file: /etc/default/prometheus.sh
service: service:
name: prometheus prometheus
args: args:
web.listen-address: 0.0.0.0:9090 web.listen-address: 0.0.0.0:9090
pushgateway:
linux: args:
#'Alternatives system' priority: zero disables (default) web.listen-address: ":9091"
altpriority: 0 web.telemetry-path: "/metrics"
node_exporter:
args:
web.listen-address: ":9110"
tofs: tofs:
# The files_switch key serves as a selector for alternative # The files_switch key serves as a selector for alternative
@ -45,9 +52,9 @@ prometheus:
# - 'example_alt.tmpl.jinja' # - 'example_alt.tmpl.jinja'
# Pillar-based config # Pillar-based config
environ:
- 'export PATH=${PATH}:/opt/prometheus-2.10.0.linux-amd64'
config: config:
prometheus:
# ref https://raw.githubusercontent.com/prometheus/prometheus/release-2.10/config/testdata/conf.good.yml
# my global config # my global config
global: global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
@ -67,18 +74,78 @@ prometheus:
# - "second_rules.yml" # - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape: # A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs: scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus' - job_name: 'prometheus'
# metrics_path defaults to '/metrics' # metrics_path defaults to '/metrics'
# scheme defaults to 'http'. # scheme defaults to 'http'.
static_configs: static_configs:
- targets: ['localhost:9090'] - targets: ['localhost:9090']
exporters: - job_name: pushgateway
node: scrape_interval: 5s
args: honor_labels: true
web.listen-address: ":9110" static_configs:
- targets: ['pushgateway:9091']
- job_name: 'blackbox'
# ref https://github.com/prometheus/blackbox_exporter#prometheus-configuration
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- http://prometheus.io # Target to probe with http.
- https://prometheus.io # Target to probe with https.
- http://example.com:8080 # Target to probe with http on port 8080.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115 # The blackbox exporter's real hostname:port.
alertmanager:
# ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
global:
smtp_smarthost: 'localhost:25'
smtp_from: 'alertmanager@example.org'
smtp_auth_username: 'alertmanager'
smtp_auth_password: "multiline\nmysecret"
smtp_hello: "host.example.org"
slack_api_url: "http://mysecret.example.com/"
http_config:
proxy_url: 'http://127.0.0.1:1025'
route:
group_by: ['alertname', 'cluster', 'service']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: team-X-mails
routes:
- match_re:
service: ^(foo1|foo2|baz)$
receiver: team-X-mails
routes:
- match:
severity: critical
receiver: team-X-mails
receivers:
- name: 'team-X-mails'
email_configs:
- to: 'team-X+alerts@example.org'
inhibit_rules:
- name: opsGenie-receiver
opsgenie_configs:
- api_key: mysecret
- name: slack-receiver
slack_configs:
- channel: '#my-channel'
image_url: 'http://some.img.com/img.png'
linux:
#'Alternatives system' priority: zero disables (default)
altpriority: 0

View File

@ -4,33 +4,26 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_archive_clean = tplroot ~ '.archive.clean' %}
{%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 %} {%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 %}
include: {%- for name in p.wanted %}
- {{ sls_archive_clean }} {%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
{%- for k in p.archive.wanted %} prometheus-archive-remove-{{ name }}-home-alternatives-remove:
{%- set dir = p.archive.dir.opt + '/' + k + '-%s.%s-%s'|format(p.archive.versions[k], p.kernel, p.arch) %}
prometheus-archive-remove-{{ k }}-home-alternatives-remove:
alternatives.remove: alternatives.remove:
- name: prometheus-{{ k }}-home - name: prometheus-{{ name }}-home
- path: {{ dir }} - path: {{ p.dir.basedir }}/{{ bundle }}
- onlyif: update-alternatives --get-selections |grep ^prometheus-{{ k }}-home - onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-home
- require:
- sls: {{ sls_archive_clean }}
{% for i in p.archive.binaries[k] %} {% for b in p.pkg[name]['binaries'] %}
prometheus-archive-remove-{{ k }}-alternatives-remove-{{ i }}:
prometheus-archive-remove-{{ name }}-alternatives-remove-{{ b }}:
alternatives.remove: alternatives.remove:
- name: prometheus-{{ k }}-{{ i }} - name: prometheus-{{ name }}-{{ b }}
- path: {{ dir }}/{{ i }} - path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- onlyif: update-alternatives --get-selections |grep ^prometheus-{{ k }}-{{ i }} - onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-{{ b }}
- require:
- sls: {{ sls_archive_clean }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{%- endif %} {%- endif %}

View File

@ -12,67 +12,66 @@
include: include:
- {{ sls_archive_install }} - {{ sls_archive_install }}
{%- for k in p.archive.wanted %} {%- for name in p.wanted %}
{%- set dir = p.archive.dir.opt + '/' + k + '-%s.%s-%s'|format(p.archive.versions[k], p.kernel, p.arch) %} {%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
prometheus-archive-alternatives-install-{{ k }}-home-cmd-run: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run:
cmd.run: cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }} - onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install {{ dir }} prometheus-{{ k }}-home {{ dir }} {{p.linux.altpriority}} - name: update-alternatives --install {{ p.dir.basedir }}/{{ bundle }} prometheus-{{ name }}-home {{ p.dir.basedir }}/{{ bundle }} {{p.linux.altpriority}}
- watch: - watch:
- archive: prometheus-archive-install-{{ k }}-archive-extracted - archive: prometheus-archive-install-{{ name }}-archive-extracted
- require: - require:
- sls: {{ sls_archive_install }} - sls: {{ sls_archive_install }}
prometheus-archive-alternatives-install-{{ k }}-home-alternatives-install: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
alternatives.install: alternatives.install:
- name: prometheus-{{ k }}-home - name: prometheus-{{ name }}-home
- link: {{ p.archive.dir.opt }}/{{ k }} - link: {{ p.dir.basedir }}/{{ name }}
- path: {{ dir }} - path: {{ p.dir.basedir }}/{{ bundle }}
- priority: {{ p.linux.altpriority }} - priority: {{ p.linux.altpriority }}
- order: 10 - order: 10
- watch: - watch:
- archive: prometheus-archive-install-{{ k }}-archive-extracted - archive: prometheus-archive-install-{{ name }}-archive-extracted
- require: - require:
- sls: {{ sls_archive_install }} - sls: {{ sls_archive_install }}
- onlyif: {{ grains.os_family not in ('Suse',) }} - onlyif: {{ grains.os_family not in ('Suse',) }}
prometheus-archive-alternatives-install-{{ k }}-home-alternatives-set: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-set:
alternatives.set: alternatives.set:
- name: prometheus-{{ k }}-home - name: prometheus-{{ name }}-home
- path: {{ dir }} - path: {{ p.dir.basedir }}/{{ bundle }}
- require: - require:
- cmd: prometheus-archive-alternatives-install-{{ k }}-home-cmd-run - cmd: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run
- alternatives: prometheus-archive-alternatives-install-{{ k }}-home-alternatives-install - alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
- onlyif: {{ grains.os_family not in ('Suse',) }} - onlyif: {{ grains.os_family not in ('Suse',) }}
{% for b in p.pkg[name]['binaries'] %}
{% for i in p.archive.binaries[k] %} prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}:
prometheus-archive-alternatives-install-{{ k }}-alternatives-install-{{ i }}:
cmd.run: cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }} - onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install /usr/bin/{{i}} prometheus-{{ k }}-{{i}} {{ dir }}/{{i}} {{p.linux.altpriority}} - name: update-alternatives --install /usr/local/bin/{{ b }} prometheus-{{ name }}-{{ b }} {{ p.dir.basedir }}/{{ bundle }}/{{ b }} {{ p.linux.altpriority }}
- require: - require:
- cmd: prometheus-archive-alternatives-install-{{ k }}-home-cmd-run - cmd: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run
alternatives.install: alternatives.install:
- name: prometheus-{{ k }}-{{ i }} - name: prometheus-{{ name }}-{{ b }}
- link: /usr/bin/{{ i }} - link: /usr/local/bin/{{ b }}
- path: {{ dir }}/{{ i }} - path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- priority: {{ p.linux.altpriority }} - priority: {{ p.linux.altpriority }}
- order: 10 - order: 10
- require: - require:
- alternatives: prometheus-archive-alternatives-install-{{ k }}-home-alternatives-install - alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
- onlyif: {{ grains.os_family not in ('Suse',) }} - onlyif: {{ grains.os_family not in ('Suse',) }}
prometheus-archive-alternatives-install-{{ k }}-alternatives-set-{{ i }}: prometheus-archive-alternatives-install-{{ name }}-alternatives-set-{{ b }}:
alternatives.set: alternatives.set:
- name: prometheus-{{ k }}-{{ i }} - name: prometheus-{{ name }}-{{ b }}
- path: {{ dir }}/{{ i }} - path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- require: - require:
- alternatives: prometheus-archive-alternatives-install-{{ k }}-alternatives-install-{{ i }} - alternatives: prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}
- onlyif: {{ grains.os_family not in ('Suse',) }} - onlyif: {{ grains.os_family not in ('Suse',) }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{%- endif %} {%- endif %}

View File

@ -6,37 +6,38 @@
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %} {%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
{%- if p.pkg.use_upstream_archive %} {%- if p.use_upstream_archive %}
include: include:
- {{ sls_alternatives_clean }} - {{ sls_alternatives_clean }}
{%- for k in p.archive.wanted %} {%- for name in p.wanted %}
{%- set dir = p.archive.dir.opt + '/' + k + '-%s.%s-%s'|format(p.archive.versions[k], p.kernel, p.arch) %}
prometheus-archive-clean-{{ k }}-file-absent: prometheus-archive-clean-{{ name }}-file-absent:
file.absent: file.absent:
- names: - names:
- {{ dir }} - {{ p.dir.basedir }}/{{ name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) }}
- {{ p.archive.systemd.dir }}/{{ k }}.service
#- require:
#- sls: {{ sls_alternatives_clean }}
prometheus-archive-clean-{{ k }}-user-absent:
user.absent:
- name: {{ k }}
group.absent:
- name: {{ k }}
- require: - require:
- user: prometheus-archive-clean-{{ k }}-user-absent - sls: {{ sls_alternatives_clean }}
prometheus-archive-clean-{{ name }}-user-absent:
user.absent:
- name: {{ name }}
group.absent:
- name: {{ name }}
- require:
- user: prometheus-archive-clean-{{ name }}-user-absent
- sls: {{ sls_alternatives_clean }}
{%- endfor %} {%- endfor %}
prometheus-archive-clean-file-directory: prometheus-archive-clean-file-directory:
file.absent: file.absent:
- names: - names:
- {{ p.archive.dir.opt }} - {{ p.dir.basedir }}
- {{ p.archive.dir.etc }} - {{ p.dir.etc }}
- {{ p.archive.dir.var }} - {{ p.dir.var }}
- require:
- sls: {{ sls_alternatives_clean }}
{%- endif %} {%- endif %}

View File

@ -1,89 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
prometheus:
archive:
wanted:
- prometheus
- alertmanager
- node_exporter
systemd:
dir: /usr/lib/systemd/system
after: docker.service
wants: network-online.target docker.target
uri: https://github.com/prometheus
suffix: tar.gz
kwargs:
trim_output: True
enforce_toplevel: True
archive_format: tar
retry:
attempts: 3
until: True
interval: 60
splay: 10
dir:
opt: /opt/prometheus
etc: /etc/prometheus
var: /var/lib/prometheus
binaries:
prometheus:
- prometheus
- promtool
alertmanager:
- amtool
- alertmanager
blackbox_exporter:
- blackbox_exporter
consul_exporter:
- consul_exporter
graphite_exporter:
- graphite_exporter
haproxy_exporter:
- haproxy_exporter
memcached_exporter:
- memcached_exporter
mysqld_exporter:
- mysqld_exporter
node_exporter:
- node_exporter
pushgateway:
- pushgateway
statsd_exporter:
- statsd_exporter
versions:
prometheus: '2.10.0'
alertmanager: '0.17.0'
blackbox_exporter: '0.14.0'
consul_exporter: '0.4.0'
graphite_exporter: '0.6.2'
haproxy_exporter: '0.10.0'
memcached_exporter: '0.5.0'
mysqld_exporter: '0.11.0'
node_exporter: '0.18.1'
pushgateway: '0.8.0'
statsd_exporter: '0.11.2'
hashes:
prometheus: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
alertmanager: 7c8d2cfeb021c80881ae9904d959131091b8785b6fda9800f84ddef148fe0a4f
blackbox_exporter: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117
consul_exporter: ff77c03de67cf381f67480b5be6699901785a34145c518c3484ae3e5b8440d08
graphite_exporter: 9b962bd06406ece4a865ad6947a6e652e48a92a0d77e496a0351c04e9c2c5e9e
haproxy_exporter: 08150728e281f813a8fcfff4b336f16dbfe4268a1c7510212c8cff2579b10468
memcached_exporter: bb07f496ceb63dad9793ad4295205547a4bd20b90628476d64fa96c9a25a020f
mysqld_exporter: b53ad48ff14aa891eb6a959730ffc626db98160d140d9a66377394714c563acf
node_exporter: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
pushgateway: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
statsd_exporter: 4632ad0c5552e271e84c376da3ffe3af8c265ec5c3035334b70e35756aca1906
configs:
prometheus: {}
alertmanager: {}
blackbox_exporter: {}
consul_exporter: {}
graphite_exporter: {}
haproxy_exporter: {}
memcached_exporter: {}
mysqld_exporter: {}
node_exporter: {}
pushgateway: {}
statsd_exporter: {}

View File

@ -5,7 +5,7 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- if prometheus.pkg.use_upstream_archive %} {%- if prometheus.use_upstream_archive %}
include: include:
- .install - .install

View File

@ -7,45 +7,64 @@
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %} {%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- for k in p.archive.wanted %} prometheus-archive-install-file-directory:
{%- set dir = p.archive.dir.opt + '/' + k + '-%s.%s-%s'|format(p.archive.versions[k], p.kernel, p.arch) %} file.directory:
- names:
- {{ p.dir.basedir }}
- {{ p.dir.etc }}
- {{ p.dir.var }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
prometheus-archive-install-{{ k }}-user-present: {%- for name in p.wanted %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
prometheus-archive-install-{{ name }}-user-present:
group.present: group.present:
- name: {{ k }} - name: {{ name }}
- require_in: - require_in:
- user: prometheus-archive-install-{{ k }}-user-present - user: prometheus-archive-install-{{ name }}-user-present
user.present: user.present:
- name: {{ k }} - name: {{ name }}
- shell: /bin/false - shell: /bin/false
- createhome: false - createhome: false
- groups: - groups:
- {{ k }} - {{ name }}
- require_in: - require_in:
- archive: prometheus-archive-install-{{ k }}-archive-extracted - archive: prometheus-archive-install-{{ name }}-archive-extracted
prometheus-archive-install-{{ k }}-archive-extracted: prometheus-archive-install-{{ name }}-archive-extracted:
archive.extracted: archive.extracted:
- name: {{ p.archive.dir.opt }} - name: {{ p.dir.basedir }}
- source: {{ p.archive.uri + '/' + k + '/releases/download/v' + p.archive.versions[k] - source: {{ p.archive.uri }}/{{ name }}/releases/download/v{{ p.pkg[name]['archive_version']
+ '/' + k + '-%s.%s-%s'|format(p.archive.versions[k], p.kernel, p.arch) + '/' + bundle + '.' + p.archive.suffix }}
+ '.' + p.archive.suffix }} - source_hash: {{ p.pkg[name]['archive_hash'] }}
- source_hash: {{ p.archive.hashes[k] }} - user: {{ name }}
- user: {{ k }} - group: {{ name }}
- group: {{ k }}
{{- format_kwargs(p.archive.kwargs) }} {{- format_kwargs(p.archive.kwargs) }}
- recurse: - recurse:
- user - user
- group - group
- require_in:
- file: prometheus-archive-install-{{ k }}-managed-systemd_file
- file: prometheus-archive-install-file-directory
prometheus-archive-install-{{ k }}-managed-systemd_file: {%- if name in p.service %}
prometheus-archive-install-{{ name }}-file-directory:
file.directory:
- name: {{ p.dir.var }}/{{ name }}
- user: {{ name }}
- group: {{ name }}
- mode: 755
- makedirs: True
- require:
- archive: prometheus-archive-install-{{ name }}-archive-extracted
prometheus-archive-install-{{ name }}-managed-service:
file.managed: file.managed:
- name: {{ p.archive.systemd.dir }}/{{ k }}.service - name: {{ p.dir.service }}/{{ name }}.service
- source: {{ files_switch(['systemd.ini.jinja'], - source: {{ files_switch(['systemd.ini.jinja'],
lookup='prometheus-archive-install-{{ k }}-managed-systemd_file' lookup='prometheus-archive-install-{{ name }}-managed-service'
) )
}} }}
- mode: 644 - mode: 644
@ -54,25 +73,15 @@ prometheus-archive-install-{{ k }}-managed-systemd_file:
- makedirs: True - makedirs: True
- template: jinja - template: jinja
- context: - context:
desc: prometheus - {{ k }} serice desc: prometheus - {{ name }} service
name: {{ k }} name: {{ name }}
user: {{ k }} user: {{ name }}
group: {{ k }} group: {{ name }}
start: {{ dir }}/{{ k }} --config.file {{ p.archive.dir.etc }}/{{ k }}/{{ k }}.yml workdir: {{ p.dir.var }}/{{ name }}
stop: killall {{ dir }}/{{ k }} start: {{ p.dir.basedir }}/{{ bundle }}/{{ name }} --config.file {{ p.dir.etc }}/{{ name }}.yml
after: {{ p.archive.systemd.after }} stop: '' #not needed
wants: {{ p.archive.systemd.wants }} - require:
- file: prometheus-archive-install-{{ name }}-file-directory
{%- endif %}
{%- endfor %} {%- endfor %}
prometheus-archive-install-file-directory:
file.directory:
- names:
- {{ p.archive.dir.opt }}
- {{ p.archive.dir.etc }}
- {{ p.archive.dir.var }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
##do not recurse!!!

View File

@ -1,54 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import concat_args %}
{%- if 'args' in prometheus.service %}
{%- set args = prometheus.service.get('args', {}) -%}
{%- if 'storage.tsdb.path' in args.keys() %}
prometheus-data-dir:
file.directory:
- name: {{ args['storage.tsdb.path'] }}
- owner: {{ prometheus.service.user }}
- group: {{ prometheus.service.group }}
- makedirs: True
- watch_in:
- service: prometheus-service-running-service-running
{%- endif %}
{# FreeBSD #}
{%- if salt['grains.get']('os_family') == 'FreeBSD' %}
{%- if 'storage.tsdb.path' in args.keys() %}
{%- set value = args.pop('storage.tsdb.path') %}
prometheus-config-args-storage-tsdb-path:
sysrc.managed:
- name: prometheus_data_dir
- value: {{ value }}
- watch_in:
- service: prometheus-service-running-service-running
{%- endif %}
prometheus-config-args-all:
sysrc.managed:
- name: prometheus_args
# service prometheus restart tended to hang on FreeBSD
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
- value: "{{ concat_args(args) }} >/dev/null 2>&1"
- watch_in:
- service: prometheus-service-running-service-running
{# Debian #}
{%- elif salt['grains.get']('os_family') == 'Debian'%}
prometheus-config-args-file-managed:
file.managed:
- name: {{ prometheus.args_file }}
- contents: |
ARGS="{{ concat_args(args) }}"
- watch_in:
- service: prometheus-service-running-service-running
{%- endif %}
{%- endif %}

View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
{%- set args = {} %}
{%- if 'args' in prometheus.service[name] %}
{%- set args = prometheus.service[name]['args'] or {} %}
{%- endif %}
{%- if args and 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-data-dir:
file.absent:
- name: {{ args['storage.tsdb.path'] }}
- require:
- sls: {{ sls_service_clean }}
{%- if grains.os_family == 'FreeBSD' %}
prometheus-config-args-{{ name }}-{{ key }}:
sysrc.absent:
- name: {{ name }}_data_dir
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- endif %}
{%- endif %}
{%- if args and grains.os_family == 'FreeBSD' %}
prometheus-config-args-{{ name }}-all:
sysrc.absent:
- names:
- {{ name }}_args
- {{ name }}_listen_address
- {{ name }}_textfile_dir
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- elif grains.os_family != 'FreeBSD' %}
prometheus-config-args-{{ name }}-file-absent:
file.absent:
- name: {{ prometheus.dir.args }}/{{ name }}.sh
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- .install

View File

@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import concat_args %}
{%- set sls_config_install = tplroot ~ '.config' %}
{%- set sls_service_install = tplroot ~ '.service' %}
include:
- {{ sls_config_install }}
- {{ sls_service_install }}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %}
{%- set args = {} %}
{%- if 'args' in prometheus.service[name] %}
{%- set args = prometheus.service[name]['args'] or {} %}
{%- endif %}
{%- if args and 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-data-dir:
file.directory:
- name: {{ args['storage.tsdb.path'] }}
- owner: {{ name }}
- group: {{ name }}
- makedirs: True
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- if args and grains.os_family == 'FreeBSD' %}
{%- if 'web.listen-address' in args.keys() %}
prometheus-config-args-args-web-listen-address:
sysrc.managed:
- name: {{ name }}_listen_address
- value: {{ args.pop('web.listen-address') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- if 'collector.textfile.directory' in args.keys() %}
prometheus-config-args-{{ name }}--collector-textfile-directory:
sysrc.managed:
- name: {{ name }}_textfile_dir
- value: {{ args.pop('collector.textfile.directory') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- if 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-{{ key }}:
sysrc.managed:
- name: {{ name }}_data_dir
- value: {{ args.pop('storage.tsdb.path') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
prometheus-config-args-{{ name }}-all:
sysrc.managed:
- name: {{ name }}_args
# service prometheus restart tended to hang on FreeBSD
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
- value: "{{ concat_args(args) }} >/dev/null 2>&1"
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- elif grains.os_family != 'FreeBSD' %}
prometheus-config-args-{{ name }}-file-managed:
file.managed:
- name: {{ prometheus.dir.args }}/{{ name }}.sh
- contents: |
ARGS="{{ concat_args(args) }}"
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,18 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_archive_clean = tplroot ~ '.archive.clean' %}
include: include:
- {{ sls_archive_clean }} - .file.clean
- .args.clean
prometheus-config-clean-file-absent:
file.absent:
- names:
- {{ prometheus.config_file }}
- {{ prometheus.environ_file }}
- require:
- sls: {{ sls_archive_clean }}

View File

@ -1,29 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
include:
- {{ sls_archive_install if prometheus.pkg.use_upstream_archive else sls_package_install }}
prometheus-config-file-file-managed-environ_file:
file.managed:
- name: {{ prometheus.environ_file }}
- source: {{ files_switch(['prometheus.sh.jinja'],
lookup='prometheus-config-file-file-managed-environ_file'
)
}}
- mode: 644
- user: root
- group: {{ prometheus.rootgroup }}
- makedirs: True
- template: jinja
- context:
prometheus: {{ prometheus|json }}
- require:
- sls: {{ sls_archive_install if prometheus.pkg.use_upstream_archive else sls_package_install }}

View File

@ -1,36 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- if 'config' in prometheus and prometheus.config %}
{%- if prometheus.pkg.use_upstream_archive %}
{%- set sls_package_install = tplroot ~ '.archive.install' %}
{%- else %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- endif %}
include:
- {{ sls_package_install }}
prometheus-config-file-file-managed-config_file:
file.managed:
- name: {{ prometheus.config_file }}
- source: {{ files_switch(['prometheus.yml.jinja'],
lookup='prometheus-config-file-file-managed-config_file'
)
}}
- mode: 644
- user: root
- group: {{ prometheus.rootgroup }}
- makedirs: True
- template: jinja
- context:
config: {{ prometheus.config|json }}
- require:
- sls: {{ sls_package_install }}
{%- endif %}

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name in prometheus.wanted %}
prometheus-config-file-{{ name }}-file-absent:
file.absent:
- name: {{ prometheus.dir.etc }}/{{ name }}.yml
- require:
- sls: {{ sls_service_clean }}
{%- endfor %}

View File

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- .install

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
include:
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %}
prometheus-config-file-{{ name }}-file-managed:
file.managed:
- name: {{ prometheus.dir.etc }}/{{ name }}.yml
- source: {{ files_switch(['config.yml.jinja'],
lookup='prometheus-config-file-{{ name }}-file-managed'
)
}}
- mode: 644
- user: {{ name }}
- group: {{ name }}
- makedirs: True
- template: jinja
- context:
config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }}
- require:
- sls: {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
{%- endif %}
{%- endfor %}

View File

@ -1,11 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
include: include:
- .args - .args
- .file - .file
- .environ

View File

@ -2,25 +2,104 @@
# vim: ft=yaml # vim: ft=yaml
--- ---
prometheus: prometheus:
pkg:
name: prometheus
use_upstream_archive: False
rootgroup: root rootgroup: root
kernel: {{ grains.kernel | lower }} kernel: {{ grains.kernel | lower }}
config_file: /etc/prometheus/prometheus.yml arch: {{ grains.osarch }}
config: {}
environ_file: /etc/default/prometheus.sh wanted:
environ: [] - prometheus
- alertmanager
- node_exporter
dir:
basedir: /opt/prometheus
etc: /etc/prometheus
var: /var/lib/prometheus
args: /etc/default
default: /etc/default
service: /usr/lib/systemd/system
service: service:
name: prometheus prometheus:
user: prometheus args:
group: prometheus web.listen-address: 0.0.0.0:9090
linux: alertmanager: {}
#'Alternatives system' priority: zero disables (default)
altpriority: 0 config:
exporters: prometheus: {}
node:
pkg: pkg:
name: prometheus-node-exporter prometheus:
service: prometheus-node-exporter archive_version: '2.10.0'
archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
binaries:
- prometheus
- promtool
alertmanager:
archive_version: '0.17.0'
archive_hash: 7c8d2cfeb021c80881ae9904d959131091b8785b6fda9800f84ddef148fe0a4f
binaries:
- amtool
- alertmanager
blackbox_exporter:
archive_version: '0.14.0'
archive_hash: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117
binaries:
- blackbox_exporter
consul_exporter:
archive_version: '0.4.0'
archive_hash: ff77c03de67cf381f67480b5be6699901785a34145c518c3484ae3e5b8440d08
binaries:
- consul_exporter
graphite_exporter:
archive_version: '0.6.2'
archive_hash: 9b962bd06406ece4a865ad6947a6e652e48a92a0d77e496a0351c04e9c2c5e9e
binaries:
- graphite_exporter
haproxy_exporter:
archive_version: '0.10.0'
archive_hash: 08150728e281f813a8fcfff4b336f16dbfe4268a1c7510212c8cff2579b10468
binaries:
- haproxy_exporter
memcached_exporter:
archive_version: '0.5.0'
archive_hash: bb07f496ceb63dad9793ad4295205547a4bd20b90628476d64fa96c9a25a020f
binaries:
- memcached_exporter
mysqld_exporter:
archive_version: '0.11.0'
archive_hash: b53ad48ff14aa891eb6a959730ffc626db98160d140d9a66377394714c563acf
binaries:
- mysqld_exporter
node_exporter:
archive_version: '0.18.1'
archive_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
binaries:
- node_exporter
pushgateway:
archive_version: '0.8.0'
archive_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
binaries:
- pushgateway
statsd_exporter:
archive_version: '0.11.2'
archive_hash: 4632ad0c5552e271e84c376da3ffe3af8c265ec5c3035334b70e35756aca1906
binaries:
- statsd_exporter
use_upstream_archive: False
archive:
uri: https://github.com/prometheus
suffix: tar.gz
kwargs:
trim_output: True
enforce_toplevel: True
archive_format: tar
retry:
attempts: 3
until: True
interval: 60
splay: 10
linux:
altpriority: 0 ##'Alternatives system' priority: zero disables (default)

View File

@ -1,14 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- if prometheus.exporters.keys()|length > 0 %}
include:
{%- for name in prometheus.exporters.keys()|list %}
- .{{ name }}
{%- endfor %}
{%- endif %}

View File

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
prometheus-exporters-node-service-dead:
service.dead:
- name: {{ prometheus.exporters.node.service }}
- enable: False
prometheus-exporters-node-pkg-removed:
pkg.removed:
- name: {{ prometheus.exporters.node.pkg.name }}
- require:
- service: prometheus-exporters-node-service-dead
{# FreeBSD #}
{%- if salt['grains.get']('os_family') == 'FreeBSD' %}
{%- for parameter in ['args', 'listen_address', 'textfile_dir'] %}
prometheus-exporters-node-args-{{ parameter }}:
sysrc.absent:
- name: node_exporter_{{ parameter }}
- require:
- service: prometheus-exporters-node-service-dead
{%- endfor %}
{%- endif %}

View File

@ -1,64 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import concat_args %}
prometheus-exporters-node-pkg-installed:
pkg.installed:
- name: {{ prometheus.exporters.node.pkg.name }}
{%- if 'args' in prometheus.exporters.node %}
{%- set args = prometheus.exporters.node.get('args', {}) -%}
{# FreeBSD #}
{%- if salt['grains.get']('os_family') == 'FreeBSD' %}
{%- if 'web.listen-address' in args.keys() %}
{%- set value = args.pop('web.listen-address') %}
prometheus-exporters-node-args-web-listen-address:
sysrc.managed:
- name: node_exporter_listen_address
- value: {{ value }}
- watch_in:
- service: prometheus-exporters-node-service-running
{%- endif %}
{%- if 'collector.textfile.directory' in args.keys() %}
{%- set value = args.pop('collector.textfile.directory') %}
prometheus-exporters-node-args-collector-textfile-directory:
sysrc.managed:
- name: node_exporter_textfile_dir
- value: {{ value }}
- watch_in:
- service: prometheus-exporters-node-service-running
{%- endif %}
prometheus-exporters-node-args:
sysrc.managed:
- name: node_exporter_args
# service node_exporter restart tended to hang on FreeBSD
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
- value: "{{ concat_args(args) }} >/dev/null 2>&1"
- watch_in:
- service: prometheus-exporters-node-service-running
{# Debian #}
{%- elif salt['grains.get']('os_family') == 'Debian'%}
prometheus-exporters-node-args:
file.managed:
- name: {{ prometheus.exporters.node.config_file }}
- contents: |
ARGS="{{ concat_args(args) }}"
- watch_in:
- service: prometheus-exporters-node-service-running
{%- endif %}
{%- endif %}
prometheus-exporters-node-service-running:
service.running:
- name: {{ prometheus.exporters.node.service }}
- enable: True
- watch:
- pkg: prometheus-exporters-node-pkg-installed

View File

@ -3,8 +3,8 @@
# Your changes may be overwritten. # Your changes may be overwritten.
######################################################################## ########################################################################
{%- if prometheus.environ %} {%- if defaults %}
{%- for item in prometheus.environ %} {%- for item in defaults %}
{{ item }} {{ item }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}

View File

@ -3,13 +3,14 @@
######################################################### #########################################################
[Unit] [Unit]
Description={{ desc }} Description={{ desc }}
Wants={{ wants }} Wants=network-online.target
After={{ after }} After=
Documentation=https://github.com/saltstack-formulas/prometheus-formula Documentation=https://github.com/saltstack-formulas/prometheus-formula
[Service] [Service]
User={{ user }} User={{ user }}
Group={{ group }} Group={{ group }}
WorkingDirectory={{ workdir }}
ExecStart={{ start }} ExecStart={{ start }}
ExecStop={{ stop }} ExecStop={{ stop }}
PIDFile=/var/run/{{ name }}.pid PIDFile=/var/run/{{ name }}.pid

View File

@ -6,6 +6,6 @@
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
include: include:
- {{ '.archive' if prometheus.pkg.use_upstream_archive else '.package' }} - {{ '.archive' if prometheus.use_upstream_archive else '.package' }}
- .config - .config
- .service - .service

View File

@ -5,24 +5,18 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{#- Start imports as #} {#- Start imports as #}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/archive/defaults.yaml" as archive_defaults %} {%- import_yaml tplroot ~ "/archive/defaults.yaml" as archive_defaults %}
{%- set defaults = salt['grains.filter_by'](default_settings, {%- set defaults = salt['grains.filter_by'](default_settings,
merge=salt['grains.filter_by'](archive_defaults, merge=salt['grains.filter_by'](archive_defaults,
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['grains.filter_by'](osmap, grain='os',
merge=salt['grains.filter_by'](osfingermap, grain='osfinger',
merge=salt['grains.filter_by'](osarchmap, grain='osarch', merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['pillar.get']('prometheus:lookup', default={}), merge=salt['pillar.get']('prometheus:lookup', default={}),
base='prometheus'), base='prometheus'),
base='prometheus'), base='prometheus'),
base='prometheus'), base='prometheus'),
base='prometheus'),
base='prometheus'),
base='prometheus') base='prometheus')
%} %}

View File

@ -14,14 +14,10 @@
{% set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %} {% set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- endif %} {%- endif %}
Debian: Debian: {}
args_file: /etc/default/prometheus
exporters:
node:
config_file: /etc/default/prometheus-node-exporter
RedHat: RedHat:
pkg: ## remove when https://github.com/saltstack-formulas/prometheus-formula/pull/4 is merged
use_upstream_archive: True use_upstream_archive: True
Suse: {} Suse: {}
@ -34,75 +30,107 @@ Alpine: {}
FreeBSD: FreeBSD:
rootgroup: wheel rootgroup: wheel
config_file: /usr/local/etc/prometheus.yml dir:
exporters: config: /usr/local/etc
node:
pkg: pkg:
name: node_exporter prometheus:
service: node_exporter archive_hash: 94a63f14baeadab2f17b5ae0bbeda6688e6d06f964ef4e32c2954a0ecf3996a1
archive: alertmanager:
hashes: archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
prometheus: 94a63f14baeadab2f17b5ae0bbeda6688e6d06f964ef4e32c2954a0ecf3996a1 blackbox_exporter:
alertmanager: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569 archive_hash: 2b92752decf2cf1883ce4f72301e4f911dab79efbd87db4df23dc9771e53e4af
blackbox_exporter: 2b92752decf2cf1883ce4f72301e4f911dab79efbd87db4df23dc9771e53e4af consul_exporter:
consul_exporter: 62e16c2f1acb9bf9411126478caccb5962da203cfb58d8c97f54b9c0add5171c archive_hash: 62e16c2f1acb9bf9411126478caccb5962da203cfb58d8c97f54b9c0add5171c
graphite_exporter: ff424b923733d8247314353ba4d13a1c4b06450c35f005bfd6c3b6ff60b047fd graphite_exporter:
haproxy_exporter: f32d158f9e3314828dc155a30a1f4c858876e1ea8ff543a4000afcbc7e923505 archive_hash: ff424b923733d8247314353ba4d13a1c4b06450c35f005bfd6c3b6ff60b047fd
memcached_exporter: 8fd53b9aede6b78e0530b159ccd0a437cf2f100da1ddc586681f389d804f5f19 haproxy_exporter:
mysqld_exporter: 9bcbbd8b3568818fd4c95d255c6f93c357ea25aed3364d7428f4ff9c89cd489a archive_hash: f32d158f9e3314828dc155a30a1f4c858876e1ea8ff543a4000afcbc7e923505
memcached_exporter:
archive_hash: 8fd53b9aede6b78e0530b159ccd0a437cf2f100da1ddc586681f389d804f5f19
mysqld_exporter:
archive_hash: 9bcbbd8b3568818fd4c95d255c6f93c357ea25aed3364d7428f4ff9c89cd489a
node_exporter: {} node_exporter: {}
pushgateway: ebcd21dc25e439eed64559e89cd7da9a94073d5ff321a8a3a4214ac2ebe04e34 pushgateway:
statsd_exporter: f345dff6311501f09bb5b6ba1128e925d504c6325ee97ad91a975f2be0d44da9 archive_hash: ebcd21dc25e439eed64559e89cd7da9a94073d5ff321a8a3a4214ac2ebe04e34
statsd_exporter:
archive_hash: f345dff6311501f09bb5b6ba1128e925d504c6325ee97ad91a975f2be0d44da9
OpenBSD: OpenBSD:
rootgroup: wheel rootgroup: wheel
kernel: openbsd kernel: openbsd
archive: pkg:
hashes: prometheus:
prometheus: c3c69919b359f00a84ef12f7ed6a956111790d64a71bd94990572baaf63377ce archive_hash: c3c69919b359f00a84ef12f7ed6a956111790d64a71bd94990572baaf63377ce
alertmanager: 88ce1b3f11bb28f24b98235994277b2c31aa03b2b2609e0058c04efa0cc5596f alertmanager:
blackbox_exporter: 0dee97d1204bac925bde919958ae890730d87386a816ed0b248c8038ee43794d archive_hash: 88ce1b3f11bb28f24b98235994277b2c31aa03b2b2609e0058c04efa0cc5596f
consul_exporter: b53ee2bd0e670907eac894387e286b0dd11eb3149fcd4e19ed586006d3de741a blackbox_exporter:
graphite_exporter: 98cbd7176f1c61023892de64ad26edc3cd7895037e3cc282c4edec53dded7156 archive_hash: 0dee97d1204bac925bde919958ae890730d87386a816ed0b248c8038ee43794d
haproxy_exporter: bc2b222f6a08232ef643cd6dcda3264f3bd7388a5bee25365cef137c7dea17e8 consul_exporter:
memcached_exporter: 21db1bffc561d47b4490ccb2cde721244d00e95f504cdcfee618bc4bb877e731 archive_hash: b53ee2bd0e670907eac894387e286b0dd11eb3149fcd4e19ed586006d3de741a
mysqld_exporter: b37d6fe68e2c884540ea41c5efcfb16d0bc5da517fe3ba713144504df1ba635d graphite_exporter:
node_exporter: {} archive_hash: 98cbd7176f1c61023892de64ad26edc3cd7895037e3cc282c4edec53dded7156
pushgateway: 0bce168e4b19234df9e954393a2102c91e4d62336b2721ed882f2003a4445d51 haproxy_exporter:
statsd_exporter: c89acb365b75af03ce612873d8b20226e3882c0177752ea0ce17a9f5e41eb5b4 archive_hash: bc2b222f6a08232ef643cd6dcda3264f3bd7388a5bee25365cef137c7dea17e8
memcached_exporter:
archive_hash: 21db1bffc561d47b4490ccb2cde721244d00e95f504cdcfee618bc4bb877e731
mysqld_exporter:
archive_hash: b37d6fe68e2c884540ea41c5efcfb16d0bc5da517fe3ba713144504df1ba635d
pushgateway:
archive_hash: 0bce168e4b19234df9e954393a2102c91e4d62336b2721ed882f2003a4445d51
statsd_exporter:
archive_hash: c89acb365b75af03ce612873d8b20226e3882c0177752ea0ce17a9f5e41eb5b4
Solaris: {} Solaris: {}
Windows: Windows:
kernel: windows kernel: windows
archive: dir:
name: C:\\Program Files opt: C:\\Program Files
hashes: pkg:
prometheus: eb138082a4d5e4d5b1e3ca838fa508f053474d46bca76e87ab0834f0d8b110db prometheus:
alertmanager: 512dbed02a3cc7e3f06d737f56179e458c462762b3427063b89c62a54d9645c6 archive_hash: eb138082a4d5e4d5b1e3ca838fa508f053474d46bca76e87ab0834f0d8b110db
blackbox_exporter: 21ea148870631310002cbd48be54ca45e8d300da5a902b0aec052f1a64316d93 alertmanager:
consul_exporter: 54579bc5dfa6a238e310a1874b0a362027661dfa1754535e74610dc8ef6163b1 archive_hash: 512dbed02a3cc7e3f06d737f56179e458c462762b3427063b89c62a54d9645c6
graphite_exporter: f83fad71bad99ccac145d65f82bf9d17fa37168a5dcce6415c6350e79a84e638 blackbox_exporter:
haproxy_exporter: 044118feb98b74eb921e27bd4b511732b553896c672c19bdd3418445dc030794 archive_hash: 21ea148870631310002cbd48be54ca45e8d300da5a902b0aec052f1a64316d93
memcached_exporter: 9e83c00c9d249c942f65b6a48112e6bd6e28a3d15b8a1d35e935621657b3d837 consul_exporter:
mysqld_exporter: 38605ae648f8def07a0f412d81a30a6c48c0d20a6981468d25b91c8aa529e599 archive_hash: 54579bc5dfa6a238e310a1874b0a362027661dfa1754535e74610dc8ef6163b1
node_exporter: {} graphite_exporter:
pushgateway: 506b555e7a13cabf3d85ec0dbe1bc6bc3a2444c0cc468baa8d31e7fc2fe18dd1 archive_hash: f83fad71bad99ccac145d65f82bf9d17fa37168a5dcce6415c6350e79a84e638
statsd_exporter: 9362b7482e74792f111c4bb1a372b18a88f6354c78f24713bacfbcb050883556 haproxy_exporter:
archive_hash: 044118feb98b74eb921e27bd4b511732b553896c672c19bdd3418445dc030794
memcached_exporter:
archive_hash: 9e83c00c9d249c942f65b6a48112e6bd6e28a3d15b8a1d35e935621657b3d837
mysqld_exporter:
archive_hash: 38605ae648f8def07a0f412d81a30a6c48c0d20a6981468d25b91c8aa529e599
pushgateway:
archive_hash: 506b555e7a13cabf3d85ec0dbe1bc6bc3a2444c0cc468baa8d31e7fc2fe18dd1
statsd_exporter:
archive_hash: 9362b7482e74792f111c4bb1a372b18a88f6354c78f24713bacfbcb050883556
MacOS: MacOS:
rootgroup: {{ macos_group | d('') }} rootgroup: {{ macos_group | d('') }}
kernel: darwin kernel: darwin
archive: pkg:
hashes: prometheus:
prometheus: 740e36bcacc0c5d4495f5341fcfa8b7e0dc623d12e8b07ac291052ea0a681325 archive_hash: 740e36bcacc0c5d4495f5341fcfa8b7e0dc623d12e8b07ac291052ea0a681325
alertmanager: efeebaa8e51c521ecb3440345fb65962533cae022d71dff8b127911e893ded2a alertmanager:
blackbox_exporter: a371d0496adb5d62368d6606928c5effd318d1387f6b9a9998f8d0333492645a archive_hash: efeebaa8e51c521ecb3440345fb65962533cae022d71dff8b127911e893ded2a
consul_exporter: 75641783938967c11c18d6d340028ff2dce7ad0ae5e300fa631b813cc6ea9647 blackbox_exporter:
graphite_exporter: f9c0aa745502c0ab01fdcca29181801810202e0aed512a9aa9a37bb4be88a919 archive_hash: a371d0496adb5d62368d6606928c5effd318d1387f6b9a9998f8d0333492645a
haproxy_exporter: 8fdb8bb182586c57e5892816a02846bae0998916765d22bb81b2c444a3565862 consul_exporter:
memcached_exporter: e10685cca5ffd8a3a7574b3dc096dc7418f34906abd399f881be06dd38be62cb archive_hash: 75641783938967c11c18d6d340028ff2dce7ad0ae5e300fa631b813cc6ea9647
mysqld_exporter: 8e0a7d8847790d6dcdcf392e6dd227458a7bcaa1e0890cc6326fdf956421f2a7 graphite_exporter:
node_exporter: 20fadb3108de0a9cc70a1333394e5be90416b4f91025f9fc66f5736335e94398 archive_hash: f9c0aa745502c0ab01fdcca29181801810202e0aed512a9aa9a37bb4be88a919
pushgateway: 25399a4c6600c1931f9d9bd5294700c2b53f964188b1c6003f9d12a2e176aac1 haproxy_exporter:
statsd_exporter: 15132494523c2b6a89e09b2da63452c8fe587fb82fcc3fd21cc75a4aa2766644 archive_hash: 8fdb8bb182586c57e5892816a02846bae0998916765d22bb81b2c444a3565862
memcached_exporter:
archive_hash: e10685cca5ffd8a3a7574b3dc096dc7418f34906abd399f881be06dd38be62cb
mysqld_exporter:
archive_hash: 8e0a7d8847790d6dcdcf392e6dd227458a7bcaa1e0890cc6326fdf956421f2a7
node_exporter:
archive_hash: 20fadb3108de0a9cc70a1333394e5be90416b4f91025f9fc66f5736335e94398
pushgateway:
archive_hash: 25399a4c6600c1931f9d9bd5294700c2b53f964188b1c6003f9d12a2e176aac1
statsd_exporter:
archive_hash: 15132494523c2b6a89e09b2da63452c8fe587fb82fcc3fd21cc75a4aa2766644

View File

@ -1,14 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['osfinger'] based logic.
# You just need to add the key:values for an `osfinger` that differ
# from `defaults.yaml` + `os_family.yaml` + `osmap.yaml`.
# Only add an `osfinger` which is/will be supported by the formula
#
# If you do not need to provide defaults via the `os_finger` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osfingermap: {}
---
# os: Ubuntu
Ubuntu-18.04: {}

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os'] based logic.
# You just need to add the key:values for an `os` that differ
# from `defaults.yaml` + `os_family.yaml`.
# Only add an `os` which is/will be supported by the formula
#
# If you do not need to provide defaults via the `os` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osmap: {}
---
# os_family: Debian
Ubuntu: {}
Raspbian: {}
# os_family: Gentoo
Funtoo: {}
# os_family: Arch
Manjaro: {}
# os_family: Solaris
SmartOS: {}

View File

@ -9,10 +9,16 @@
include: include:
- {{ sls_config_clean }} - {{ sls_config_clean }}
prometheus-package-clean-pkg-removed: {%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg %}
prometheus-package-clean-{{ name }}-removed:
pkg.removed: pkg.removed:
- name: {{ prometheus.pkg.name }} - name: {{ name }}
{%- if 'config' in prometheus and prometheus.config %} {%- if name in prometheus.service %}
- require: - require:
- sls: {{ sls_config_clean }} - service: prometheus-service-clean-{{ name }}-service-dead
{%- endif %} {%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -5,6 +5,10 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
prometheus-package-install-pkg-installed: {%- for name in prometheus.wanted %}
prometheus-package-install-{{ name }}-installed:
pkg.installed: pkg.installed:
- name: {{ prometheus.pkg.name }} - name: {{ name }}
{%- endfor %}

View File

@ -5,7 +5,16 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
prometheus-service-clean-service-dead: {%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
prometheus-service-clean-{{ name }}-service-dead:
service.dead: service.dead:
- name: {{ prometheus.service.name }} - name: {{ name }}
- enable: False - enable: False
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -3,29 +3,44 @@
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_args = tplroot ~ '.config.args' %} {%- set sls_config_args = tplroot ~ '.config.args.install' %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ '.config.file.install' %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus with context %}
include: include:
- {{ sls_config_args }} - {{ sls_config_args }}
- {{ sls_config_file }} - {{ sls_config_file }}
prometheus-service-running-service-unmasked: {%- for name in prometheus.wanted %}
service.unmasked: {%- if name in prometheus.service %}
- name: {{ prometheus.service.name }}
- onlyif: systemctl list-unit-files | grep {{ prometheus.service.name }} >/dev/null 2>&1
prometheus-service-running-service-running: prometheus-service-running-{{ name }}-service-unmasked:
service.running: service.unmasked:
- name: {{ prometheus.service.name }} - name: {{ name }}
- enable: True
{%- if 'config' in prometheus and prometheus.config %}
- watch:
- file: prometheus-config-file-file-managed-config_file
- require: - require:
- service: prometheus-service-running-service-unmasked
- sls: {{ sls_config_args }} - sls: {{ sls_config_args }}
- sls: {{ sls_config_file }} - sls: {{ sls_config_file }}
{%- if grains.kernel|lower == 'linux' %}
- onlyif:
- systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
{%- endif %} {%- endif %}
- onlyif: systemctl list-unit-files | grep {{ prometheus.service.name }} >/dev/null 2>&1
prometheus-service-running-{{ name }}-service-running:
service.running:
- name: {{ name }}
- enable: True
{%- if name in prometheus.config %}
- watch:
- file: prometheus-config-file-{{ name }}-file-managed
{%- endif %}
- require:
- service: prometheus-service-running-{{ name }}-service-unmasked
- sls: {{ sls_config_args }}
- sls: {{ sls_config_file }}
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
{%- endfor %}

View File