Merge pull request #1 from storiesbi/feature/local
Initial implementation of local deployment.
This commit is contained in:
commit
bc1e13dbec
17 changed files with 597 additions and 20 deletions
12
README.rst
12
README.rst
|
@ -72,6 +72,8 @@ Configure prometheus server
|
|||
num_fingerprint_mutexes: 4096
|
||||
alertmanager:
|
||||
notification_queue_capacity: 10000
|
||||
host: localhost
|
||||
port: 9093
|
||||
config:
|
||||
global:
|
||||
scrape_interval: "15s"
|
||||
|
@ -135,6 +137,16 @@ Configure pushgateway
|
|||
enabled: true
|
||||
external_port: 15012
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
prometheus:
|
||||
pushgateway:
|
||||
enabled: true
|
||||
telemetry_path: /metrics
|
||||
bind:
|
||||
address: 0.0.0.0
|
||||
port: 9091
|
||||
|
||||
Documentation and Bugs
|
||||
======================
|
||||
|
||||
|
|
9
metadata/service/pushgateway/local.yml
Normal file
9
metadata/service/pushgateway/local.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
applications:
|
||||
- pushgateway
|
||||
parameters:
|
||||
prometheus:
|
||||
pushgateway:
|
||||
enabled: true
|
||||
bind:
|
||||
address: localhost
|
||||
port: 9091
|
9
metadata/service/pushgateway/single.yml
Normal file
9
metadata/service/pushgateway/single.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
applications:
|
||||
- pushgateway
|
||||
parameters:
|
||||
prometheus:
|
||||
pushgateway:
|
||||
enabled: true
|
||||
bind:
|
||||
address: 0.0.0.0
|
||||
port: 9091
|
|
@ -1,12 +1,62 @@
|
|||
{% from "prometheus/map.jinja" import alertmanager with context %}
|
||||
{%- if alertmanager.enabled %}
|
||||
|
||||
{%- if pillar.docker is defined and pillar.docker.host is defined %}
|
||||
|
||||
{{alertmanager.dir.config}}/alertmanager.yml:
|
||||
file.managed:
|
||||
- source: salt://prometheus/files/alertmanager.yml
|
||||
- template: jinja
|
||||
|
||||
{%- if not (pillar.docker is defined and pillar.docker.host is defined) %}
|
||||
|
||||
include:
|
||||
- prometheus.common
|
||||
|
||||
alertmanager_tarball:
|
||||
archive.extracted:
|
||||
- name: {{ alertmanager.dir.install }}
|
||||
- source: {{ alertmanager.source }}
|
||||
- source_hash: sha1={{ alertmanager.source_hash }}
|
||||
- archive_format: tar
|
||||
- if_missing: {{ alertmanager.dir.version_path }}
|
||||
|
||||
alertmanager_bin_link:
|
||||
file.symlink:
|
||||
- name: /usr/bin/alertmanager
|
||||
- target: {{ alertmanager.dir.version_path }}/alertmanager
|
||||
- require:
|
||||
- archive: alertmanager_tarball
|
||||
|
||||
alertmanager_defaults:
|
||||
file.managed:
|
||||
- name: /etc/default/alertmanager
|
||||
- source: salt://prometheus/files/default-alertmanager.jinja
|
||||
- template: jinja
|
||||
|
||||
alertmanager_service_unit:
|
||||
file.managed:
|
||||
{%- if grains.get('init') == 'systemd' %}
|
||||
- name: /etc/systemd/system/alertmanager.service
|
||||
- source: salt://prometheus/files/alertmanager.systemd.jinja
|
||||
{%- elif grains.get('init') == 'upstart' %}
|
||||
- name: /etc/init/alertmanager.conf
|
||||
- source: salt://prometheus/files/alertmanager.upstart.jinja
|
||||
{%- endif %}
|
||||
- watch:
|
||||
- file: alertmanager_defaults
|
||||
- require_in:
|
||||
- file: alertmanager_service
|
||||
|
||||
alertmanager_service:
|
||||
service.running:
|
||||
- name: alertmanager
|
||||
- enable: True
|
||||
- reload: True
|
||||
- watch:
|
||||
- file: alertmanager_service_unit
|
||||
- file: {{alertmanager.dir.config}}/alertmanager.yml
|
||||
- file: alertmanager_bin_link
|
||||
|
||||
{%- endif %}
|
||||
|
||||
|
||||
{%- endif %}
|
||||
|
|
20
prometheus/common.sls
Normal file
20
prometheus/common.sls
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% from "prometheus/map.jinja" import server with context %}
|
||||
|
||||
prometheus_user:
|
||||
user.present:
|
||||
- name: prometheus
|
||||
- shell: /bin/bash
|
||||
- system: true
|
||||
- home: /srv/prometheus
|
||||
|
||||
prometheus_dirs:
|
||||
file.directory:
|
||||
- names:
|
||||
- /var/log/prometheus
|
||||
- {{ server.dir.storage }}
|
||||
- {{ server.dir.config }}
|
||||
- makedirs: true
|
||||
- group: prometheus
|
||||
- user: prometheus
|
||||
- require:
|
||||
- user: prometheus
|
18
prometheus/files/alertmanager.systemd.jinja
Normal file
18
prometheus/files/alertmanager.systemd.jinja
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=The Alertmanager handles alerts sent by client applications such as the Prometheus server
|
||||
Documentation=https://prometheus.io/docs/alerting/alertmanager/
|
||||
Wants=basic.target
|
||||
After=basic.target network.target
|
||||
|
||||
[Service]
|
||||
User=prometheus
|
||||
Group=prometheus
|
||||
EnvironmentFile=/etc/default/alertmanager
|
||||
ExecStart=/usr/bin/alertmanager $ARGS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=always
|
||||
RestartSec=42s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
30
prometheus/files/alertmanager.upstart.jinja
Normal file
30
prometheus/files/alertmanager.upstart.jinja
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Prometheus Alert Manager (Upstart unit)
|
||||
description "The Alertmanager handles alerts sent by client applications such as the Prometheus server."
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [06]
|
||||
|
||||
env ALERTMANAGER=/usr/bin/alertmanager
|
||||
env USER=prometheus
|
||||
env GROUP=prometheus
|
||||
env DEFAULTS=/etc/default/alertmanager
|
||||
env RUNDIR=/var/run/alertmanager
|
||||
env PID_FILE=/var/run/alertmanager/alertmanager.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/alertmanager", if available.
|
||||
[ -e $DEFAULTS ] && . $DEFAULTS
|
||||
|
||||
export GOMAXPROCS=${GOMAXPROCS:-2}
|
||||
exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $ALERTMANAGER -S -- $ARGS
|
||||
end script
|
||||
|
||||
respawn
|
||||
respawn limit 10 10
|
||||
kill timeout 10
|
26
prometheus/files/default-alertmanager.jinja
Normal file
26
prometheus/files/default-alertmanager.jinja
Normal file
|
@ -0,0 +1,26 @@
|
|||
{%- from "prometheus/map.jinja" import alertmanager with context %}
|
||||
# Set the command-line arguments to pass to the server.
|
||||
ARGS="-config.file {{alertmanager.dir.config}}/alertmanager.yml -storage.path {{alertmanager.dir.storage}}"
|
||||
|
||||
# The alert manager supports the following options:
|
||||
# -config.file string
|
||||
# Alertmanager configuration file name.
|
||||
# (default "/etc/prometheus/alertmanager.yml")
|
||||
# -log.level value
|
||||
# Only log messages with the given severity or above.
|
||||
# Valid levels: [debug, info, warn, error, fatal]. (default info)
|
||||
# -storage.path string
|
||||
# Base path for data storage.
|
||||
# (default "/var/lib/prometheus/alertmanager/")
|
||||
# -web.external-url string
|
||||
# The URL under which Alertmanager is externally reachable (for example,
|
||||
# if Alertmanager is served via a reverse proxy). Used for generating
|
||||
# relative and absolute links back to Alertmanager itself. If the URL has
|
||||
# a path portion, it will be used to prefix all HTTP endpoints served by
|
||||
# Alertmanager. If omitted, relevant URL components will be derived
|
||||
# automatically.
|
||||
# -web.listen-address string
|
||||
# Address to listen on for the web interface and API. (default ":9093")
|
||||
# -web.local-assets string
|
||||
# Path to static assets/templates directory.
|
||||
# (default "/usr/share/prometheus/alertmanager/")
|
180
prometheus/files/default-prometheus.jinja
Normal file
180
prometheus/files/default-prometheus.jinja
Normal file
|
@ -0,0 +1,180 @@
|
|||
{%- from "prometheus/map.jinja" import server with context %}
|
||||
|
||||
# Set the command-line arguments to pass to the server.
|
||||
ARGS="-config.file {{server.dir.config}}/prometheus.yml -storage.local.path {{server.dir.storage}} -web.console.libraries {{server.dir.version_path}}/console_libraries -web.console.templates {{ server.dir.version_path }}/consoles -alertmanager.url {%- if server.alertmanager is defined %}{{server.alertmanager.get('host', 'localhost')}}:{{server.alertmanager.get('port', 9093)}}{%- endif %}"
|
||||
|
||||
# Prometheus supports the following options:
|
||||
|
||||
# -config.file "/etc/prometheus/prometheus.yml"
|
||||
# Prometheus configuration file name.
|
||||
#
|
||||
# == ALERTMANAGER ==
|
||||
#
|
||||
# -alertmanager.notification-queue-capacity 10000
|
||||
# The capacity of the queue for pending alert manager notifications.
|
||||
#
|
||||
# -alertmanager.timeout 10s
|
||||
# Alert manager HTTP API timeout.
|
||||
#
|
||||
# -alertmanager.url
|
||||
# The URL of the alert manager to send notifications to.
|
||||
#
|
||||
# == LOG ==
|
||||
#
|
||||
# -log.format
|
||||
# If set use a syslog logger or JSON logging. Example:
|
||||
# logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to
|
||||
# stderr.
|
||||
#
|
||||
# -log.level "info"
|
||||
# Only log messages with the given severity or above. Valid levels:
|
||||
# [debug, info, warn, error, fatal].
|
||||
#
|
||||
# == QUERY ==
|
||||
#
|
||||
# -query.max-concurrency 20
|
||||
# Maximum number of queries executed concurrently.
|
||||
#
|
||||
# -query.staleness-delta 5m0s
|
||||
# Staleness delta allowance during expression evaluations.
|
||||
#
|
||||
# -query.timeout 2m0s
|
||||
# Maximum time a query may take before being aborted.
|
||||
#
|
||||
# == STORAGE ==
|
||||
#
|
||||
# -storage.local.checkpoint-dirty-series-limit 5000
|
||||
# If approx. that many time series are in a state that would require
|
||||
# a recovery operation after a crash, a checkpoint is triggered, even if
|
||||
# the checkpoint interval hasn't passed yet. A recovery operation requires
|
||||
# a disk seek. The default limit intends to keep the recovery time below
|
||||
# 1min even on spinning disks. With SSD, recovery is much faster, so you
|
||||
# might want to increase this value in that case to avoid overly frequent
|
||||
# checkpoints.
|
||||
#
|
||||
# -storage.local.checkpoint-interval 5m0s
|
||||
# The period at which the in-memory metrics and the chunks not yet
|
||||
# persisted to series files are checkpointed.
|
||||
#
|
||||
# -storage.local.chunk-encoding-version 1
|
||||
# Which chunk encoding version to use for newly created chunks.
|
||||
# Currently supported is 0 (delta encoding) and 1 (double-delta encoding).
|
||||
#
|
||||
# -storage.local.dirty false
|
||||
# If set, the local storage layer will perform crash recovery even if
|
||||
# the last shutdown appears to be clean.
|
||||
#
|
||||
# -storage.local.index-cache-size.fingerprint-to-metric 10485760
|
||||
# The size in bytes for the fingerprint to metric index cache.
|
||||
#
|
||||
# -storage.local.index-cache-size.fingerprint-to-timerange 5242880
|
||||
# The size in bytes for the metric time range index cache.
|
||||
#
|
||||
# -storage.local.index-cache-size.label-name-to-label-values 10485760
|
||||
# The size in bytes for the label name to label values index cache.
|
||||
#
|
||||
# -storage.local.index-cache-size.label-pair-to-fingerprints 20971520
|
||||
# The size in bytes for the label pair to fingerprints index cache.
|
||||
#
|
||||
# -storage.local.max-chunks-to-persist 524288
|
||||
# How many chunks can be waiting for persistence before sample
|
||||
# ingestion will be throttled. Many chunks waiting to be persisted will
|
||||
# increase the checkpoint size.
|
||||
#
|
||||
# -storage.local.memory-chunks 1048576
|
||||
# How many chunks to keep in memory. While the size of a chunk is
|
||||
# 1kiB, the total memory usage will be significantly higher than this value
|
||||
# * 1kiB. Furthermore, for various reasons, more chunks might have to be
|
||||
# kept in memory temporarily. Sample ingestion will be throttled if the
|
||||
# configured value is exceeded by more than 10%.
|
||||
#
|
||||
# -storage.local.path "/var/lib/prometheus/metrics"
|
||||
# Base path for metrics storage.
|
||||
#
|
||||
# -storage.local.pedantic-checks false
|
||||
# If set, a crash recovery will perform checks on each series file.
|
||||
# This might take a very long time.
|
||||
#
|
||||
# -storage.local.retention 360h0m0s
|
||||
# How long to retain samples in the local storage.
|
||||
#
|
||||
# -storage.local.series-file-shrink-ratio 0.1
|
||||
# A series file is only truncated (to delete samples that have
|
||||
# exceeded the retention period) if it shrinks by at least the provided
|
||||
# ratio. This saves I/O operations while causing only a limited storage
|
||||
# space overhead. If 0 or smaller, truncation will be performed even for a
|
||||
# single dropped chunk, while 1 or larger will effectively prevent any
|
||||
# truncation.
|
||||
#
|
||||
# -storage.local.series-sync-strategy "adaptive"
|
||||
# When to sync series files after modification. Possible values:
|
||||
# 'never', 'always', 'adaptive'. Sync'ing slows down storage performance
|
||||
# but reduces the risk of data loss in case of an OS crash. With the
|
||||
# 'adaptive' strategy, series files are sync'd for as long as the storage
|
||||
# is not too much behind on chunk persistence.
|
||||
#
|
||||
# -storage.remote.graphite-address
|
||||
# The host:port of the remote Graphite server to send samples to.
|
||||
# None, if empty.
|
||||
#
|
||||
# -storage.remote.graphite-prefix
|
||||
# The prefix to prepend to all metrics exported to Graphite. None, if
|
||||
# empty.
|
||||
#
|
||||
# -storage.remote.graphite-transport "tcp"
|
||||
# Transport protocol to use to communicate with Graphite. 'tcp', if
|
||||
# empty.
|
||||
#
|
||||
# -storage.remote.influxdb-url
|
||||
# The URL of the remote InfluxDB server to send samples to. None, if
|
||||
# empty.
|
||||
#
|
||||
# -storage.remote.influxdb.database "prometheus"
|
||||
# The name of the database to use for storing samples in InfluxDB.
|
||||
#
|
||||
# -storage.remote.influxdb.retention-policy "default"
|
||||
# The InfluxDB retention policy to use.
|
||||
#
|
||||
# -storage.remote.influxdb.username
|
||||
# The username to use when sending samples to InfluxDB. The
|
||||
# corresponding password must be provided via the INFLUXDB_PW environment
|
||||
# variable.
|
||||
#
|
||||
# -storage.remote.opentsdb-url
|
||||
# The URL of the remote OpenTSDB server to send samples to. None, if
|
||||
# empty.
|
||||
#
|
||||
# -storage.remote.timeout 30s
|
||||
# The timeout to use when sending samples to the remote storage.
|
||||
#
|
||||
# == WEB ==
|
||||
#
|
||||
# -web.console.libraries "/etc/prometheus/console_libraries"
|
||||
# Path to the console library directory.
|
||||
#
|
||||
# -web.console.templates "/etc/prometheus/consoles"
|
||||
# Path to the console template directory, available at /consoles.
|
||||
#
|
||||
# -web.enable-remote-shutdown false
|
||||
# Enable remote service shutdown.
|
||||
#
|
||||
# -web.external-url
|
||||
# The URL under which Prometheus is externally reachable (for
|
||||
# example, if Prometheus is served via a reverse proxy). Used for
|
||||
# generating relative and absolute links back to Prometheus itself. If the
|
||||
# URL has a path portion, it will be used to prefix all HTTP endpoints
|
||||
# served by Prometheus. If omitted, relevant URL components will be derived
|
||||
# automatically.
|
||||
#
|
||||
# -web.listen-address ":9090"
|
||||
# Address to listen on for the web interface, API, and telemetry.
|
||||
#
|
||||
# -web.local-assets "/usr/share/prometheus/web/"
|
||||
# Path to static assets/templates directory.
|
||||
#
|
||||
# -web.telemetry-path "/metrics"
|
||||
# Path under which to expose metrics.
|
||||
#
|
||||
# -web.user-assets
|
||||
# Path to static asset directory, available at /user.
|
||||
#
|
19
prometheus/files/default-pushgateway.jinja
Normal file
19
prometheus/files/default-pushgateway.jinja
Normal file
|
@ -0,0 +1,19 @@
|
|||
{%- from "prometheus/map.jinja" import pushgateway with context %}
|
||||
# Set the command-line arguments to pass to the server.
|
||||
ARGS="-web.listen-address {{pushgateway.bind.get('address', '')}}:{{pushgateway.bind.get('port', 9091)}} -web.telemetry-path {{pushgateway.get('telemetry_path', '/metrics')}}"
|
||||
|
||||
#Usage of /usr/bin/pushgateway:
|
||||
# -log.format value
|
||||
# If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.
|
||||
# -log.level value
|
||||
# Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].
|
||||
# -persistence.file string
|
||||
# File to persist metrics. If empty, metrics are only kept in memory.
|
||||
# -persistence.interval duration
|
||||
# The minimum interval at which to write out the persistence file. (default 5m0s)
|
||||
# -version
|
||||
# Print version information.
|
||||
# -web.listen-address string
|
||||
# Address to listen on for the web interface, API, and telemetry. (default ":9091")
|
||||
# -web.telemetry-path string
|
||||
# Path under which to expose metrics. (default "/metrics")
|
18
prometheus/files/prometheus.systemd.jinja
Normal file
18
prometheus/files/prometheus.systemd.jinja
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Monitoring system and time series database
|
||||
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||
Wants=basic.target
|
||||
After=basic.target network.target
|
||||
|
||||
[Service]
|
||||
User=prometheus
|
||||
Group=prometheus
|
||||
EnvironmentFile=/etc/default/prometheus
|
||||
ExecStart=/usr/bin/prometheus $ARGS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=always
|
||||
RestartSec=42s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -6,7 +6,11 @@ global:
|
|||
{%- endif %}
|
||||
|
||||
rule_files:
|
||||
{%- if server.dir.config_in_container is defined %}
|
||||
- {{ server.dir.config_in_container }}/alerts.yml
|
||||
{%- else %}
|
||||
- {{ server.dir.config }}/alerts.yml
|
||||
{%- endif %}
|
||||
|
||||
{%- set static_target = {} %}
|
||||
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
||||
|
@ -43,7 +47,7 @@ scrape_configs:
|
|||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{%- if server.get('target', {}).get('kubernetes', {}).get('enabled', True) %}
|
||||
{%- if server.get('target', {}).get('kubernetes', {}).get('enabled', False) %}
|
||||
{%- set kubernetes_target = server.target.kubernetes %}
|
||||
- job_name: 'kubernetes-api'
|
||||
scheme: https
|
||||
|
|
18
prometheus/files/pushgateway.systemd.jinja
Normal file
18
prometheus/files/pushgateway.systemd.jinja
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Monitoring system and time series database
|
||||
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||
Wants=basic.target
|
||||
After=basic.target network.target
|
||||
|
||||
[Service]
|
||||
User=prometheus
|
||||
Group=prometheus
|
||||
EnvironmentFile=/etc/default/pushgateway
|
||||
ExecStart=/usr/bin/pushgateway $ARGS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=always
|
||||
RestartSec=42s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -7,4 +7,7 @@ include:
|
|||
{%- if pillar.prometheus.alertmanager is defined %}
|
||||
- prometheus.alertmanager
|
||||
{%- endif %}
|
||||
{%- if pillar.prometheus.pushgateway is defined %}
|
||||
- prometheus.pushgateway
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
|
|
@ -1,16 +1,70 @@
|
|||
{% set server = salt['grains.filter_by']({
|
||||
'default': {
|
||||
'dir': {
|
||||
'config': '/srv/volumes/prometheus',
|
||||
'config_in_container': '/opt/prometheus/config'
|
||||
},
|
||||
},
|
||||
}, merge=salt['pillar.get']('prometheus:server')) %}
|
||||
|
||||
{% set alertmanager = salt['grains.filter_by']({
|
||||
'default': {
|
||||
'dir': {
|
||||
'config': '/srv/volumes/prometheus',
|
||||
},
|
||||
},
|
||||
}, merge=salt['pillar.get']('prometheus:alertmanager')) %}
|
||||
{%- set version = pillar.prometheus.get('version', '1.6.2') %}
|
||||
|
||||
{%- load_yaml as base_defaults %}
|
||||
{%- if pillar.docker is defined and pillar.docker.host is defined %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /srv/volumes/prometheus
|
||||
config_in_container: /opt/prometheus/config
|
||||
{%- else %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /etc/prometheus
|
||||
storage: /var/lib/prometheus/metrics
|
||||
install: /opt
|
||||
version_path: /opt/prometheus-{{ version }}.linux-amd64
|
||||
version: {{ version }}.linux-amd64
|
||||
source: https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz
|
||||
source_hash: 7a7f3b3c8d886975c9c1c443ac4ccca053e834a7
|
||||
|
||||
{%- endif %}
|
||||
{%- endload %}
|
||||
|
||||
{%- set server = salt['grains.filter_by'](base_defaults, merge=salt['pillar.get']('prometheus:server')) %}
|
||||
|
||||
{%- set alertmanager_version = pillar.prometheus.get('alertmanager', {}).get('version', '0.6.2') %}
|
||||
|
||||
{%- load_yaml as alertmanager_defaults %}
|
||||
{%- if pillar.docker is defined and pillar.docker.host is defined %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /srv/volumes/prometheus
|
||||
{%- else %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /etc/prometheus
|
||||
storage: /var/lib/prometheus/metrics
|
||||
install: /opt
|
||||
version_path: /opt/alertmanager-{{ alertmanager_version }}.linux-amd64
|
||||
version: {{ alertmanager_version }}.linux-amd64
|
||||
source: https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/alertmanager-{{ alertmanager_version }}.linux-amd64.tar.gz
|
||||
source_hash: 82990573096a5805a3db48c729dc111b151c1c24
|
||||
|
||||
{%- endif %}
|
||||
{%- endload %}
|
||||
|
||||
{%- set alertmanager = salt['grains.filter_by'](alertmanager_defaults, merge=salt['pillar.get']('prometheus:alertmanager')) %}
|
||||
|
||||
{%- set pushgateway_version = pillar.prometheus.get('pushgateway', {}).get('version', '0.3.1') %}
|
||||
|
||||
{%- load_yaml as pushgateway_defaults %}
|
||||
{%- if pillar.docker is defined and pillar.docker.host is defined %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /srv/volumes/prometheus
|
||||
{%- else %}
|
||||
Debian:
|
||||
dir:
|
||||
config: /etc/prometheus
|
||||
storage: /var/lib/prometheus-pushgateway/metrics
|
||||
install: /opt
|
||||
version_path: /opt/pushgateway-{{ pushgateway_version }}.linux-amd64
|
||||
version: {{ pushgateway_version }}.linux-amd64
|
||||
source: https://github.com/prometheus/pushgateway/releases/download/v{{ pushgateway_version }}/pushgateway-{{ pushgateway_version }}.linux-amd64.tar.gz
|
||||
source_hash: 237061c45d2b5f4ff706528ed5f4203578901f0d
|
||||
|
||||
{%- endif %}
|
||||
{%- endload %}
|
||||
|
||||
{%- set pushgateway = salt['grains.filter_by'](pushgateway_defaults, merge=salt['pillar.get']('prometheus:pushgateway')) %}
|
||||
|
|
57
prometheus/pushgateway.sls
Normal file
57
prometheus/pushgateway.sls
Normal file
|
@ -0,0 +1,57 @@
|
|||
{% from "prometheus/map.jinja" import pushgateway with context %}
|
||||
|
||||
{%- if pushgateway.enabled %}
|
||||
|
||||
{%- if not (pillar.docker is defined and pillar.docker.host is defined) %}
|
||||
|
||||
include:
|
||||
- prometheus.common
|
||||
|
||||
pushgateway_tarball:
|
||||
archive.extracted:
|
||||
- name: {{ pushgateway.dir.install }}
|
||||
- source: {{ pushgateway.source }}
|
||||
- source_hash: sha1={{ pushgateway.source_hash }}
|
||||
- archive_format: tar
|
||||
- if_missing: {{ pushgateway.dir.version_path }}
|
||||
|
||||
pushgateway_bin_link:
|
||||
file.symlink:
|
||||
- name: /usr/bin/pushgateway
|
||||
- target: {{ pushgateway.dir.version_path }}/pushgateway
|
||||
- require:
|
||||
- archive: pushgateway_tarball
|
||||
|
||||
pushgateway_defaults:
|
||||
file.managed:
|
||||
- name: /etc/default/pushgateway
|
||||
- source: salt://prometheus/files/default-pushgateway.jinja
|
||||
- template: jinja
|
||||
|
||||
pushgateway_service_unit:
|
||||
file.managed:
|
||||
{%- if grains.get('init') == 'systemd' %}
|
||||
- name: /etc/systemd/system/pushgateway.service
|
||||
- source: salt://prometheus/files/pushgateway.systemd.jinja
|
||||
{%- elif grains.get('init') == 'upstart' %}
|
||||
- name: /etc/init/pushgateway.conf
|
||||
- source: salt://prometheus/files/pushgateway.upstart.jinja
|
||||
{%- endif %}
|
||||
- watch:
|
||||
- file: pushgateway_defaults
|
||||
- require_in:
|
||||
- file: pushgateway_service
|
||||
|
||||
pushgateway_service:
|
||||
service.running:
|
||||
- name: pushgateway
|
||||
- enable: True
|
||||
- reload: True
|
||||
- watch:
|
||||
- file: pushgateway_service_unit
|
||||
- file: pushgateway_bin_link
|
||||
|
||||
{%- endif %}
|
||||
|
||||
|
||||
{%- endif %}
|
|
@ -1,7 +1,6 @@
|
|||
{% from "prometheus/map.jinja" import server with context %}
|
||||
{%- if server.enabled %}
|
||||
|
||||
{%- if pillar.docker is defined and pillar.docker.host is defined %}
|
||||
{%- if server.enabled %}
|
||||
|
||||
{{server.dir.config}}/prometheus.yml:
|
||||
file.managed:
|
||||
|
@ -13,5 +12,56 @@
|
|||
- source: salt://prometheus/files/alerts.yml
|
||||
- template: jinja
|
||||
|
||||
{%- if not (pillar.docker is defined and pillar.docker.host is defined) %}
|
||||
|
||||
include:
|
||||
- prometheus.common
|
||||
|
||||
prometheus_server_tarball:
|
||||
archive.extracted:
|
||||
- name: {{ server.dir.install }}
|
||||
- source: {{ server.source }}
|
||||
- source_hash: sha1={{ server.source_hash }}
|
||||
- archive_format: tar
|
||||
- if_missing: {{ server.dir.version_path }}
|
||||
|
||||
prometheus_bin_link:
|
||||
file.symlink:
|
||||
- name: /usr/bin/prometheus
|
||||
- target: {{ server.dir.version_path }}/prometheus
|
||||
- require:
|
||||
- archive: prometheus_server_tarball
|
||||
|
||||
prometheus_defaults:
|
||||
file.managed:
|
||||
- name: /etc/default/prometheus
|
||||
- source: salt://prometheus/files/default-prometheus.jinja
|
||||
- template: jinja
|
||||
|
||||
prometheus_service_unit:
|
||||
file.managed:
|
||||
{%- if grains.get('init') == 'systemd' %}
|
||||
- name: /etc/systemd/system/prometheus.service
|
||||
- source: salt://prometheus/files/prometheus.systemd.jinja
|
||||
{%- elif grains.get('init') == 'upstart' %}
|
||||
- name: /etc/init/prometheus.conf
|
||||
- source: salt://prometheus/files/prometheus.upstart.jinja
|
||||
{%- endif %}
|
||||
- watch:
|
||||
- file: prometheus_defaults
|
||||
- require_in:
|
||||
- file: prometheus_service
|
||||
|
||||
prometheus_service:
|
||||
service.running:
|
||||
- name: prometheus
|
||||
- enable: True
|
||||
- reload: True
|
||||
- watch:
|
||||
- file: prometheus_service_unit
|
||||
- file: {{server.dir.config}}/prometheus.yml
|
||||
- file: prometheus_bin_link
|
||||
|
||||
{%- endif %}
|
||||
|
||||
{%- endif %}
|
||||
|
|
Loading…
Reference in a new issue