docker安装prometheus

目录

    • 1. 拉取镜像包
    • 2. 启动node-exporter
        • 启动
        • 访问
    • 3. 启动prometheus
        • 新建目录,生成prometheus.yaml
        • 启动prometheus
        • 访问
    • 4. 启动grafana
        • 新建目录
        • 启动
        • 访问

1. 拉取镜像包

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

2. 启动node-exporter

启动

docker run -d -p 9100:9100 \
  -v "/proc:/host/proc:ro" \
  -v "/sys:/host/sys:ro" \
  -v "/:/rootfs:ro" \
  --net="host" \
  prom/node-exporter

访问

< http://192.168.1.109:9100/metrics>
docker安装prometheus_第1张图片

3. 启动prometheus

新建目录,生成prometheus.yaml

mkdir /opt/prometheus
cd /opt/prometheus/
vim prometheus.yml

内容

global:
  scrape_interval:     60s
  evaluation_interval: 60s
 
scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
 
  - job_name: linux
    static_configs:
      - targets: ['192.168.1.109:9100']
        labels:
          instance: localhost

修改其中的192.168.1.109为本机地址

启动prometheus

docker run  -d \
  -p 9090:9090 \
  -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  \
  prom/prometheus

访问

http://192.168.1.109:9090/graph
docker安装prometheus_第2张图片

4. 启动grafana

新建目录

mkdir /opt/grafana-storage
chmod 777 -R /opt/grafana-storage

启动

docker run -d \
  -p 3000:3000 \
  --name=grafana \
  -v /opt/grafana-storage:/var/lib/grafana \
  grafana/grafana

访问

http://192.168.1.109:3000
默认账号admin 密码admin
docker安装prometheus_第3张图片数据源选择prometheus
docker安装prometheus_第4张图片

结果docker安装prometheus_第5张图片

参考链接
[1] https://www.cnblogs.com/xiao987334176/p/9930517.html

你可能感兴趣的:(docker,prometheus)