mkdir -pv /apps/exporter/node-exporter
vim /apps/exporter/node-exporter/docker-compose.yaml
version: "3"
services:
node-exporter:
image: prom/node-exporter:v1.3.1
container_name: prometheus-node-exporter
hostname: node-exporter
restart: always
ports:
- 9100:9100
networks:
default:
external:
name: prometheus
docker network list
若不存在,则创建:
docker network create prometheus --subnet 10.21.22.0/24
cd /apps/exporter/node-exporter
docker-compose up -d
cd /apps/exporter/node-exporter
docker-compose ps
docker-compose logs -f
- job_name: 'demo-node'
static_configs:
- targets: ['127.0.0.1:9100']
cd /apps/prometheus
docker-compose restart
登录 Grafana,导入对应的看板即可。
看板获取地址:https://grafana.com/grafana/dashboards/?dataSource=prometheus&collector=nodeexporter
注意: 看板导入后需要修改数据源的ID
数据源详情
页面,浏览器 URL 的最后一段字符为该数据源的 ID。 如 URL 为 grafana/datasources/edit/6lbJpCb4z
时, 6lbJpCb4z
即为当前数据源的 IDdatasource
中的 uid