Skip to content

Commit 09529ad

Browse files
committed
Adding Grafana dashboard tutorial
Adding Grafana dashboard tutorial
1 parent 3987768 commit 09529ad

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
title: "Grafana dashboard"
3+
description: "Lotus supports exporting a wide range of metrics, enabling users to gain insights into its behavior and effectively analyze performance issues. These metrics can be conveniently utilized with aggregation and visualization tools for in-depth analysis. In this tutorial, we show how you can set up Prometheus and Grafana for monitoring and visualizing these metrics"
4+
lead: "Lotus supports exporting a wide range of metrics, enabling users to gain insights into its behavior and effectively analyze performance issues. These metrics can be conveniently utilized with aggregation and visualization tools for in-depth analysis. In this tutorial, we show how you can set up Prometheus and Grafana for monitoring and visualizing these metrics"
5+
draft: false
6+
menu:
7+
tutorials:
8+
parent: "tutorials-lotus"
9+
weight: 145
10+
toc: true
11+
---
12+
13+
- **Prometheus**: Prometheus is an open-source monitoring and alerting toolkit designed for collecting and storing time-series data from various systems and applications. It provides a robust querying language (PromQL) and a web-based interface for analyzing and visualizing metrics.
14+
15+
- **Grafana**: Grafana is an open-source platform for creating, sharing, and visualizing interactive dashboards and graphs. It integrates with various data sources, including Prometheus, to help users create meaningful visual representations of their data and set up alerting based on specific conditions.
16+
17+
## Prerequisites
18+
19+
- You have a Linux or Mac based system.
20+
- You have root access to install software
21+
- You have lotus node already running
22+
23+
**Note:** These instructions have been tested on Ubuntu 23.04 and on Mac M1.
24+
25+
## Install and start Prometheus
26+
27+
### On Ubuntu:
28+
29+
```
30+
# install prometheus
31+
sudo apt-get install prometheus
32+
33+
# copy the prometheus.yml config to the correct directory
34+
sudo cp metrics/prometheus.yml /etc/prometheus/prometheus.yml
35+
36+
# start prometheus
37+
sudo systemctl start prometheus
38+
39+
# enable prometheus on boot (optional)
40+
sudo systemctl enable prometheus
41+
```
42+
43+
### On Mac:
44+
45+
```
46+
# install prometheus
47+
brew install prometheus
48+
49+
# start prometheus
50+
prometheus --config.file=lotus/metrics/prometheus.yml
51+
```
52+
53+
## Install and start Grafana
54+
55+
### On Ubuntu:
56+
57+
```
58+
# download the Grafana GPG key in our keyring
59+
wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana.gpg > /dev/null
60+
61+
# add the Grafana repository to our APT sources
62+
echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
63+
64+
# update our APT cache
65+
sudo apt-get update
66+
67+
# now we can install grafana
68+
sudo apt-get install grafana
69+
70+
# start grafana
71+
sudo systemctl start grafana-server
72+
73+
# start grafana on boot (optional)
74+
sudo systemctl enable grafana-server
75+
```
76+
77+
### On Mac:
78+
79+
```
80+
brew install grafana
81+
brew services start grafana
82+
```
83+
84+
You should now have Prometheus and Grafana running on your machine where Prometheus is already collecting metrics from your Lotus node (if its running) and saving it to a database.
85+
86+
You can confirm everything is setup correctly by visiting:
87+
- Prometheus (http://localhost:9090): You can open the metric explorer and view any of the aggregated metrics scraped from Lotus
88+
- Grafana (http://localhost:3000): Default username/password is admin/admin, remember to change it after login.
89+
90+
## Add Prometheus as datasource in Grafana
91+
92+
1. Log in to Grafana using the web interface.
93+
2. Navigate to "Home" > "Connections" > "Data Sources."
94+
3. Click "Add data source."
95+
4. Choose "Prometheus."
96+
5. In the "HTTP" section, set the URL to http://localhost:9090.
97+
6. Click "Save & Test" to verify the connection.
98+
99+
## Import one of the existing dashboards in lotus/metrics/grafana
100+
101+
1. Log in to Grafana using the web interface.
102+
2. Navigate to "Home" > "Dashboards" > Click the drop down menu in the "New" button and select "Import"
103+
3. Paste any of the existing dashboards in lotus/metrics/grafana into the "Import via panel json" panel.
104+
4. Click "Load"
105+
5. Select the Prometheus datasource you created earlier
106+
6. Click "Import"
107+
108+
# Collect system metrics using node_exporter
109+
110+
Although Lotus includes many useful metrics it does not include system metrics, such as information about cpu, memory, disk, network, etc. If you are investigating an issue and have Lotus metrics available, its often very useful to correlate certain events or behaviour with general system metrics.
111+
112+
## Install node_exporter
113+
If you have followed this guide so far and have Prometheus and Grafana already running, you can run the following commands to also aggregate the system metrics:
114+
115+
Ubuntu:
116+
117+
```
118+
119+
# download the newest release by https://github.com/prometheus/node_exporter/releases (it was 1.6.1 as of writing this doc)
120+
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
121+
122+
# extract the release (it contains a single binary plus some docs)
123+
tar -xf node_exporter-1.6.1.linux-amd64.tar.gz
124+
125+
# move it to /usr/local/bin
126+
sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin
127+
128+
# run node_exporter
129+
node_exporter
130+
```
131+
132+
Mac:
133+
134+
```
135+
# install node_exporter
136+
brew install node_exporter
137+
138+
# run node_exporter
139+
node_exporter
140+
```
141+
142+
## Import system dashboard
143+
144+
Since our `prometheus.yml` config already has configuration for node_exporter, we can go straight away and import a Grafana dashboard for viewing:
145+
146+
1. Download the most recent dashboard from https://grafana.com/grafana/dashboards/1860-node-exporter-full/
147+
2. Log in to Grafana (http://localhost:3000) using the web interface.
148+
3. Navigate to "Home" > "Dashboards" > Click the drop down menu in the "New" button and select "Import"
149+
4. Paste any of the existing dashboards in lotus/metrics/grafana into the "Import via panel json" panel.
150+
5. Click "Load"
151+
6. Select the Prometheus datasource you created earlier
152+
7. Click "Import"

0 commit comments

Comments
 (0)