Grafana placement

Grafana ( https://grafana.com/grafana ) is a visual platform monitoring and analysis tool. The production environment of xxxx is monitored by configuring Grafana's Docker instance. This text combines the actual application of the xxxx project to introduce the basic configuration method of Grafana.

0. Install Docker CE and Docker Compose

Docker CE

To install Docker CE on Ubuntu, please refer to: https://store.docker.com/editions/community/docker-ce-server-ubuntu .

For instructions on installing Docker CE on other platforms, please check here .

Docker Compose

Steps to install Docker Compose on Linux:

sudo bash -c "curl -L https://github.com/docker/compose/releases/download/1.22.0-

rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose" 

sudo chmod +x /usr/local/bin/docker-compose

For more information, please refer to: https://github.com/docker/compose/releases

1. Install Docker image

docker pull kamon/grafana_graphite
After installation, it is best to check the list of mirrored columns:
  docker images

For more information, please refer to Docker Hub: https://hub.docker.com/r/kamon/grafana_graphite

2. Configure docker-compose

The content of the docker-compose.yml file is as follows:

version: '2'
services:
    grafana_graphite: 
        build: .
        image: kamon/grafana_graphite 
        container_name: kamon-grafana-dashboard 
        ports:
            - '8000:80'
            - '8001:81'
            - '8125:8125/udp' 
            - '8126:8126'
            - '2003:2003'

        environment:
            - GF_USERS_ALLOW_SIGN_UP=false
            - GF_USERS_ALLOW_ORG_CREATE=false
            - GF_USERS_AUTO_ASSIGN_ORG_ROLE=Read Only Editor 
            - GF_DATABASE_TYPE=mysql
            - GF_DATABASE_HOST=<host>:<port>
            - GF_DATABASE_NAME=<database_name>
            - GF_DATABASE_USER=<user>
            - GF_DATABASE_PASSWORD=<password>

Among them, the ports configuration instructions are as follows:

80:Grafana⽹⻚界面。 
81:Graphite⽹络端口。 
8125:StatsD端⼝。 
8126:StatsD管理端口。 
2003:Graphite数据端口。

The environment configuration instructions are as follows:

GF_USERS_ALLOW_SIGN_UP:设置为false时表示禁止⽤用户注册/创建用户账号,默认为false;但管理员用户仍然可以从Grafana管理界面创建用户
GF_USERS_ALLOW_ORG_CREATE:设置为false禁⽌用户创建新组织,默认为false。 GF_USERS_AUTO_ASSIGN_ORG_ROLE: 新⽤户将分配给主要组织的角色,默认为Viewer,其他有效选项为Admin和Editor。
GF_DATABASE_TYPE:数据库类型,⽆非就是mysql、postgres或者sqlites。
GF_DATABASE_HOST: 仅适⽤于mysql或postgres,包括ip或主机名和端口,例如,对于Grafana在同一台 主机上运行时MySQL: host = 127.0.0.1 : 3306
GF_DATABASE_NAME: Grafana数据库名称,下述中为是定义为grafana_test。 
GF_DATABASE_USER:数据库用户,不适用于sqlites3。
GF_DATABASE_PASSWORD: 数据库⽤户密码(不适⽤于sqlites),如果密码中包含#或;则必须用3个
  
引号包装它,例如 """ #password; """

Note: All the options defined in conf/grafana.ini can be overridden by grammar using environment variables GF_<SectionName>_<KeyName>, the above <host>, <port>, <database_name>, <user>, <password > Please configure the items in angle brackets according to the actual situation.

For more configuration, please refer to http://docs.grafana.org/installation/configuration/

3. Mysql authorized GRANT ALL PRIVILEGES

Configure mysql

According to the environment configuration in the docker-compose.yml file, configure Mysql as follows:

among them,

Host:内⽹网ip,对应environment配置中的‘<host>’。
Username : 对应environment配置中的'<database_name>'。
Password : 对应environment配置中的 '<password>'。 
Database : 对应environment配置中的'<database_name>'。
After configuration, you can use the following command to see if you can connect to the database remotely:
mysql -h ‘<host>’ -u '<user>' -p

Note: When connecting to the database remotely, you will find that the error Can't connect to MySQL server (10060) may still be reported. There are two reasons: one is that the current user is rejected by the mysql server, and the other is that port 3306 is blocked. It is blocked by the wall and cannot be connected to this port.

 

Login MYSQL

Note: In general, to modify the MySQL password and authorization, it is necessary to have root privileges in mysql.

@>mysql -u root -p 
@>密码

Give any host access to data

mysql>GRANT ALL PRIVILEGES ON *.* TO '<user>'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

Refresh the system permission table

  mysql>flush privileges;

Open the fire wall

Open the firewall in "System Preferences->Security & Privacy->Wall".

Modify the my.cnf configuration file under mac

sudo find / -name my.cnf
nano /usr/local/etc/my.cnf
nano /usr/local/Cellar/mysql/5.7.22/.bottle/etc/my.cnf bind-address = 0.0.0.0

Note: There is an option bind-address=127.0.0.1 in my.cnf, which means that mysql server listens to requests sent locally. If any host can request it, write it as 0.0.0.0, but this is not very safe . To monitor an ip, specify this ip address, but ensure that the mysql user allows this ip to access, otherwise the database cannot be operated.

After changing the configuration, restart the mysql database to make it effective:

brew services restart mysql

4. Run docker-compose to execute the command

docker-compose -f docker-compose.yml up


docker-compose up

Start the docker instance example.

After installation is complete and normal operation, the normal effect of accessing service_ip:8000 is as follows:

Note: My service_ip is the local ip, so my local access address is: http://127.0.0.1:8000/login

The initial login account/password is: admin/admin. It is recommended to change the initial account password immediately after logging in for the first time. The modification path is as follows:

5. Configuration and use of monitoring window
 

service_ip:8000 actually accesses the grafana suite, which mainly needs to be configured in two parts: Data Sources and Dashboards.

Data Sources configuration

Data Sources is mainly to configure the data source for obtaining graphite, the configuration example is as follows: (for privacy issues, the picture should be very vague)

For more information, please refer to: http://docs.grafana.org/features/datasources/graphite/ 

Dashboards configuration

For reference: http://docs.grafana.org/reference/dashboard/

Guess you like

Origin blog.csdn.net/LYX_WIN/article/details/107949137