Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A weekend project turned into a comprehensive guide. Dive into monitoring your Raspberry Pi cluster with Grafana, Prometheus, Node Exporter, and cAdvisor.

NotificationsYou must be signed in to change notification settings

domengabrovsek/raspberry-pi-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Over the weekend, I dabbled in setting up a monitoring solution for Raspberry Pis, and I thought it'd be great to share what I've learned and accomplished. If you're interested in leveraging Grafana, Prometheus, Node Exporter, and cAdvisor for your own monitoring needs, you've come to the right place!

Table of Contents

Overview of Services

  1. Grafana: A powerful open-source platform for monitoring and observability. Grafana allows you to visualize, alert on, and understand your metrics no matter where they are stored.

  2. Prometheus: An open-source systems monitoring and alerting toolkit originally built at SoundCloud. It scraps metrics from configured locations at given intervals, evaluates alert conditions, and can trigger alerts.

  3. Node Exporter: A Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors. We'll be using Node Exporter to expose system metrics from each Raspberry Pi.

  4. cAdvisor: Stands for Container Advisor; it provides container users an understanding of the resource usage and performance characteristics of their running containers. It is a Google project that is now open source.

System Architecture

Here's a visual representation of how the services interact:

graph TD;        A[Raspberry Pi 4] -->|Runs| B[Prometheus]    A -->|Runs| C[Grafana]    A -->|Runs| J[Node Exporter]    A -->|Runs| K[cAdvisor]    D[Raspberry Pi 3_1] -->|Runs| E[Node Exporter]    F[Raspberry Pi 3_2] -->|Runs| G[Node Exporter]    E -->|System Metrics to| B    G -->|System Metrics to| B    J -->|System Metrics to| B    D -->|Runs| H[cAdvisor]    F -->|Runs| I[cAdvisor]    H -->|Container Metrics to| B    I -->|Container Metrics to| B    K -->|Container Metrics to| B    B -->|Data Source| C
Loading

Install Docker

  1. Update Package List and Install Prerequisites: Basic initial setup.

    sudo apt-get updatesudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
  2. Add Docker's GPG Key: For package verification.

    curl -fsSL https://download.docker.com/linux/debian/gpg| sudo apt-key add -
  3. Add Docker Repository: To fetch Docker packages.

    sudo add-apt-repository"deb [arch=armhf] https://download.docker.com/linux/debian$(lsb_release -cs) stable"
  4. Install Docker: Finally, install Docker.

    sudo apt-get updatesudo apt-get install -y docker-ce
  5. Enable and Start Docker: To run Docker on boot.

    sudo systemctlenable dockersudo systemctl start docker

To run Docker commands withoutsudo, add your user to thedocker group with:

sudo usermod -aG docker$USERnewgrp docker

Setup Docker-Compose

  1. Download Docker Compose: From the official GitHub repository.

    sudo curl -L"https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. Make Executable:

    sudo chmod +x /usr/local/bin/docker-compose

Verify the installation with:

docker-compose --version

Running Grafana in Docker

  1. Create a Docker-Compose File: Save the following YAML content in a file nameddocker-compose.yml.

    version:'3'services:grafana:image:grafana/grafana:8.4.3-armv7ports:      -"3000:3000"environment:      -GF_SECURITY_ADMIN_USER=admin      -GF_SECURITY_ADMIN_PASSWORD=adminvolumes:      -grafana-storage:/var/lib/grafana
  2. Run Grafana: Execute the following command to get Grafana up and running.

    docker-compose up -d

Node Exporter Setup

  1. Download and Extract Node Exporter: Compatible with ARM.

    wget https://github.com/prometheus/node_exporter/releases/download/v1.3.0/node_exporter-1.3.0.linux-armv7.tar.gztar xvfz node_exporter-1.3.0.linux-armv7.tar.gz
  2. Move Binary to a Directory in Your PATH: For easy access.

    sudo mv node_exporter-1.3.0.linux-armv7/node_exporter /usr/local/bin
  3. Run Node Exporter: Run it in the background.

    nohup node_exporter&

Prometheus Setup

  1. Add Prometheus to Docker-Compose: Add the following service to your existingdocker-compose.yml.

    prometheus:image:prom/prometheus:latestvolumes:    -./prometheus.yml:/etc/prometheus/prometheus.ymlports:    -"9090:9090"
  2. Create a Configuration File (prometheus.yml): Place it in the same directory as yourdocker-compose.yml.

    global:scrape_interval:15sscrape_configs:  -job_name:'node_exporter'static_configs:      -targets:['<RPI_1_IP>:9100', '<RPI_2_IP>:9100', '<RPI_3_IP>:9100']relabel_configs:# Your relabel configs

cAdvisor Setup

  1. Add cAdvisor to Docker-Compose: Insert the snippet into your existingdocker-compose.yml.

    cadvisor:image:gcr.io/cadvisor/cadvisor-arm:v0.47.2container_name:cadvisorvolumes:    -/:/rootfs:ro    -/var/run:/var/run:rw    -/sys:/sys:ro    -/var/lib/docker/:/var/lib/docker:roports:    -"8080:8080"
  2. Run Docker Compose: To apply changes and start cAdvisor.

    docker-compose up -d

Final Docker-Compose File

Here's the completedocker-compose.yml for your reference:

version:'3'services:grafana:image:grafana/grafana:8.4.3-armv7ports:      -"3000:3000"environment:      -GF_SECURITY_ADMIN_USER=admin      -GF_SECURITY_ADMIN_PASSWORD=adminvolumes:      -grafana-storage:/var/lib/grafanaprometheus:image:prom/prometheus:latestvolumes:      -./prometheus.yml:/etc/prometheus/prometheus.ymlports:      -"9090:9090"cadvisor:image:gcr.io/cadvisor/cadvisor-arm:v0.47.2container_name:cadvisorvolumes:      -/:/rootfs:ro      -/var/run:/var/run:rw      -/sys:/sys:ro      -/var/lib/docker/:/var/lib/docker:roports:      -"8080:8080"volumes:grafana-storage:

Debugging Notes

If you run into issues or want to check the status of your services, these URLs will be your best friends:

  • Prometheus Targets:http://<prometheus-ip>:9090/targets?search
  • Node Exporter Metrics:http://<rpi-ip>:9100/metrics
  • cAdvisor Container Metrics:http://<rpi-ip>:8080/containers

About

A weekend project turned into a comprehensive guide. Dive into monitoring your Raspberry Pi cluster with Grafana, Prometheus, Node Exporter, and cAdvisor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp