Zabbix+Grafana: How to count website visits based on logs?

Thanks to the author of this article, Li Gen, Zabbix senior certified expert .

In addition to monitoring the website's response results, response time and transmission speed through HTTP proxy and WEB scenarios, Zabbix can also obtain useful statistical information by reading the website's background logs.

Let me take Grafana as an example to introduce how to count website visits through logs.

Here's how to do it:


1. To read grafana logs, you must first read the logs based on Zabbix Agent. For its installation, please refer to the Zabbix official manual and will not go into details here. 

1.1. After the Agent is started, a host can be created automatically or manually.

1.2. Create another monitoring item "grafana log file" of the "Zabbix client (active)" type, and read the grafana log through the key value "log[/var/log/grafana/grafana.log]" . As shown below:

1.3. After creating the above monitoring items, you can view grafna’s log content in the latest data, as shown below:


2. Intercept user login information and then match key values ​​through regular expressions based on the read log content to obtain the required user login information. 

2.1. Create a monitoring item "grafana login user" of type "related projects". The main item is the previously created "grafana log file" monitoring item.

2.2. During the preprocessing process, intercept the corresponding login user information based on keywords such as "Successfull Loing". As shown below

2.3. After creating the above monitoring items, you can view the corresponding logged-in user information in the latest data, as shown below:

3. Statistics of user login data and then based on intercepted user login information, relevant data statistics are carried out through calculable items.

3.1. Create a monitoring item "grafana login user num" of type "calculable item", which is used to calculate the number of user logins per minute. As shown below:

3.2. Create a monitoring item "grafana login user num sum" of type "calculable item" to count the total number of user logins in the last day. As shown below:

3.3. You can also create a monitoring item "grafana login user count unique" of type "calculable item" to count the number of users logged in in the last day. As shown below:

3.3. After creating the above monitoring items, you can log in to grafana to observe the data collection of the corresponding monitoring items. As shown below:. As shown below: Note: The statistics of client IP and number of requests in the above figure are similar to the statistics of user login numbers. In addition to the above method, key information statistics can also be carried out through log.count or logrt.count.

4. After the corresponding data is displayed on the customized Dashboard, the above data can be displayed through the customized Dashboard. 

4.1. In the "Monitoring->Dashboard" page, click "Create Dashboard" and enter the name of the new dashboard.

4.2. Then click "Add New Build", enter the corresponding name, and select the corresponding type and monitoring items. As shown below:

4.3. Display the collected data by adding different constructs. As shown below:

Contributions are welcome! Earn a few thousand yuan from it first! Zabbix Prize-winning Submission

Further reading

Grafana 9.0 is released, with new features such as Prometheus and Loki query builder, new navigation, heat map panel and more!

Grafana builds computer room and network topology visualization

This article is shared from the WeChat public account - Zabbix open source community (china_zabbix).
If there is any infringement, please contact [email protected] for deletion.
This article participates in the " OSC Source Creation Plan ". You who are reading are welcome to join and share together.

Lei Jun: The official version of Xiaomi’s new operating system ThePaper OS has been packaged. A pop-up window on the Gome App lottery page insults its founder. The U.S. government restricts the export of NVIDIA H800 GPU to China. The Xiaomi ThePaper OS interface is exposed. A master used Scratch to rub the RISC-V simulator and it ran successfully. Linux kernel RustDesk remote desktop 1.2.3 released, enhanced Wayland support After unplugging the Logitech USB receiver, the Linux kernel crashed DHH sharp review of "packaging tools": the front end does not need to be built at all (No Build) JetBrains launches Writerside to create technical documentation Tools for Node.js 21 officially released
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/3900302/blog/10114346