This repository was archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
How to monitor the server with Prometheus and Grafana by Docker
Nguyễn Hữu Hưng edited this page Apr 16, 2021
·
1 revision
- Ubuntu
- Docker (Need to know) but you don't know, it's okay, just skip this tutorial =)
- Node exporter: https://github.com/prometheus/node_exporter
docker run -d \
--net="host" \
--pid="host" \
-v "/:/host:ro,rslave" \
quay.io/prometheus/node-exporter:latest \
--path.rootfs=/host
For Docker compose, similar flag changes are needed.
version: '3.8'
services:
node_exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
network_mode: host
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'
On some systems, the timex collector requires an additional Docker flag, --cap-add=SYS_TIME, in order to access the required syscalls.
Volumes & bind-mount
docker run \
-p 9090:9090 \
-v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
Or bind-mount the directory containing prometheus.ym
l onto /etc/prometheus
by running:
docker run \
-p 9090:9090 \
-v /path/to/config:/etc/prometheus \
prom/prometheus
protheus.yml
global:
scrape_interval: 5s
external_labels:
monitor: 'node'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['(ipLAN or PublicIP):9090'] ## IP Address of the localhost recommended
- job_name: 'node-exporter'
static_configs:
- targets: ['(ipLAN or PublicIP):9100'] ## IP Address of the localhost recommended
Docker (Don't execute it, if you don't understand)
docker run -d --name prometheus -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
docker run -d -p 3000:3000 grafana/grafana
Watch this video to continue: https://youtu.be/uCYfDtR9S9k?t=269
Powered by @ds112
@ds112, @onepiecehung