Skip to content

Instantly share code, notes, and snippets.

@InclinedScorpio
Last active October 24, 2021 19:56
Show Gist options
  • Save InclinedScorpio/77c70e4c3049a22ed733770bd2b34658 to your computer and use it in GitHub Desktop.
Save InclinedScorpio/77c70e4c3049a22ed733770bd2b34658 to your computer and use it in GitHub Desktop.
Docker | Prometheus | Grafana | Node Exporter Integration

We will be using Docker to run the applications. Let's start!

Node Exporter

Setting up Node Exporter

  1. Run the following docker command:
     docker run -d \
     --net="host" \
     --pid="host" \
     -v "/:/host:ro,rslave" \
    quay.io/prometheus/node-exporter:latest \
     --path.rootfs=/host
    
    
  2. Node Exporter is started 🤠

Prometheus

  • Prometheus will collect the logs from the system.

Setting up Prometheus

  1. We will need a configuration file with 2 IP: prometheus & Node exporter.
  2. Create the file, let's name it prometheus.yaml:
global:
scrape_interval:     15s # By default, scrape targets every 15 seconds.

# Attach these extra labels to all timeseries collected by this Prometheus instance.
external_labels:
  monitor: 'my-nodes'

scrape_configs:
- job_name: 'prometheus'

  # Override the global default and scrape targets from this job every 5 seconds.
  scrape_interval: 5s

  static_configs:
    - targets: ['localhost:9090'] # IP Address of Prometheus running

- job_name: 'node-exporter'

  # Override the global default and scrape targets from this job every 5 seconds.
  scrape_interval: 5s

  static_configs:
    - targets: ['localhost:9100'] # IP Address of Node Exporter

NOTE: localhost won't work above, provide IP & verify from prometheus > tagets

  1. Run below CMD to run prometheus: docker run -d --name prometheus -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

Grafana

  • Analysing logs through prometheus is difficult task, Grafana to the rescue!
  • Grafana will provide a UI for better log analysis

Grafana Setup

  • Run the docker command to spin up Grafana docker run -d -p 3000:3000 --name grafana grafana/grafana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment