We will be using Docker to run the applications. Let's start!
- Node Exporter will help in providing the OS stats to the prometheus.
- Access the doc here: https://github.com/prometheus/node_exporter
- 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
- Node Exporter is started 🤠
- Prometheus will collect the logs from the system.
- We will need a configuration file with 2 IP: prometheus & Node exporter.
- 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
- Run below CMD to run prometheus:
docker run -d --name prometheus -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
- Analysing logs through prometheus is difficult task, Grafana to the rescue!
- Grafana will provide a UI for better log analysis
- Run the docker command to spin up Grafana
docker run -d -p 3000:3000 --name grafana grafana/grafana