This section presents a step-by-step real-life example of how web monitoring can be used.
Zabbix web monitoring will be used to monitor Zabbix frontend. The goal is to determine if it is available, provides the right content, and how quickly it works. To achieve this, several steps are required, including checking the availability of the first page, logging in with a username and password, verifying the login success, logging out, and confirming the logout.
Go to Data collection → Hosts, pick a host and click on Web in the row of that host. Then click on Create web scenario.
In the new scenario form, fill out the following fields:
In the Variables section, add two variables: {password} and {user}. Enter your existing Zabbix user credentials as values.
For safety reasons, it is recommended to create a separate user with minimal permissions to use for monitoring purposes.
Optionally, switch to the Tags tab and add web scenario tags.
Once fully configured, this web scenario will automatically add a Zabbix trapper item to the host. You can use web scenario tags to quickly identify related items and triggers or search through collected data. For example, suitable tags for this tutorial are component: web-scenario
and/or target: frontend
.
Switch to the Steps tab and define steps for the scenario. Click on Add button to add an individual step.
For each step described below, fill out the following fields in addition to the step-specific fields:
Check that the first page responds correctly, returns HTTP response code 200 and contains the text "Zabbix SIA".
When done configuring the step, press the Add button.
Log in to the Zabbix frontend using the macros (variables) defined at the scenario level - {user} and {password}.
Note that Zabbix frontend uses JavaScript redirect when logging in, so login must occur first, and logged-in features can be checked only in further steps. Additionally, the login step must use the full URL to index.php file.
After logging in, verify success by checking for a string visible only when logged in - for example, Administration.
Once the frontend's accessibility and login have been verified, add a logout step - otherwise the Zabbix database will become cluttered with many open session records.
This step uses the variable {csrf_token} obtained in step 2
To confirm the logout, check for the Username string.
A complete configuration of web scenario steps should look like this:
Save the finished web monitoring scenario.
The scenario will be added to the host. To view web scenario information go to Monitoring → Hosts, locate the host in the list and click on the Web hyperlink in the last column.
Click on the scenario name to see more detailed statistics: