ernestas-poskus.ansible-prometheus

ansible-prometheus

Build Status

This is an Ansible playbook for installing the Prometheus monitoring system.

The playbook installs and manages services using systemd. Currently, it supports:

  • Prometheus
  • Node Exporter (which collects metrics from the host machine)
  • Alert Manager
  • Push Gateway
  • SNMP Exporter
  • Blackbox Exporter

You can find default configuration options in default/main.yml.

Contribution

If you can't find the exporter you need, please check these examples #47 or #50 and consider making a pull request.

Installation

You can install the playbook with the following command:

ansible-galaxy install ernestas-poskus.ansible-prometheus

Requirements

  • Systemd is required.

Role Variables

Here are the default variables for ansible-prometheus:

---
# Defaults for ansible-prometheus

prometheus_install: true
prometheus_node_exporter_install: true
prometheus_alert_manager_install: true
prometheus_push_gateway_install: false
prometheus_snmp_exporter_install: false
prometheus_blackbox_exporter_install: false

prometheus_owner: 'prometheus'
prometheus_group: 'prometheus'

prometheus_install_dir: '/usr/local/opt'
prometheus_config_dir: '/etc/prometheus'
prometheus_lib_dir: '/var/lib/prometheus'
prometheus_rules_dir: "{{ prometheus_config_dir }}/rules"

prometheus_data_dir: "{{ prometheus_lib_dir }}/prometheus2"
prometheus_alert_manager_data_dir: "{{ prometheus_lib_dir }}/alertmanager"
prometheus_alert_manager_config_dir: "{{ prometheus_config_dir }}/alertmanager"
prometheus_alert_manager_templates_dir: "{{ prometheus_config_dir }}/alertmanager/templates"
prometheus_snmp_exporter_config_dir: "{{ prometheus_config_dir }}/snmpexporter"
prometheus_blackbox_exporter_config_dir: "{{ prometheus_config_dir }}/blackboxexporter"

# Prometheus
prometheus_version: '2.25.1'
prometheus_platform_architecture: 'linux-amd64'

# Open file limit settings
prometheus_service_limitnofile: infinity

# Node Exporter
prometheus_node_exporter_version: '1.1.2'

# Alert Manager
prometheus_alert_manager_version: '0.21.0'

# Push Gateway
prometheus_push_gateway_version: '1.4.0'

# SNMP Exporter
prometheus_snmp_exporter_version: '0.20.0'

# Blackbox Exporter
prometheus_blackbox_exporter_version: '0.18.0'

For more information, refer to the Prometheus variables and others linked below.

Dependencies

There are no dependencies.

Example Playbook

Here's an example of how to use this role to install Prometheus:

- name: Installing Prometheus on hosted machine
  hosts: vagrant1
  sudo: yes
  roles:
    - role: ansible-prometheus
      prometheus_config_scrape_configs:
        - job_name: 'prometheus'
          honor_labels: true
          scrape_interval: '15s'
          scrape_timeout: '3s'
          metrics_path: '/metrics'
          scheme: 'http'
          static_configs:
            - targets:
                - 'localhost:9090' # Prometheus itself
                - 'localhost:9100' # Node Exporter
        - job_name: 'consul-services'
          consul_sd_configs:
            - server: "localhost:8500"

License

Copyright (c) 2021, Ernestas Poskus
All rights reserved.

You can use and modify this software as long as you keep the copyright notice and this list of conditions.

This software is provided "as is" without any express or implied warranties. The authors are not liable for any damages related to the use of this software.

Author Information

You can reach the author on Twitter: @ernestas_poskus

Informazioni sul progetto

Ansible playbook for managing Prometheus monitoring system

Installa
ansible-galaxy install ernestas-poskus.ansible-prometheus
Licenza
bsd-3-clause
Download
6.6k
Proprietario
pragmatic & ambitious