CoinCashew
English
Search
⌃K
Links

10. Setup Prometheus and Grafana Dashboard

🔮
0. Introduction

Prometheus is a monitoring platform that collects metrics from monitored targets by scraping metrics HTTP endpoints on these targets. Official documentation is available here. Grafana is a dashboard used to visualize the collected data.

🐣
1. Installation

Install prometheus and prometheus node exporter.
sudo apt-get install -y prometheus prometheus-alertmanager prometheus-node-exporter
Install grafana with su.
sudo su
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" > /etc/apt/sources.list.d/grafana.list
sudo apt-get update && sudo apt-get install -y grafana
sudo systemctl start grafana-server.service
exit
Enable services so they start automatically.
sudo systemctl enable grafana-server.service
sudo systemctl enable prometheus.service
sudo systemctl enable prometheus-node-exporter.service
To verify that the service has started:
sudo systemctl status grafana-server.service
sudo systemctl status prometheus-node-exporter.service
sudo systemctl status prometheus.service
Update prometheus.yml
sudo su
cat > /etc/prometheus/prometheus.yml << EOF
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label job=<job_name> to any timeseries scraped from this config.
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9100']
EOF
exit
Finally, restart services.
sudo systemctl restart grafana-server.service
sudo systemctl restart prometheus.service
sudo systemctl restart prometheus-node-exporter.service

📶
2. Setting up Grafana Dashboards

  1. 2.
    Login with admin / admin
  2. 3.
    Change password
  3. 4.
    Click the configuration gear icon, then Data Source
  4. 5.
    Select prometheus
  5. 6.
    Set URL to http://localhost:9090
  6. 7.
    Click Save & Test
  7. 8.
    Click Create + icon > Import
  8. 9.
    Add dashboard by importing id: 11074
  9. 10.
    Select Prometheus data source as "Prometheus"
  10. 11.
    Click the Import button.
Grafana dashboard ID 11074 is an excellent overall systems health visualizer.
Grafana dashboard
Congratulations. Prometheus and Grafana are working.