Install Zabbix 5.0 with Docker → Set up Slack notification in case of failure

Ubuntu-20.04.01Zabbix-5.0.3Git-2.28.0Docker-19.03.13CPython-3.7.7OpenSSL-1.1.0

I want to monitor the server and domain. Since I had no experience of using Zabbix, I will implement it for learning. The goal is to be notified to the designated channel of Slack in the event of a failure.

Environment preparation

name version
Ubuntu 20.04.01
Zabbix 5.0.3
Git 2.28.0
Docker 19.03.13
docker-compose 1.27.3, build 4092ae5d
docker-py 4.3.1
CPython 3.7.7
OpenSSL 1.1.0l 10 Sep 2019

procedure

This is the installation procedure.

Clone Zabbix

git clone https://github.com/zabbix/zabbix-docker.git
cd zabbix-docker

This time, we will configure Alpine + PostgreSQL. Alpine is enough when using Docker, so I don't think it is necessary to have an image that is too large. The reason for choosing PostgreSQL over MySQL is that in the future, when the settings became bloated, MySQL decided that tuning alone would not be suitable for handling a large number of queries. I think it would be good to change from MySQL to PostgreSQL later, but considering the cost, I decided to go with PostgreSQL from the beginning.

For selection

I referred to.

Copy YAML

$ cp docker-compose_v3_alpine_pgsql_latest.yaml docker-compose.yml

Modify DB User and Password

#Modify the following files as needed
.POSTGRES_USER
.POSTGRES_PASSWORD

Start-up

$ sudo docker-compose up -d

$ sudo docker-compose ps
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
                 Name                                Command                  State                           Ports                     
----------------------------------------------------------------------------------------------------------------------------------------
zabbix-docker_db_data_mysql_1             sh                               Exit 0                                                       
zabbix-docker_db_data_pgsql_1             sh                               Exit 0                                                       
zabbix-docker_mysql-server_1              docker-entrypoint.sh mysql ...   Up                                                           
zabbix-docker_postgres-server_1           docker-entrypoint.sh postgres    Up                                                           
zabbix-docker_zabbix-agent_1              /sbin/tini -- /usr/bin/doc ...   Up                                                           
zabbix-docker_zabbix-java-gateway_1       docker-entrypoint.sh /usr/ ...   Up                                                           
zabbix-docker_zabbix-proxy-mysql_1        /sbin/tini -- /usr/bin/doc ...   Up             0.0.0.0:10071->10051/tcp                      
zabbix-docker_zabbix-proxy-sqlite3_1      /sbin/tini -- /usr/bin/doc ...   Up             0.0.0.0:10061->10051/tcp                      
zabbix-docker_zabbix-server_1             /sbin/tini -- /usr/bin/doc ...   Up             0.0.0.0:10051->10051/tcp                      
zabbix-docker_zabbix-snmptraps_1          /usr/bin/supervisord -c /e ...   Up             0.0.0.0:162->1162/udp                         
zabbix-docker_zabbix-web-apache-pgsql_1   docker-entrypoint.sh /usr/ ...   Up (healthy)   0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   
zabbix-docker_zabbix-web-nginx-pgsql_1    docker-entrypoint.sh             Up (healthy)   0.0.0.0:8081->8080/tcp, 0.0.0.0:8443->8443/tcp

I got a Warning, so I will check it just in case. WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus (the following deploy subkeys were ignored because they are not supported)

 deploy:
   resources:
    reservations:
      cpus: '0.5'

