Cosmos Monitoring with Grafana & Prometheus

Jay | Human Being
Cypher Core
4 min readDec 20, 2018

--

Before you start, make sure prometheus is set to true in .gaia/config/config.toml.

Option 1 — Docker

  1. Install Docker and Docker Compose
  2. Clone this repo and change the working directory to node_tooling/monitoring
  3. Populated prometheus/prometheus.yml with the server’s public IP by running the setup.sh script. Modify prometheus/prometheus.yml if needed
  4. Finally start the containers

Option 2 — Bash Script

Here is a script I put together for those who don’t want to mess with Docker.

Option 3 — Manual Installation

1. Install Grafana

  • Navigate to your working directory of choice
  • Visit here and grab the download link for the architecture and OS that run on your device

For demonstration purposes, this tutorial will assume an amd64-based device running Linux is used.

2. Start Grafana Server As a Service

Choose either one of the approaches down below:

Option 1: via systemd

Optionally, you may make grafana-server start at boot

Option 2: init.d service

Optionally, you may make grafana-server start at boot

3. Download Prometheus

  • Navigate to your working directory of choice
  • Visit here and grab the download link for the architecture and OS that run on your device
  • Extract the tar.gz file
  • cd into the folder containing the extracted files

4. Configure Prometheus

  • Add the following in prometheus.yaml using your editor of choice

Feel free to change job_name and group to whatever you like. You can verify if your finished prometheus.yaml is valid using YAMLLint.

5. Start Prometheus

While still in the folder where the extracted files are located, run

Prometheus is now running. We will then need to configure a dashboard on Grafana.

6. Add a Data Source

  • Log in on Grafana.com with your registered account (register if you haven’t) by hitting the Log In button on the top right corner
Fig. 1
  • Once logged in, go to your Org Profile page and create a Grafana instance
Fig. 2
Fig. 3
  • Log in to the instance you just created, and start adding a data source by clicking on the gear button at the bottom of the column on the left. Then click on Add data source
Fig. 4

On the settings page make sure your settings match, or are at least close to what’s shown below:

Fig. 5
  • Hit “Save & Test” to finish adding the data source

7. Build a Dashboard

You are welcome to make your own dashboard. For your convenience, we have one ready for you in this tutorial. Simply follow the steps below to import it:

  • Start importing by clicking on the + button at the top of the column on the left. Paste in the JSON from here and load it
Fig. 6
  • Go to the Dashboards page by hitting the button below the + button. And Voilà ! You now have a working dashboard
Fig. 7

Bonus: Node Exporter

Download the latest Prometheus Node Exporter static binary from here, and extract it:

Change working directory to where you extracted the binary to, then run the node exporter:

Add the following in prometheus.yaml using your editor of choice.

Resources

[1] Katernoir. (2018, August 30). Monitoring/Alerting for your Validator. Retrieved December 20, 2018, from https://forum.cosmos.network/t/monitoring-alerting-for-your-validator/446/28

[2] Grafana. (n.d.). Installing on Debian / Ubuntu. Retrieved from http://docs.grafana.org/installation/debian/

[3] Prometheus. (n.d.). First steps with Prometheus. Retrieved December 20, 2018, from https://prometheus.io/docs/introduction/first_steps/

--

--

Jay | Human Being
Cypher Core

Blockchain | Distributed Consensus | Software Architecture | Pitbull | Columbia University SEAS '17.