In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this article, the editor introduces in detail "how to use Grafana to monitor Docker in Ubuntu". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use Grafana to monitor Docker in Ubuntu" can help you solve your doubts.
Grafana is the Graphite and InfluxDB dashboard and graphical editor. Grafana is an open source, full-featured measurement dashboard and graphical editor that supports Graphite,InfluxDB and OpenTSDB.
Grafana is installed on the server on which Docker is installed.
We can build our Grafana in Docker. There is an official Grafana Docker image. Run the following command to build the Grafana container.
Root@ubuntu:~# docker run-I-p 3000 grafana/grafanaUnable to find image 'grafana/grafana:latest' locallylatest: Pulling from grafana/grafana5c90d4a2d1a8: Pull completeb1a9a0b6158e: Pull completeacb23b0d58de: Pull completeDigest: sha256:34ca2f9c7986cb2d115eea373083f7150a2b9b753210546d14477e2276074ae1Status: Downloaded newer image for grafana/grafana:latestt=2016-07-27T15:20:19+0000 lvl=info msg= "Starting Grafana" logger=main version=3.1.0 commit=v3.1.0 compiled=2016-07-12T06:42:28+0000t=2016-07-27T15:20:19+0000 lvl=info msg= "Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults. Init=2016-07-27T15:20:19+0000 lvl=info msg= "Config loaded from" logger=settings file=/etc/grafana/grafana.init=2016-07-27T15:20:19+0000 lvl=info msg= "Config overriden from command line" logger=settings arg= "default.paths.data=/var/lib/grafana" tangles 2016-07-27T15:20:19+0000 lvl=info msg= "Config overriden from command line" logger=settings arg= "default.paths.logs=/var/log/grafana" tweets 2016-07-27T15:20:19+0000 lvl=info msg= "Config overriden from command line" logger=settings arg= "default.paths.plugins=/var/ Lib/grafana/plugins "tweets 2016-07-27T15:20:19+0000 lvl=info msg=" Path Home "logger=settings path=/usr/share/grafanat=2016-07-27T15:20:19+0000 lvl=info msg=" Path Data "logger=settings path=/var/lib/grafanat=2016-07-27T15:20:19+0000 lvl=info msg=" Path Logs "logger=settings path=/var/log/grafanat=2016-07-27T15:20:19+0000 lvl=info msg=" Path Plugins logger=settings path=/var/lib/grafana/pluginst=2016-07-27T15:20:19+0000 lvl=info msg= "Initializing DB" logger=sqlstore dbtype=sqlite3t=2016-07-27T15:20: 200000 lvl=info msg= "Executing migration" logger=migrator id= "create playlist table v2" tangles 2016-07-27T15:20:20+0000 lvl=info msg= "Executing migration" logger=migrator id= "create playlist item table v2" tours 2016-07-27T15:20:20+0000 lvl=info msg= "Executing migration" logger=migrator id= "drop preferences table v2" tweets 2016-07-27T15:20:20+0000 lvl=info msg= "Executing migration" logger=migrator id= "drop preferences table v3" tweets 2016-07-27T15:20:20+0000 lvl=info msg= "Executing migration" logger=migrator id= "create preferences table v3" tones 2016-07-27T15:20:20+0000 lvl=info msg= " Created default admin user: [admin] "tweets 2016-07-27T15:20:20+0000 lvl=info msg=" Starting plugin search "logger=pluginst=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 status of the Grafana container "docker ps-a" or access the http://Docker IP:3000 through this URL by running this command.
All Grafana configuration settings are defined with environment variables, which is useful when using container technology. The path to the Grafana profile is / etc/grafana/grafana.ini.
Understand configuration items
Grafana can specify several configuration options in its ini configuration file, or it can be specified using the previously mentioned environment variables.
Profile location
Usually the configuration file path:
Default profile path: $WORKING_DIR/conf/defaults.ini Custom profile path: $WORKING_DIR/conf/custom.ini
PS: when you install Grafana using deb, rpm, or docker images, your configuration file is in / etc/grafana/grafana.ini.
Understand configuration variables
Now let's look at some variables in the configuration file:
Instance_name: this is the name of the Grafana server instance. The default value is obtained from ${HOSTNAME}, whose value is the environment variable HOSTNAME, and if this variable is empty or does not exist, Grafana will try to use the system call to get the machine name.
[paths] >: these paths are usually in init.d
Script
Or through the command line in the systemd service file.
Data: this is the path where Grafana stores sqlite3 databases (if used), file-based sessions (if used), and other data. Logs: this is the path where Grafana stores the logs.
[server]
Http_addr: the IP address that the application listens to. If it is empty, it listens on all interfaces. Http_port: the port on which the application listens. The default is 3000. You can redirect your port 80 to port 3000 using the following command: $iptables-t nat-A PREROUTING-p tcp-dport 80-j REDIRECT-to-port 3000root_url: this URL is used to access Grafana from the browser. Cert_file: the path to the certificate file if the protocol is HTTPS. Cert_key: the path to the certificate key file (if the protocol is HTTPS).
[database]: Grafana uses a database to store users and dashboards and other information, and the default configuration is to use SQLite3 embedded in the main binary of Grafana.
Type: you can choose MySQL, Postgres and SQLite3 according to your needs. Path: this is the path that the database stores when you select a SQLite3 database only. Host: only applicable to MySQL or Postgres. It includes the IP address or hostname and the port. For example, Grafana and MySQL are running on the same host, such as: host = 127.0.0.1 host 3306. The name of the name:Grafana database and set it to Grafana or some other name. User: database user (not applicable to SQLite3). Password: database user password (not applicable to SQLite3). Ssl_mode: for Postgres, use disable,require, or verify-full equivalents. For MySQL, use true,false, or skip-verify. Ca_cert_path: (MySQL only) the path to the CA certificate file, which on most Linux systems can be found at / etc/ssl/certs. Client_key_path: (MySQL only) the path to the client key, used only when the server needs client-side authentication. Client_cert_path: (MySQL only) the path to the client certificate, which is used only when the server needs client authentication. Server_cert_name: (MySQL only) the common name field of the certificate used by the MySQL server. If ssl_mode is set to skip-verify, it may not be set.
[security]
Admin_user: this is the user name of the Grafana default administrator user, which is set to admin by default. Admin_password: this is the default administrator user password for Grafana, which is set the first time it is run, and defaults to admin. Login_remember_days: keep logging in / remember the number of days I last. Secret_key: used to keep login / remember my cookies signature. Set up important components of monitoring
We can use the following components to create our Docker monitoring system.
CAdvisor: it's called Container Advisor. It provides users with an interpretation of resource utilization and performance characteristics. It collects, aggregates, processes, and exports information about running containers. You can learn more through this document. InfluxDB: this is a database that contains time series, measurements, and analysis. We use this data source to set up our monitoring. CAdvisor only displays real-time information and does not save this metric information. Influx Db helps to save the monitoring data provided by cAdvisor to display data that is not in a certain period of time. Grafana Dashboard: it helps us integrate all the information visually. This powerful dashboard allows us to query against InfluxDB data stores and put them in a well-laid out chart. Installation of Docker monitoring
We need to install each of the following components in our Docker system step by step:
Install InfluxDB
We can use this command to pull the InfluxDB image and deploy the influxDB container.
Root@ubuntu:~# docker run-d-p 8083 expose 8099-e PRE_CREATE_DB=cadvisor-- name influxsrv tutum/influxdb:0.8.8Unable to find image 'tutum/influxdb:0.8.8' locally0.8.8: Pulling from tutum/influxdba3ed95caeb02: Already exists23efb549476f: Already existsaa2f8df21433: Already existsef072d3c9b41: Already existsa248b0871c3c: Already exists749db6d368d0: Already exists7d7c7d923e63: Pull completee47cc7808961: Pull complete1743b6eeb23f: Pull completeDigest: sha256:8494b31289b4dbc1d5b444e344ab1dda3e18b07f80517c3f9aae7d18133c0c42Status: Downloaded newer image for tutum/influxdb:0.8.8d3b6f7789e0d1d01fa4e0aacdb636c221421107d1df96808ecbe8e241ceb1823-p 8083: user interface Log in with username-admin, pass-admin-p 8086 interaction with other application: name influxsrv: container have name influxsrv, use to cAdvisor link it.
You can test whether InfluxDB is installed. By visiting this URL http://, your IP address is 8083, and your username and password are "root".
Skills of Grafana Monitoring Docker on Ubuntu skills of Grafana Monitoring Docker on Ubuntu
We can create the database we need on this interface.
Skills of Grafana Monitoring Docker on Ubuntu skills of Grafana Monitoring Docker on Ubuntu install cAdvisor
Our next step is to install the 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:8086Unable to find image 'google/cadvisor:latest' locallylatest: Pulling from google/cadvisor09d0220f4043: Pull complete151807d34af9: Pull complete14cd28dce332: Pull completeDigest: sha256:8364c7ab7f56a087b757a304f9376c3527c8c60c848f82b66dd728980222bd2fStatus: Downloaded newer image for google/cadvisor:latest3bfdf7fdc83872485acb06666a686719983a1172ac49895cd2a260deb1cdde29root@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
You can test whether the installation of cAdvisor is working by visiting this address. Http:// your IP address: 8080. This will provide statistics for your Docker hosts and containers.
Skills of Grafana Monitoring Docker on Ubuntu skills of Grafana Monitoring Docker on Ubuntu install Grafana Control Panel
Finally, we need to install the Grafana dashboard and connect to the InfluxDB, which you can set up by executing the following command.
Root@ubuntu:~# docker run-d-p 3000 INFLUXDB_NAME=cadvisor 3000-e INFLUXDB_HOST=localhost-e INFLUXDB_NAME=cadvisor-e INFLUXDB_USER=root-e INFLUXDB_PASS=root-- link influxsrv:influxsrv-- name grafana grafana/grafanaf3b7598529202b110e4e6b998dca6b6e60e8608d75dcfe0d2b09ae408f43684a
Now we can log in to Grafana to configure the data source. Visit http:// your IP address: 3000 or http:// your IP address (if you have done port mapping earlier):
User name-admin password-admin
Once we have installed Grafana, we can connect to InfluxDB. Log in to the dashboard and click the Grafana icon (the fireball) in the upper left corner of the panel. Click the data source to configure.
Now you can add a new drawing to our default data source, InfluxDB.
We can adjust our graphics by editing and adjusting our queries on the survey page.
After reading this, the article "how to use Grafana to monitor Docker in Ubuntu" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.