修正代码块样式、补充链接

This commit is contained in:
Felix Yan 2016-08-09 15:08:12 +08:00
parent d658889532
commit ba719f40e3
No known key found for this signature in database
GPG Key ID: 786C63F330D7CB92

View File

@ -17,6 +17,7 @@ In this article, I'll explain on how to install Grafana on a docker container in
We can build our Grafana in a docker container. There is an official docker image available for building Grafana. Please run this command to build a Grafana container.
```
root@ubuntu:~# docker run -i -p 3000:3000 grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
@ -46,6 +47,7 @@ We can build our Grafana in a docker container. There is an official docker imag
t=2016-07-27T15:20:20+0000 lvl=info msg="Created default admin user: [admin]"
t=2016-07-27T15:20:20+0000 lvl=info msg="Starting plugin search" logger=plugins
t=2016-07-27T15:20:20+0000 lvl=info msg="Server Listening" logger=server address=0.0.0.0:3000 protocol=http subUrl=
```
We can confirm the working of the Grafana container by running this command `docker ps -a` or by accessing it by URL `http://Docker IP:3000`
@ -84,7 +86,9 @@ Both these paths are usually specified via command line in the init.d scripts or
`http_port` : The port to which the application is bind to, defaults is 3000. You can redirect your 80 port to 3000 using the below command.
```
$iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000
```
`root_url` : This is the URL used to access Grafana from a web browser.
@ -157,6 +161,7 @@ We need to install each of these components one by one in our docker system.
We can use this command to pull InfluxDB image and setuup a influxDB container.
```
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
@ -177,6 +182,7 @@ We can use this command to pull InfluxDB image and setuup a influxDB container.
-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.
```
You can test your InfluxDB installation by calling this URL >>http://45.79.148.234:8083 and login with user/password as "root".
@ -190,6 +196,7 @@ We can create our required databases from this tab.
Our next step is to install cAdvisor container and link it to the InfluxDB container. You can use this command to create it.
```
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
@ -207,6 +214,7 @@ Our next step is to install cAdvisor container and link it to the InfluxDB cont
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
```
You can test our cAdvisor installation by calling this URL >>http://45.79.148.234:8080. This will provide you the statistics of your Docker host and containers.
@ -216,8 +224,10 @@ You can test our cAdvisor installation by calling this URL >>http://45.79.148.23
Finally, we need to install the Grafana Dashboard and link to the InfluxDB. You can run this command to setup that.
```
root@ubuntu:~# docker run -d -p 3000:3000 -e INFLUXDB_HOST=localhost -e INFLUXDB_PORT=8086 -e INFLUXDB_NAME=cadvisor -e INFLUXDB_USER=root -e INFLUXDB_PASS=root --link influxsrv:influxsrv --name grafana grafana/grafana
f3b7598529202b110e4e6b998dca6b6e60e8608d75dcfe0d2b09ae408f43684a
```
Now we can login to Grafana and configure the Data Sources. Navigate to http://45.79.148.234:3000 or just http://45.79.148.234:
@ -251,3 +261,4 @@ via: http://linoxide.com/linux-how-to/monitor-docker-containers-grafana-ubuntu/
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/saheethas/
[1]:https://github.com/vegasbrianc/docker-monitoring