kibatic.prometheus
kibatic.prometheus for Ansible Galaxy
============
Overview
Role name in Ansible Galaxy: kibatic.prometheus
This Ansible role is designed for Prometheus and includes:
- Installation of specific versions of Prometheus server, Node exporter, Alertmanager.
- Handlers to restart, reload, or stop services.
- Basic configuration (actual configurations should be set by user templates; see Usage below).
This role installs 3 main components: Prometheus server, Node exporter, and Alertmanager. For additional Prometheus exporters, use the following roles:
- Consul: William-Yeh.consul_exporter
- Elasticsearch: William-Yeh.es_cluster_exporter
- MongoDB: williamyeh.mongodb_exporter
Role Variables
Required Variables
Specify which components to install:
prometheus_components:
- "prometheus"
- "alertmanager"
- "node_exporter"
Optional Variables: General Settings
User-configurable default settings:
prometheus_user: prometheus
prometheus_group: prometheus
prometheus_install_path: /opt/prometheus
prometheus_config_path: /etc/prometheus
prometheus_log_path: /var/log/prometheus
prometheus_pid_path: /var/run/prometheus
prometheus_download_path: /tmp
gosu_version: "1.10"
Optional Variables: systemd Settings
If your Linux distribution uses systemd, the role will use it. You can switch to traditional SysV-style scripts by setting the following variable to false
:
prometheus_node_exporter_use_systemd
Optional Variables: Prometheus Server
User-configurable defaults:
prometheus_version: 1.5.0
prometheus_rule_path: {{ prometheus_config_path }}/rules
prometheus_file_sd_config_path: {{ prometheus_config_path }}/tgroups
prometheus_db_path: /var/lib/prometheus
User-installable configuration file:
prometheus_conf_main
User-installable rule files:
prometheus_rule_files
Configure Alertmanager with:
prometheus_alertmanager_url
Optional Variables: Node Exporter
User-configurable defaults:
prometheus_node_exporter_version: 0.13.0
prometheus_node_exporter_opts
Optional Variables: Alertmanager
User-configurable defaults:
prometheus_alertmanager_version: 0.5.1
prometheus_alertmanager_db_path: /var/lib/alertmanager
User-installable Alertmanager configuration file:
prometheus_alertmanager_conf
Optional: Building From Source
You can also compile the components from the source by setting the respective versions to git
:
prometheus_version: git
prometheus_node_exporter_version: git
prometheus_alertmanager_version: git
To force rebuild each time, enable the following variable:
prometheus_rebuild: true
Handlers
Service controls for Prometheus server, Node exporter, and Alertmanager:
Prometheus server:
restart prometheus
reload prometheus
stop prometheus
Node exporter:
restart node_exporter
reload node_exporter
(same asrestart
)stop node_exporter
Alertmanager:
restart alertmanager
reload alertmanager
stop alertmanager
Usage
Step 1: Add Role
Include the role kibatic.prometheus
in your playbook.
Step 2: Add Variables
Set variables in your playbook if needed.
Simple example:
---
- hosts: all
become: True
roles:
- kibatic.prometheus
vars:
prometheus_components: [ "prometheus", "alertmanager" ]
prometheus_alertmanager_url: "http://localhost:9093/"
Step 3: Copy User's Config Files
More detailed example:
---
- hosts: all
become: True
roles:
- kibatic.prometheus
vars:
prometheus_components:
- prometheus
- node_exporter
- alertmanager
prometheus_rule_files:
this_is_rule_1_InstanceDown:
src: some/path/basic.rules
dest: basic.rules
prometheus_alertmanager_conf: some/path/alertmanager.yml.j2
Step 4: Access the Default Prometheus Pages
Open in your browser:
- Prometheus -
http://HOST:9090
orhttp://HOST:9090/consoles/node.html
- Alertmanager -
http://HOST:9093
Dependencies
None.
Contributors
License
MIT License. See the LICENSE file for details.
ansible-galaxy install kibatic.prometheus