docker | 从零开始搭建prometheus+Grafan

2020-06-30  本文已影响0人  炒面Z

Grafana成品效果图

image.png

定义

1.docker拉取镜像

docker pull prom/prometheus
docker pull grafana/grafana
docker pull prom/node-exporter

2.docker模式运行他们

docker run -d \
--name node-exporter \
  --net="host" \
   --pid="host" \
   -v "/:/host:ro,rslave" \
   prom/node-exporter \
   --path.rootfs /host
docker run -d \
--name prometheus \
-p 9090:9090 \
-v /opt/prometheus/:/etc/prometheus/ \
prom/prometheus
docker run -d -p 3000:3000 --name=grafana -v /etc/localtime:/etc/localtime grafana/grafana

如果端口冲突,使用 netstate 命令查看端口被哪个进程占用,改端口或者使用kill -9 PID 杀掉占用进程

3. 配置 prometheus.yml

文件位置: /opt/prometheus/prometheus.yml

global:
  scrape_interval:     10s
  evaluation_interval: 10s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus

  - job_name: linux
    static_configs:
      - targets: ['localhost:9100','其他电脑IP:9100']

4.grafana 配置仪表盘

grafana dashboards 仪表盘模板市场: https://grafana.com/grafana/dashboards

参考: https://yasongxu.gitbook.io/container-monitor/

上一篇 下一篇

猜你喜欢

热点阅读