Skip to content

Mapping Live, Realtime Requests from Heroku Log Drains via WebSockets

Notifications You must be signed in to change notification settings

tonyta/cartologger

Repository files navigation

Cartologger

Mapping Live, Realtime Requests from Heroku Log Drains via WebSockets

Cartologger Map

How It Works

Cartologger receives Heroku HTTPS log drains via POST /logplex and, from the router logs, parse the original client IP address of each successful request to the target Heroku app.

Each IP is geolocated via Freegeoip.net (the result of which is cached into Redis). The lat/long coordinates are pushed to the web-client using Rails 5's ActionCable.

The web-client uses Mapbox.js and Leaflet.markercluster to display live realtime Heroku app requests on a map.

How To Use It

Dependencies

The only real dependency is Redis. Make sure you have is installed and that the redis-server is running.

Running Development Servers

You'll need to make sure you have Redis running before starting...

Clone the repo:

git clone https://github.com/tonyta/cartologger.git
cd cartologger/

Install gem dependencies and run tests:

bundle install
bin/rspec

Echo your Mapbox Public Key into your .env file:

# The public key below is just an example. You'll need to get your own.
echo "MAPBOX_PUBLIC_KEY: pk.eyJ1IjoiZm9vIiwiYSI6ImJhciIsImFsZyI6Ik.AkX0xyUS0coZ3t7EZUKW33" >> .env

Run the Rails server in a separate tab, or daemonize with the --daemon option:

bin/rails s

Run Sidekiq process in a separate tab, or daemonize with the --daemon --logfile path/to/log options:

bundle exec sidekiq

Navigate your browser to http://localhost:3000 and you should see a blank map.

Run the following rake task:

bin/rake mock:logdrain

This task will post into your server at /logplex with a fake log drain. You should see markers populating the map in your browser.

Populating Live Heroku Log Events

Make sure the app can accept external requests and add it to your Heroku log drains:

heroku drains:add https://where-you-deployed-cartologger.com/logplex --app your-heroku-app

Feature Requests

  • Tooltip on each marker displaying the city and country of the request.
  • Statistics and history per visitor (IP address).
  • Sorting and selection based on host, path, and method.
  • Reset button to clear map.
  • Automatically scroll map to latest activity.
  • Color and size tweaks for clusters.
  • Presentation mode.
  • Configure log parsing via YAML.
  • Mountable in existing Rails app.

About

Mapping Live, Realtime Requests from Heroku Log Drains via WebSockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published