InfluxDB+cAdvisor+Grafana配置Docker监控
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了InfluxDB+cAdvisor+Grafana配置Docker监控相关的知识,希望对你有一定的参考价值。
一、配置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监控的主要内容,如果未能解决你的问题,请参考以下文章
InfluxDB+cAdvisor+Grafana配置Docker监控
Docker监控快速部署,cAdvisor+InfluxDB+Grafana
docker:十分钟构建容器监控系统cAdvisor+InfluxDB+Grafana
在Marathon 上部署 cAdvisor + InfluxDB + Grafana Docker监控