Docker运行Prometheus和Grafana
(金庆的专栏 2018.4)
Prometheus官网的运行示例是直接执行。
可以参照 https://www.katacoda.com/ 的教程用Docker运行Prometheus和Grafana.
搜索 Grafana 的教程,运行步骤如下:
1. 编写 prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090', 'localhost:9100']
labels:
group: 'prometheus'
localhost 好像不行,换成 127.0.0.1
2. 运行 prometheus
docker run -d --net=host \
-v /root/prometheus.yml:/etc/prometheus/prometheus.yml \
--name prometheus-server \
prom/prometheus
3. 运行 Node Exporter
docker run -d -p 9100:9100 \
-v "/proc:/host/proc" \
-v "/sys:/host/sys" \
-v "/:/rootfs" \
--net="host" \
--name=prometheus \
quay.io/prometheus/node-exporter:v0.13.0 \
-collector.procfs /host/proc \
-collector.sysfs /host/sys \
-collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
4. 运行 Grafana
docker run -d --name=grafana -p 3000:3000 grafana/grafana
缺省用户: admin/admin
5. 添加数据源,并导入仪表盘
Add Data Sources ->
Name: Prometheus
Type: Prometheus
URL: http://1.2.3.4:9090
Access: proxy
Save & Test...
Create Import ->
Grafana.com Dashboard: 22