These options are scheduled options for swarm mode services (That is, don't actually reserve resources, just let swarm consider them when scheduling containers on the node).

Docker Compose doesn't work in swarm mode (deploys a local container) No orchestrator takes these restrictions into account.

Reference: Compatibility mode # 5684

If you don't use reservation, the warning will disappear. Since it is ignored, it seems that there is no problem ignoring this error. Since it is not psychologically good to get a Warning every time I check it, I commented out the corresponding line.

      #reservations:
      #cpus: '0.5'
      #memory: 512M

Let's run it again.

$ sudo docker-compose up -d --build

$ sudo docker-compose ps
                 Name                                Command                       State                               Ports                     
-------------------------------------------------------------------------------------------------------------------------------------------------
zabbix-docker_db_data_mysql_1             sh                               Exit 0                                                                
zabbix-docker_db_data_pgsql_1             sh                               Exit 0                                                                
zabbix-docker_mysql-server_1              docker-entrypoint.sh mysql ...   Up                                                                    
zabbix-docker_postgres-server_1           docker-entrypoint.sh postgres    Up                                                                    
zabbix-docker_zabbix-agent_1              /sbin/tini -- /usr/bin/doc ...   Up                                                                    
zabbix-docker_zabbix-java-gateway_1       docker-entrypoint.sh /usr/ ...   Up                                                                    
zabbix-docker_zabbix-proxy-mysql_1        /sbin/tini -- /usr/bin/doc ...   Up                      0.0.0.0:10071->10051/tcp                      
zabbix-docker_zabbix-proxy-sqlite3_1      /sbin/tini -- /usr/bin/doc ...   Up                      0.0.0.0:10061->10051/tcp                      
zabbix-docker_zabbix-server_1             /sbin/tini -- /usr/bin/doc ...   Up                      0.0.0.0:10051->10051/tcp                      
zabbix-docker_zabbix-snmptraps_1          /usr/bin/supervisord -c /e ...   Up                      0.0.0.0:162->1162/udp                         
zabbix-docker_zabbix-web-apache-pgsql_1   docker-entrypoint.sh /usr/ ...   Up (health: starting)   0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   
zabbix-docker_zabbix-web-nginx-pgsql_1    docker-entrypoint.sh             Up (health: starting)   0.0.0.0:8081->8080/tcp, 0.0.0.0:8443->8443/tcp

Now that WARNING has disappeared, I would like to return to the main topic.

About the host name

You can check it at http: // localhost / from this server where the container is located. From the same network band, I was able to confirm the connection at http://192.168.x.x/.

Proxy settings

Check the logs and check the error.

zabbix-server_1            |    211:20200923:130201.825 cannot parse proxy data from active proxy at "172.16.238.4": proxy "zabbix-proxy-sqlite3" not found
zabbix-server_1            |    211:20200923:130202.452 cannot parse proxy data from active proxy at "172.16.238.6": proxy "zabbix-proxy-mysql" not found

Take action as follows. I tried launching Zabbix4.2 with docker

cannot send list of active checks to "xxx": host [yyy] not found I keep getting errors. Deal with the following. [[Zabbix] "-cannot-send-list-of-active-checks-to-127-0-0-1" keeps appearing in the log](https://vamdemicsystem.black/zabbix/%E3%80% 90zabbix% E3% 80% 91% E3% 83% AD% E3% 82% B0% E3% 81% AB% E3% 80% 8C-cannot-send-list-of-active-checks-to-127-0- 0-1% E3% 80% 8D% E3% 81% 8C% E5% 87% BA% E7% B6% 9A% E3% 81% 91% E3% 82% 8B)

Login

zabbix5.0ログイン画面

The initial ID and PW are as follows. (Caution for capital letters)

ID PW
Admin zabbix
zabbix5.0ログイン後、初期画面

This is the initial screen after login.

Localizing into Japanese

Change to "User setting"-> "Language"-> "Japanese (ja_JP)" on the left sidebar. The initial password is vulnerable, so change the password at the same time.

Eliminate "Zabbix Server unavailable"

I corrected it referring to the following. [Resolve Zabbix Server Unavailability](https://qiita.com/zembutsu/items/d98099bf68399c56c236#zabbix-server-%E3%81%AE-%E5%88%A9%E7%94%A8%E4 % B8% 8D% E5% 8F% AF-% E3% 82% 92% E8% A7% A3% E6% B6% 88% E3% 81% 99% E3% 82% 8B)

Zabbix Server の 利用不可 を解消する * From "Settings" → "Host" → "Interface".

Around host template mail settings

I think that there are various things here if you go around. I referred to the following.

Time zone

Alpine version Zabbix is not Japan time, so it needs to be corrected.

I was wondering where to change, but I fixed ".env_web".

Fixed garbled characters in graph

See here.

[Build Zabbix server with Docker on ARM CPU machine --Download Japanese font](https://qiita.com/sakai00kou/items/285d0a4008b8492f5937#%E6%97%A5%E6%9C%AC%E8 % AA% 9E% E3% 83% 95% E3% 82% A9% E3% 83% B3% E3% 83% 88% E3% 81% AE% E3% 83% 80% E3% 82% A6% E3% 83 % B3% E3% 83% AD% E3% 83% BC% E3% 83% 89)

sudo apt-get install -y fonts-ipafont

I mounted the font directly like this.

docker-compose.yml


 zabbix-web-nginx-pgsql:
  image: zabbix/zabbix-web-nginx-pgsql:alpine-5.0-latest
  ports:
   - "80:8080"
   - "443:8443"
  links:
   - postgres-server:postgres-server
   - zabbix-server:zabbix-server
  volumes:
   - /etc/localtime:/etc/localtime:ro
   - /etc/timezone:/etc/timezone:ro
   - ./zbx_env/etc/ssl/nginx:/etc/ssl/nginx:ro
   - ./zbx_env/usr/share/zabbix/modules/:/usr/share/zabbix/modules/:ro
   - /usr/share/fonts/opentype/ipafont-gothic/ipagp.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf:ro

Now when you start docker again, you can see that it is in Japanese.

日本語表示を確認したZabbix5.0のグラフの一部

This completes the Japanese font area.

Slack notification settings

Refer to the following Set up slack notification in Zabbix 5.0

result

For the time being, I was able to build the monitoring system I wanted to do.

zabbixからslackに障害時に通知を飛ばした際のサンプル

Impressions

reference

Zabbix 5.0 environment construction memo with Docker Set up slack notification in Zabbix 5.0 Update the version of git on Ubuntu Zabbix Database Benchmark Report PostgreSQL vs MySQL PostgreSQL on Large-Scale Surveillance Server I searched for ultra-lightweight Alpine Linux Procedure to start Zabbix 5.0 with Docker Compose Install the latest version of docker on ubuntu Install the latest docker compose on Ubuntu 20.04 Productivity Tips and Best Practices for Running Docker Compose Limits-Practical Exercises for Docker Compose Part 4 [Note] How to monitor Docker resources with zabbix Zabbix 5.0: Monitoring host settings What I was addicted to when I first learned Zabbix (small story, scheduled to be updated at any time) Zabbix 5.0 LTS Docker version from startup to login Build Zabbix server with Docker on ARM CPU machine Web monitoring with Zabbix (Part 1) Launch Zabbix 5.0 with docker-compose

Recommended Posts

Install Zabbix 5.0 with Docker → Set up Slack notification in case of failure
Set up GitLab with docker
Alert slack with alert manager in Docker environment
Install Composer with Docker
Install by specifying the version of Django in the Docker environment
Case that gave up environment construction of react with ubuntu
How to set up a proxy with authentication in Feign
Install yarn in docker image
Build Zabbix5.0 with official docker-compose, monitor SNMPTRAP and set Slack notifications
Install Docker on Ubuntu and set up remote connection using tls