技术

docker安装prometheus

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>

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

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

Prev Next
No Comments

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注