https://github.com/atosatto/ansible-prometheus
An Ansible role to install and configure Prometheus (https://prometheus.io)
https://github.com/atosatto/ansible-prometheus
ansible molecule monitoring prometheus
Last synced: over 1 year ago
JSON representation
An Ansible role to install and configure Prometheus (https://prometheus.io)
- Host: GitHub
- URL: https://github.com/atosatto/ansible-prometheus
- Owner: atosatto
- License: mit
- Created: 2018-01-20T10:22:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T18:39:19.000Z (about 6 years ago)
- Last Synced: 2025-02-28T10:04:08.888Z (over 1 year ago)
- Topics: ansible, molecule, monitoring, prometheus
- Language: Python
- Size: 45.9 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Ansible Role: Prometheus
========================
[](https://travis-ci.org/atosatto/ansible-prometheus)
[](https://galaxy.ansible.com/atosatto/prometheus)
Install and configure Prometheus.
Requirements
------------
An Ansible 2.2 or higher installation.
This role makes use of the Ansible `json_filter` that requires `jmespath` to be installed on the Ansible machine.
See the `requirements.txt` file for further details on the specific version of `jmespath` required by the role.
Role Variables
--------------
Available variables are listed below, along with default values (see defaults/main.yml):
prometheus_release_tag: "latest"
The Prometheus release to be installed.
By default, the latest release published at https://github.com/prometheus/prometheus/releases.
prometheus_release_url: ""
If set, the role will download Prometheus from the provided URL instead of using the download URL indicated in the Prometheus Github release metadata.
prometheus_user: "prometheus"
prometheus_group: "prometheus"
Prometheus system user and group.
prometheus_install_path: "/opt"
Directory containing the downloaded Prometheus release artifacts.
prometheus_bin_path: "/usr/local/bin"
Directory to which the Prometheus binaries will be symlinked.
prometheus_config_path: "/etc/prometheus"
prometheus_config_file: "prometheus.yml"
Prometheus configuration file and directory
prometheus_config: {}
YAML dictionary holding the Prometheus configuration.
The complete Prometheus configuration reference can be found at
https://prometheus.io/docs/prometheus/latest/configuration/configuration/.
**NOTE**: the provided prometheus configuration will be merged with the default one defined in `vars/main.yml`.
prometheus_rule_files_path: "{{ prometheus_config_path }}/rules"
prometheus_rule_files: {}
# e.g.
# prometheus_rule_files:
# alertmanager: |
# groups:
# - name: alertmanager.rules
# rules:
# - alert: AlertmanagerNotificationsFailing
# expr: rate(alertmanager_notifications_failed_total[1m]) > 0
# for: 1m
# labels:
# service: alertmanager
# severity: critical
# annotations:
# title: Alertmanager is failing sending notications
# description: Alertmanager is seeing errors for integration {{$labels.integration}}
Dictionary of Prometheus rule files to be created into the specified `prometheus_rule_files_path`.
prometheus_listen_address: "127.0.0.1:9090"
The Prometheus WebServer listen ip address and port.
**NOTE**: the Prometheus metrics will be available at `{{ prometheus_listen_address }}/metrics`.
prometheus_tsdb_path: "/var/lib/prometheus"
prometheus_tsdb_retention: |-
{%- if prometheus_release_tag == 'latest' or prometheus_release_tag | regex_replace('^v(.*)$', '\\1') is version_compare('2.0.0', '>=') -%}
15d
{%- else -%}
360h0m0s
{%- endif -%}
Directory containing the Prometheus time-series database files.
By default, the old data will be deleted after 14 days.
An in depth analysis of the Operational Aspects of Prometheus Storage is available at
https://prometheus.io/docs/prometheus/latest/storage/#operational-aspects.
prometheus_log_level: "info"
Prometheus deamon log verbosity level.
prometheus_additional_cli_args: ""
Additional command-line arguments to be added to the Prometheus service unit.
For the complete refence of the available CLI arguments please refer to the output
of the `prometheus --help` command.
Dependencies
------------
None.
Example Playbooks
-----------------
$ cat playbook.yml
- name: "Install and configure Prometheus"
hosts: all
roles:
- { role: atosatto.prometheus }
Testing
-------
Tests are automated with [Molecule](http://molecule.readthedocs.org/en/latest/).
$ pip install tox
To test all the scenarios run
$ tox
To run a custom molecule command
$ tox -e py27-ansible29 -- molecule test -s prometheus-latest
License
-------
MIT
Author Information
------------------
Andrea Tosatto ([@\_hilbert\_](https://twitter.com/_hilbert_))