2 Real-life scenario

Overview

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.

Scenario

Add a new web scenario

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:

  • Name - Frontend check
  • Update interval - 1m
  • Attempts - 1
  • Agent - Zabbix

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.

Configure web scenario steps

Switch to the Steps tab and define steps for the scenario. Click on Add button to add an individual step.

Common fields

For each step described below, fill out the following fields in addition to the step-specific fields:

  • URL - the URL of Zabbix frontend
  • Timeout - 15s
  • Required status codes - 200
Web scenario step 1

Check that the first page responds correctly, returns HTTP response code 200 and contains the text "Zabbix SIA".

  • In the Name field, enter First page.
  • In the Required string field, enter Zabbix SIA.
  • Fill out the common fields.

When done configuring the step, press the Add button.

Web scenario step 2

Log in to the Zabbix frontend using the macros (variables) defined at the scenario level - {user} and {password}.

  • In the Name field, enter Login.
  • In the Post fields section, add three post fields:
    • name with value {user}
    • password with value {password}
    • enter with value Sign in
  • In the Variables section, add a new variable {csrf_token} with value regex:([0-9a-z]{64}). This variable will catch the value of the assigned CSRF token to reuse in step 4.
  • Fill out the common fields.

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.

Web scenario step 3

After logging in, verify success by checking for a string visible only when logged in - for example, Administration.

  • In the Name field, enter Login check.
  • In the Required string field, enter Administration.
  • Fill out the common fields.

Web scenario step 4

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.

  • In the Name field, enter Logout.
  • In the Post fields section, add two post fields:
    • reconnect with value 1
    • _csrf_token with value {csrf_token}.
  • Fill out the common fields.

This step uses the variable {csrf_token} obtained in step 2

Web scenario step 5

To confirm the logout, check for the Username string.

  • In the Name field, enter First page.
  • In the Required string field, enter Username.
  • Fill out the common fields.

Full configuration of steps

A complete configuration of web scenario steps should look like this:

Check the results

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: