監(jiān)控
influxDB:(時序數(shù)據(jù)庫),常用的一種使用場景:監(jiān)控數(shù)據(jù)統(tǒng)計驻啤。
prometheus:存儲的是時序數(shù)據(jù),即按相同時序(相同名稱和標簽)测僵,以時間維度存儲連續(xù)的數(shù)據(jù)的集合街佑。
時序(time series)是由名字(Metric)以及一組key/value標簽定義的,具有相同的名字以及標簽屬于相同時序捍靠。
cadvisor:可以對節(jié)點機器上的資源及容器進行實時監(jiān)控和性能數(shù)據(jù)采集沐旨,包括CPU使用情況、內(nèi)存使用情況榨婆、網(wǎng)絡吞吐量及文件系統(tǒng)使用情況磁携。
grafana:是一個跨平臺的開源的度量分析和可視化工具,可以通過將采集的數(shù)據(jù)查詢?nèi)缓罂梢暬恼故玖挤纾⒓皶r通知谊迄。
刪除原有容器
docker rm -fv influxsrv
docker rm -fv prometheus
docker rm -fv cadvisor
docker rm -fv grafana
修改目錄權(quán)限
chmod 777 ./prometheus/data
chmod 777 ./grafana/data
啟動安裝
version: '3'
services:
influxsrv:
network_mode: bridge
image: tutum/influxdb:0.13
ports:
- 8083:8083
- 8086:8086
container_name: influxsrv
restart: on-failure
volumes:
- ./influxdb/data:/data
logging:
driver: 'json-file'
options:
max-size: '30m'
max-file: '1'
cadvisor:
network_mode: bridge
image: google/cadvisor:v0.33.0
ports:
- 8080:8080
container_name: cadvisor
restart: on-failure
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
environment:
- storage_driver:influxdb
- storage_driver_db:cadvisor
- storage_driver_host:'influxsrv:8086'
logging:
driver: 'json-file'
options:
max-size: '30m'
max-file: '1'
depends_on:
- influxsrv
links:
- influxsrv:influxsrv
prometheus:
network_mode: bridge
image: prom/prometheus:v2.20.1
ports:
- 9090:9090
container_name: prometheus
restart: on-failure
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/data:/prometheus
logging:
driver: 'json-file'
options:
max-size: '30m'
max-file: '1'
depends_on:
- cadvisor
grafana:
network_mode: bridge
image: grafana/grafana:7.1.5
ports:
- 3000:3000
container_name: grafana
restart: on-failure
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- ./grafana/data:/var/lib/grafana
environment:
- INFLUXDB_HOST:localhost
- INFLUXDB_PORT:8086
- INFLUXDB_NAME:cadvisor
- INFLUXDB_USER:root
- INFLUXDB_PASS:root
logging:
driver: 'json-file'
options:
max-size: '30m'
max-file: '1'
depends_on:
- influxsrv
- cadvisor
links:
- influxsrv:influxsrv
docker-compose up -d
檢查服務
influxDB:http://10.2.8.200:8083/
cadvisor:http://10.2.8.200:8080/containers/
prometheus:http://10.2.8.200:9090/targets
grafana:http://10.2.8.200:3000/
配置服務
Grafana進行新增數(shù)據(jù)源,配置prometheus數(shù)據(jù)連接和influxsrv數(shù)據(jù)連接
prometheus路徑:http://10.2.8.200:9090
influxsrv路徑:http://10.2.8.200:8086/
常見模板
Grafana模板路徑:https://grafana.com/grafana/dashboards
Linux監(jiān)控模板:9276(Linux模板需要調(diào)整變量nic,調(diào)整為Linux的實際網(wǎng)卡);
Docker監(jiān)控模板:193;
Mysql監(jiān)控模板:7362烟央;
Redis監(jiān)控模板:763统诺;
SpringBoot監(jiān)控模板:4701;
MongoDB監(jiān)控模板:2583疑俭;
RabbitMQ監(jiān)控模板:2121粮呢;
JVM監(jiān)控模板:4701;