Skip to header Skip to main navigation Skip to main content Skip to footer

Search form

Site branding

Home
What's up, home?

Main navigation

  • Home
  • Story mode
  • About
  • Features
  • Hardware list
  • Videos
  • GitHub (opens in new tab)
  • Daily AI generated stories (opens in new tab)

Part 34: Monitor your website visitor rate

Breadcrumbs

Breadcrumb

  • Home
  • Part 34: Monitor your website visitor rate

Main page content

By whatsuphome | 6:15 AM EET, Thu January 26, 2023

TL;DR

I monitor my website's visitor rate by mounting its remote access logs over SSH using sshfs on my Raspberry Pi. Zabbix then applies standard log file monitoring to parse the Apache-style access logs in real time. The result is a dashboard showing visitor
Dashboard

Can you monitor your website visitor rate with Zabbix? Of course you can! By day, I am a lead site reliability engineer in a global cyber security company. By night, I monitor my home with Zabbix & Grafana and do some weird experiments with them.

I have this website hosted in a domain hotel, and among other features the admin panel has some standard website access log analysers (such as awstats) available for me to see activity of this site. That's cool, but also boringly easy, and requires me to login to that admin panel instead of me using my trusted single pane of glass that is Zabbix.

Let's connect to site logs

If I login to my site over ssh/sftp, my home directory has a preconfigured access_logs directory. Like the name says, it contains the website access logs in the usual format you would expect it to be:

35.166.xxx.xxx - - [26/Jan/2023:04:24:37 +0200] "GET / HTTP/1.1" 200 10055 "http://whatsuphome.fi" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"

That's great, but how to monitor that in real-time with Zabbix? Let's use sshfs -- it's like NFS or CIFS, but allows you to mount stuff over ssh. On my dear Raspberry Pi 4 which runs my Zabbix, running

sudo mkdir /var/log/whatsuphome && sudo chown zabbix /var/log/whatsuphome

sudo sshfs -o allow_other mywhatsuphomeaccount@myhotelname:access_logs /var/log/whatsuphome 

did mount my remote server access_logs directory perfectly fine.

Time for monitoring

Now that we have our log file, the rest is very straightforward and standard log file monitoring. First, let's add a master item that reads the log. 

Access log master item
Nothing too difficult yet.

Next, let's add a dependent item that grabs the visitor IP address part from a log line.

Dependent item

... and some item pre-processing to grab only the IP

Item pre-processing regular expression
Sorry about that ugly regular expression.

... after adding a few more items, here's my template.

Template overview

I'm currently not parsing the referrer, exact URL or user-agent values, as for the most part those would just add unnecessary noise and load for my poor little home Zabbix.

Dashboard time!

So, finally I created a dashboard showing the number of unique IP addresses & hits during the past 24 hours and some graphs. Now that I've not posted any posts in a while, welcome to Tumbleweedville!

Dashboard
It's so silent in here that I can hear my own typing.

After publishing this post, I'll wait for a while and then update the post with a new screenshot, so we'll get to see the incredible visitor surge that will be counted in at least tens of new IP addresses.

Update #1 about 15 minutes after publishing the post

15 minutes after publishing the post
Clearly some movement in the access log needle!

Update #2 one hour after publishing the post

One hour after posting
Almost 400 unique IP addresses already? Hello, dear readers and bots.

Update #3 one day after publishing the post

Statistics one day after publishing the post
Even though IP addresses are a bad way to measure actual amount of visitors, roughly 400 unique new addresses after publishing my post is very good. Thanks, bots and readers!


 

whatsuphome
zabbix
website
accesslogs
part34
  • Add new comment

Comments (2)

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Nginx Acces logs template

Dan (not verified)

3 years 8 months ago
Permalink
New

Hi, awesome stuff can you also export the template and maybe upload is somewhere?
Cheers

  • Reply

Zabbix

Gregoriy (not verified)

3 years 4 months ago
Permalink
New

Interesting

  • Reply
I monitor my website's visitor rate by mounting its remote access logs over SSH using sshfs on my Raspberry Pi. Zabbix then applies standard log file monitoring to parse the Apache-style access logs in real time. The result is a dashboard showing visitor

Search

Who am I?

  • Janne Pikkarainen from Finland 🇫🇮
  • Began with computers in 1986 with C64
  • Doing IT for living since 1999
  • Principal Site Reliability Engineer at Forcepoint
  • A Zabbix Summit speaker every year since 2022
  • Walking, talking Zabbix commercial

Support my project

Buy me a coffee 

Footer menu

  • Contact

What's up, home? | Janne Pikkarainen | contact(at)whatsuphome.fi | 2022 - 2026

Developed and Designed by Janne Pikkarainen