在Ubuntu上使用Grafana监控Docker的方法

2020-06-17 06:37:41易采站长站整理


root@ubuntu:~# docker run -d -p 8083:8083 -p 8086:8086 --expose

8090 --expose 8099 -e PRE_CREATE_DB=cadvisor --name influxsrv tutum/influxdb:0.8.8

Unable to find image 'tutum/influxdb:0.8.8' locally

0.8.8: Pulling from tutum/influxdb

a3ed95caeb02: Already exists

23efb549476f: Already exists

aa2f8df21433: Already exists

ef072d3c9b41: Already exists

c9f371853f28: Already exists

a248b0871c3c: Already exists

749db6d368d0: Already exists

7d7c7d923e63: Pull complete

e47cc7808961: Pull complete

1743b6eeb23f: Pull complete

Digest: sha256:8494b31289b4dbc1d5b444e344ab1dda3e18b07f80517c3f9aae7d18133c0c42

Status: Downloaded newer image for tutum/influxdb:0.8.8

d3b6f7789e0d1d01fa4e0aacdb636c221421107d1df96808ecbe8e241ceb1823

-p 8083:8083 : user interface, log in with username-admin, pass-admin

-p 8086:8086 : interaction with other application

--name influxsrv : container have name influxsrv, use to cAdvisor link it.

你可以测试 InfluxDB 是否安装好,通过访问这个 URL http://你的 IP 地址:8083,用户名和密码都是 ”root“。

InfluxDB Administration 2016-08-01 14-10-08

我们可以在这个界面上创建我们所需的数据库。

createDB influx

安装 cAdvisor

我们的下一个步骤是安装 cAdvisor 容器,并将其链接到 InfluxDB 容器。你可以使用此命令来创建它。


root@ubuntu:~# docker run --volume=/:/rootfs:ro --volume

=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=

/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080

--detach=true --link influxsrv:influxsrv --name=cadvisor

google/cadvisor:latest -storage_driver_db=cadvisor

-storage_driver_host=influxsrv:8086

Unable to find image 'google/cadvisor:latest' locally

latest: Pulling from google/cadvisor

09d0220f4043: Pull complete

151807d34af9: Pull complete

14cd28dce332: Pull complete

Digest: sha256:8364c7ab7f56a087b757a304f9376c3527c8c60c848f82b66dd728980222bd2f

Status: Downloaded newer image for google/cadvisor:latest

3bfdf7fdc83872485acb06666a686719983a1172ac49895cd2a260deb1cdde29

root@ubuntu:~#

--publish=8080:8080 : user interface

--link=influxsrv:influxsrv: link to container influxsrv

-storage_driver=influxdb: set the storage driver as InfluxDB

Specify what InfluxDB instance to push data to:

-storage_driver_host=influxsrv:8086: The ip:port of the

database. Default is ‘localhost:8086'

-storage_driver_db=cadvisor: database name. Uses db

‘cadvisor' by default

你可以通过访问这个地址来测试安装 cAdvisor 是否正常 http://你的 IP 地址:8080。 这将为你的 Docker 主机和容器提供统计信息。