Nomisoft
Menu

Real-time website visitors map

09th July 2015

A while back I had the thought that it would be interesting to see where visitors originate from on various websites I own represented in a graphical way. Around the same time I was looking into getting setup and learning the basics of the MEAN stack, that's MongoDB, ExpressJS, AngularJS and NodeJS. As a little sideline project I ended up developing a nodeJs application for displaying information from apache log files onto an SVG world map with the help of d3.js. The resulting web app is shown below and code is now available on Github at https://github.com/nomisoft/rtwv-map

The application

Apache visitors map
Apache visitors map. Showing visitors from around the world hitting a server in London

How it works

The application works by tailing the apache (or alternative such as nginx) log files. When a new line is written to the log file it is parsed and data about the requested url, visitors ip, browser etc are pulled out. The IP address is then passed to a GeoIP coding library which returns its co-ordinates. All of this information is then passed back to the browser via an open socket connection. d3 then handles plotting this information onto a SVG image of a world map.

Green lines represent successful requests (i.e 200 response code). Red represent requests for non-existent addresses (i.e 404 status code) and orange show redirects (i.e 301/302 status codes).