entercloudsuite.prometheus-exporter
Ansible Role: prometheus-exporter
This role installs the Prometheus exporter on Ubuntu 16.04 (Xenial).
Requirements
You need Ansible version 2.4 or higher.
Role Variables
Most variables are defined in the defaults/main.yml
file.
Example Playbook
To run with default variables:
- hosts: all
roles:
- { role: ansible-prometheus-exporter }
Testing
Testing is done using Molecule.
To test with Molecule:
- Run
molecule create
to start a Docker container. - Use
molecule login
to enter the container. - Edit the role files as needed.
- Add any extra roles needed in
molecule/default/requirements.yml
. - Edit
molecule/default/playbook.yml
. - Write tests in the
molecule/default/tests
folder. - Use
molecule converge
to run the playbook andmolecule verify
to run the tests.- The converge step will check the syntax of the role.
- After testing, use
molecule destroy
to remove the container.
You can also run all these steps at once with molecule test
.
To deploy to a VM, use the playbook_deploy.yml
file:
ansible-playbook ansible-prometheus-exporter/molecule/default/playbook_deploy.yml -i VM_IP_OR_FQDN, -u ubuntu --private-key private.pem
More Examples
Deploy node_exporter
Simple Playbook
- name: install node_exporter on all instances
hosts: all
roles:
- role: ansible-prometheus-exporter
prometheus_exporter_name: node_exporter
With More Options
- name: install node_exporter on all instances
hosts: all
roles:
- role: ansible-prometheus-exporter
prometheus_exporter_name: node_exporter
prometheus_exporter_config_flags:
'--web.listen-address': '0.0.0.0:9100'
'--log.level': 'info'
Deploy haproxy_exporter
Playbook
- role: entercloudsuite.prometheus-exporter
prometheus_exporter_version: 0.9.0
prometheus_exporter_name: "haproxy_exporter"
prometheus_enable_exporter_config_flags: true
prometheus_exporter_config_flags:
'--haproxy.scrape-uri': 'unix:/run/haproxy/admin.sock'
HAproxy Configuration
stats socket /run/haproxy/admin.sock mode 666 level admin
Deploy mysqld_exporter
Playbook
hosts: mysql_exporter
roles:
- role: entercloudsuite.prometheus-exporter
prometheus_exporter_name: mysqld_exporter
prometheus_exporter_version: 0.10.0
prometheus_environment_variables:
'DATA_SOURCE_NAME': 'exporter:v3rys3cr3tp4sw0rd@(mysqlhost:3306)/'
MySQL Configuration
Create User for Monitoring
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
Example Ansible Task
- name: Create user for monitoring
mysql_user:
name: "exporter"
host: localhost
password: "v3rys3cr3tp4sw0rd"
priv: '*.*:PROCESS,REPLICATION CLIENT,SELECT'
state: present
Deploy blackbox_exporter
To set a custom configuration file, use the variable prometheus_exporter_custom_conf_destination.
Example Playbook
- name: install blackbox_exporter on group
hosts: blackbox_exporter
roles:
- role: ansible-prometheus-exporter
prometheus_exporter_name: blackbox_exporter
prometheus_exporter_version: 0.12.0
prometheus_exporter_conf_main: black_box_exporter_example_config.yaml
prometheus_exporter_config_flags:
"--config.file": "{{ prometheus_exporter_custom_conf_destination }}/black_box_exporter_example_config.yaml"
Deploy postgres_exporter
Playbook
- name: install postgres_exporter on postgres_exporter group
hosts: postgres_exporter
roles:
- role: ansible-prometheus-exporter
prometheus_exporter_name: postgres_exporter
url: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.4.6/postgres_exporter_v0.4.6_linux-amd64.tar.gz
prometheus_environment_variables:
'DATA_SOURCE_NAME': 'postgresql://user:password@localhost:5432/?sslmode=disable'
Deploy uwsgi_exporter
Playbook
- name: install uwsgi_exporter on uwsgi instances
hosts: uwsgi
roles:
- role: ansible-prometheus-exporter
prometheus_exporter_name: uWSGI_exporter
url: https://github.com/AndreaGreco/prometeus_uwsgi_exporter/files/1734745/uWSGI_exporter-v1.1.linux-amd64.tar.gz
prometheus_exporter_conf_main: prometheus/config_uwsgi_exporter.yaml
prometheus_exporter_config_flags:
"-c": "{{ prometheus_exporters_common_root_dir }}/{{prometheus_exporter_name}}_current/config_uwsgi_exporter.yaml"
"-n": ""
License
MIT
Installa
ansible-galaxy install entercloudsuite.prometheus-exporter
Licenza
mit
Download
211.4k
Proprietario