Role name in Ansible Galaxy: williamyeh.prometheus
This Ansible role has the following features for Prometheus:
- Install specific versions of Prometheus server, node_exporter, and alertmanager.
- Handlers for restart/reload/stop events;
- Bare bone configuration (real configuration should be left to user's template files; see Usage section below).
None.
User-configurable defaults:
# user and group
prometheus_user: prometheus
prometheus_group: prometheus
# which components to install?
# possible values:
# - "prometheus"
# - "node_exporter"
# - "alertmanager"
prometheus_components: [ "prometheus", "node_exporter" ]
# directory for executable files
prometheus_install_path: /opt/prometheus
# directory for configuration files
prometheus_config_path: /etc/prometheus
# directory for logs
prometheus_log_path: /var/log/prometheus
# directory for PID files
prometheus_pid_path: /var/run/prometheus
# directory for temporary files
prometheus_download_path: /tmp
# version of helper utility "gosu"
gosu_version: 1.4
User-configurable defaults:
# which version?
prometheus_version: 0.15.1
# directory for rule files
prometheus_rule_path: {{ prometheus_config_path }}/rules
# directory for file_sd files
prometheus_file_sd_config_path: {{ prometheus_config_path }}/tgroups
# directory for runtime database
prometheus_db_path: /var/lib/prometheus
User-installable configuration file (see doc for details):
# main conf template relative to `playbook_dir`;
# to be installed to "{{ prometheus_config_path }}/prometheus.yml"
prometheus_conf_main
User-installable rule files (see doc for details):
# rule files to be installed to "{{ prometheus_rule_path }}" directory;
# dict fields:
# - key: memo for this rule
# - value:
# - src: file relative to `playbook_dir`
# - dest: target file relative to `{{ prometheus_rule_path }}`
prometheus_rule_files
Alertmanager to be triggered:
prometheus_alertmanager_url
User-configurable defaults:
# which version?
prometheus_node_exporter_version: 0.11.0
User-configurable defaults:
# which version?
prometheus_alertmanager_version: 0.0.4
# directory for runtime database
prometheus_alertmanager_db_path: /var/lib/alertmanager
User-installable alertmanager conf file (see doc for details):
# main conf template relative to `playbook_dir`;
# to be installed to "{{ prometheus_config_path }}/alertmanager.conf"
prometheus_alertmanager_conf
Prometheus server:
-
restart prometheus
-
reload prometheus
-
stop prometheus
Alert manager:
-
restart alertmanager
-
reload alertmanager
-
stop alertmanager
Add role name williamyeh.prometheus
to your playbook file.
Set vars in your playbook file, if necessary.
Simple example:
---
# file: simple-playbook.yml
- hosts: all
sudo: True
roles:
- williamyeh.prometheus
vars:
prometheus_components: [ "prometheus", "alertmanager" ]
prometheus_alertmanager_url: "http://localhost:9093/"
More practical example:
---
# file: complex-playbook.yml
- hosts: all
sudo: True
roles:
- williamyeh.prometheus
vars:
prometheus_rule_files:
this_is_rule_1_InstanceDown:
src: some/path/basic.rules
dest: basic.rules
prometheus_alertmanager_conf: some/path/alertmanager.conf.j2
Open the page in your browser: http://
HOST:9090
None.
MIT License. See the LICENSE file for details.