一、配置influxdb
docker run -d \
-p 8083:8083 \
-p 8086:8086 \
--expose 8090 \
--expose 8099 \
--name influxsrv \
tutum/influxdb
默认用户名:root, 默认密码:root
# 创建数据库
create database 'cadvisor';
# 创建用户
CREATE USER 'cadvisor' WITH PASSWORD 'cadvisor'
# 用户授权
grant all privileges on 'cadvisor' to 'cadvisor'
# 授予读写权限
grant WRITE on 'cadvisor' to 'cadvisor'
grant READ on 'cadvisor' to 'cadvisor'
二、cadvisor数据收集,在监控节点启动
# docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=9090:8080 --detach=true --name=cadvisor google/cadvisor:latest -storage_driver=influxdb -storage_driver_host=192.168.1.100:8086 -storage_driver_db=cadvisor -storage_driver_user=cadvisor -storage_driver_password=cadvisor
storage_driver=influxdb 指定存储驱动,使cadvisor将数据存储到数据库中,更多存储插件,请参考这里
-storage_driver_host=influxdb:8086 InfluxDB数据库的地址
-storage_driver_db=cadvisor 数据库名称
如果要指定用户名可以用-storage_driver_user参数,默认是root
如果要指定密码可以用-storage_driver_password参数,默认是root
报错:
W0130 03:47:13.734200 1 manager.go:313] Could not configure a source for OOM detection, disabling OOM events: open /dev/kmsg: no such file or directory
I0130 03:47:13.740891 1 manager.go:329] Starting recovery of all containers
I0130 03:47:14.131098 1 manager.go:334] Recovery completed
F0130 03:47:14.174599 1 cadvisor.go:156] Failed to start container manager: inotify_add_watch /sys/fs/cgroup/cpuacct,cpu: no such file or directory
解决办法:
# mount -o remount,rw /sys/fs/cgroup/
# ln -sf /sys/fs/cgroup/cpu,cpuacct /sys/fs/cgroup/cpuacct,cpu
二、prometheus配置
docker run -d -p 9090:9090 -v /nfs/prometheus-data/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
配置文件:
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['192.168.1.100:9090']
三、grafana展示
docker run -d -p 3000:3000 grafana/grafana
http://10.6.8.41:3000/login
用户名密码admin admin
InfluxDB+cAdvisor+Grafana配置Docker监控
原创
©著作权归作者所有:来自51CTO博客作者peaceweb的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:使用rvm安装ruby
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Docker容器监控,使用CAdvisor+InfluxDB+Granfana实现docker容器监控
通过docker stats命令可以很方便的看到当前宿主机上所有容器的CPU,内存以及网络流量等数据,一般情况是够用了,但是d
docker elasticsearch java 数据 数据源