moovs / zabbix-grafana

Deploy Zabbix 4.0 LTS with Grafana and notifications in Telegram

Home Page:https://github.com/moovs/zabbix-grafana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Deploy Zabbix 4.0 with Grafana dashboards in Docker-compose


This guide is about how to deploy a Zabbix monitoring system with Grafana to display graphs.
The whole installation will be divided into 3 parts. The first step is setting up Zabbix, the second step is connecting Zabbix to Grafana, and the third step is creating Telegram bot and connect to Zabbix for notifications.

Prerequisites:

Clone this repo to your host:

git clone https://github.com/moovs/zabbix-grafana.git

Build and start docker-compose file:

cd /path/to/zabbix-grafana
docker-compose up -d --build

Move telegram script to alertscripts:

mv telegram alertscripts/

Set right permission to telegram script and make it executable:

cd alertscripts/
chown -R zabbix telegram
chmod +x telegram

Step 1. Zabbix setup.

Login to Zabbix web interface with default 80 port:

the default user is “admin” and the password is “zabbix”

Change admin password:

  • navigate to Administration then Users select Admin and click Change password

If you want to monitor your instance with Zabbix, you need to install zabbix-agent on this host:

in this case, we install Zabbix agent of the 4.0 version:

wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb
dpkg -i zabbix-release_4.0-2+stretch_all.deb
apt-get update
apt-get install zabbix-agent

Update Zabbix agent config:

  • after that you need to change point Server= in /etc/zabbix/zabbix_agentd.conf config to IP address your zabbix-server container Server=172.16.238.10 and restart zabbix-agent /etc/init.d/zabbix-agent restart

Change Zabbix server IP address:

  • and the last step, go to Configuration then Hosts click on Zabbix server and change IP address to IP address your host:

Check monitoring data:

  • after few minutes, monitoring data will start flowing in, to check host graphs go to Moniroting then Graphs:

Step 2. Grafana setup.

Login to Grafana:

  • login to Grafana web interface with default 3000 port login with default credentials and change admin password:

default login and password is admin

Enable Zabbix plugin:

  • go to Zabbix in Installed Apps and enable Zabbix plugin or just click Enable now:

Configure the data source as follows:

  • enter a name for this new data source in the Name field.
  • fill in the Url field with the full path to the Zabbix API, which will be http://your_zabbix_server_ip_address/api_jsonrpc.php.
  • fill in the Username and Password fields in Zabbix API details block with the username and password for Zabbix.

  • click Save & Test to save and test your configuration. If you did everything correctly you will see the following message:

  • here you may import some dashboards for vizualizations, just click to Dashboards and import Zabbix Server Dashboard and Zabbix Template Linux Server:

  • to see them go to Home:

  • and select your dashboards to see graphs:

here you find more dasboards for Zabbix

Step 3. Сonnecting and setting up a Telegram to Zabbix.

If you want send alert notifications to Telegram channel you need create Telegram bot.

Create Telegram Bot.

  • firstly go to BotFather in your Telegram.
  • in BotFather type /start see informations about what you can do or just type /newbot for create your bot.
  • the next you will be asked to give a name and username to your bot.

it must end in bot. Like this, for example: TetrisBot or tetris_bot.

  • after that you received your bot token to access the HTTP API, copy this token in you Telegram script in line BOT_TOKEN

  • get the list of updates for your BOT for that follow this link and substitute your bot token https://api.telegram.org/bot<YourBOTToken>/getUpdates
  • login to the Telegram web in your browser and find your bot by username and click on Start button.
  • create your new group and add here your bot.
  • now refresh this link to see you group chat id.

your group chat id will be start with minus sign like this -635324858

  • after that you can send test notification in your chat group:
docker exec -ti zabbix_server bash
cd /usr/lib/zabbix/alertscripts/
./telegram -635324858 test mesage

if you received test message you can move on.

Create Media type in Zabbix.

  • after everything done you need go to Zabbix web interface to Administration > Media types and choose Create media type:

  • enter a name for media type in the Name and Script name fields and choose Script in Type fields.
  • fill in Script parameters fields next parameters: {ALERT.SENDTO}, {ALERT.SUBJECT} and {ALERT.MESSAGE}.
  • then go to User profile: Zabbix Administrator, click on human icon in the right corner and choose Media tab:

  • choose Type telegram in the field Send to substitute your group chat id -635324858and click add then Update.
  • the next go to Configuration then Actions and choose Host, equals and name of your server Zabbix server and click Add button then Update:

  • don't forget Enable it on Actions page:

  • now you can test you alerting system, go to instance with Zabbix server and stop your zabbix_agent:
service zabbix-agent stop

and after waiting a few minutes you revieved alert massage to your group in Telegram:

About

Deploy Zabbix 4.0 LTS with Grafana and notifications in Telegram

https://github.com/moovs/zabbix-grafana


Languages

Language:Python 52.9%Language:Dockerfile 47.1%