[go: up one dir, main page]

Skip to content

Ansible role for installing Grafana, Prometheus and node_exporter for top-notch monitoring

License

Notifications You must be signed in to change notification settings

d-averkiev/ansible-monitoring

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible-monitoring
ansible-monitoring

Ansible role for installing Grafana, Prometheus and node_exporter

TravisCI

TestsVariablesUsageUse it on Raspberry PiCredits

screenshot

Tests

The role was tested in the following distributions using docker images.

Distribution Tested
Debian 9 Stretch
Ubuntu 16.04 Xenial Xerus

You can run the tests from the root directory using the following command.

distro=<distro> tests/runtests.sh
# <distro> is one of { debian9, ubuntu16 } (debian9 is the default one)

Variables

Variable Default Description
components [] Services to install. Possible values: { prometheus, node_exporter, grafana }

Usage

Inventory example:

[master]
halcyon1     ansible_connection=local

[workers]
halcyon2

[cluster:children]
master
workers

The last group is important because we need to tell Prometheus from where it should gather the metrics exported by node_exporter.

Then, you can use the provided playbooks in tests to install, start and stop the services.

---
#
# file: tests/monitoring_install.yml
#

- hosts: master
  become: True
  roles:
    - monitoring
  vars:
    components:
      - prometheus
      - node_exporter
      - grafana

- hosts: workers
  become: True
  roles:
    - monitoring
  vars:
    components:
      - node_exporter

As you can see, one node of the cluster will host Prometheus and Grafana, while the metrics will be gathered from all the nodes in the cluster.

ansible-playbook monitoring_install.yml

Keep in mind that the previous playbook doesn't start the services. This one does:

ansible-playbook monitoring_start.yml

You should be able to access Grafana and Prometheus using the browser. The installation includes two Grafana dashboards to check the status of the cluster and the individual nodes.

Use it on Raspberry Pi

I've successfully used this role in a Raspberry Pi 3 cluster with a few changes in defaults/main.yml.

First, update the variable prometheus_platform_suffix to armv7. Then, update the variables grafana_apt_key and grafana_apt_repo since you need to use an unofficial repository to install the latest Grafana version. You can find the official repos and keys at Installing Grafana.

Just add the following modification to defaults/main.yml.

#grafana_apt_key: https://packagecloud.io/gpg.key
#grafana_apt_repo: deb https://packagecloud.io/grafana/stable/debian/ jessie main

# Use these one instead if you want to install it on Raspberry Pi 3
grafana_apt_key: https://bintray.com/user/downloadSubjectPublicKey?username=bintray
grafana_apt_repo: deb https://dl.bintray.com/fg2it/deb jessie main

Credits

I've been inspired by the following open source projects:

About

Ansible role for installing Grafana, Prometheus and node_exporter for top-notch monitoring

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%