prometheus
从零开始搭建Prometheus自动监控报警系统 - 雪山飞猪 - 博客园 (cnblogs.com)
--挂在目录设置,以及配置文件
mkdir -p /home/chenqionghe/promethues
mkdir -p /home/chenqionghe/promethues/server
mkdir -p /home/chenqionghe/promethues/client
touch /home/chenqionghe/promethues/server/rules.yml
chmod 777 /home/chenqionghe/promethues/server/rules.yml
mkdir -p /home/chenqionghe/test/prometheus
touch -p /home/chenqionghe/test/prometheus/prometheus.yml
chmod 777 /home/chenqionghe/test/prometheus/prometheus.yml
prometheus.yml对应的内容
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
--启动容器
docker rm -f prometheus
docker run --name=prometheus -d \
-p 9090:9090 \
-v /home/chenqionghe/promethues/server/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /home/chenqionghe/promethues/server/rules.yml:/etc/prometheus/rules.yml \
prom/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--web.enable-lifecycle
热加载配置文件
调用指令是curl -X POST http://localhost:9090/-/reload
我们配置了9090端口,默认prometheus会抓取自己的/metrics接口
访问http://10.211.55.25:9090/metrics
查看监控节点
http://192.168.226.131:9091/targets
访问http://10.211.55.25:9090
配置influxdb作为存储
remote_write:
- url: "http://127.0.0.1:8086/api/v1/prom/write?db=prometheusdb"
basic_auth:
username: admin
password: admin
remote_read:
- url: "http://127.0.0.1:8086/api/v1/prom/read?db=prometheusdb"
basic_auth:
username: admin
password: admin
--安装pushgateway
mkdir -p /home/chenqionghe/promethues/pushgateway
cd !$
docker run -d -p 9092:9091 --name pushgateway prom/pushgateway
访问 http://192.168.226.131:9092/
配置监控节点
- job_name: pushgateway
scrape_interval: 30s
honor_labels: true
static_configs:
- targets: ['192.168.1.100:9091']
labels:
instance: pushgateway
安装Grafana
docker run -d -p 3000:3000 --name grafana grafana/grafana
--监控物理机程序客户端node-exporter
docker run -d \
--name=node-exporter \
-p 9100:9100 \
prom/node-exporter
--修改配置文件, 加入监控节点
--安装docker监听
docker run -d \
-v=/:/rootfs:ro \
-v=/var/run:/var/run:ro \
-v=/sys:/sys:ro \
-v=/var/lib/docker/:/var/lib/docker:ro \
-v=/dev/disk/:/dev/disk:ro \
-p=8081:8080 \
--name=cadvisor \
--restart=always \
google/cadvisor
--配置监控文件
- job_name: 'docker'
static_configs:
- targets: ['192.168.31.138:8080']
labels:
instance: docker测试
--现成图表下载
https://grafana.com/grafana/dashboards