Realtime pixel tracking with nginx, syslog-ng, and Redis
benwilber.net
benwilber.net
For those who didn't read the post: he's formatting syslog messages as redis wire commands, telling syslog to forward those messages to redis over the network (normally you're forwarding to another syslog client, but because of the custom message format here, it acts against a redis server), so syslog ends up as a write-only redis client.
Insane. and brilliant.
log_format json '["$time_local","$msec","$remote_addr","$remote_user","$http_host","$request","$status","$upstream_addr","$upstream_cache_status","$bytes_sent","$request_time","$upstream_response_time","$http_referer","$http_user_agent","$http_x_forwarded_for","$http_cookie","$upstream_http_x_session_key","$upstream_http_x_session_user"]';
(just copied and pasted from my own config, many fields are not relevant to this use case in particular).
Then log to a named pipe into a program which would then RPUSH the entries into a LIST or maybe PUBLISH them to a channel, from where several different analytics programs would be running for several different metrics that depend on the same data, so that they could run in parallel.
@namespace url(http://www.w3.org/1999/xhtml); @-moz-document domain("news.ycombinator.com") { p { word-break: break-all; } }
I'd love to see an open source package emerge to implement the collection and the data processing. Cloudfront + Redshift would rock.
http://wiki.nginx.org/HttpRedis2Module
We log the same requests to a file in a custom log format that gets batched to s3 and then Cassandra and EMR/Hive. Makes a great platform for realtime + historical analytics.
I followed your guide but I am not able to see the Redis records. I was able to find pixel.log in /var/log/nginx and inside was what I would expect to see in Redis:
1379192937.393,test=2
1379193104.365,test=5
1379193105.308,test=7
1379193106.311,test=28
.....At this point I went to check the syslog-ng program as I realized I never verified it was running/working. I am getting a "Error parsing source, source plugin system not found in /usr/local/etc/syslog-ng.conf at line 2, column 3:" error and after some googling I found some people suggesting[0] adding '@include "scl.conf"' to the syslog-ng config file. I tried added this and it caused another syntax error. I googled for a while longer to no avail.
I know HN isn't really the forum for tech support but I couldn't find a better place to post it other than over email (My email is in my profile if you prefer that). If you have any pointers please let me know. Thank you for any help you may be able to provide.
1. Javascript disabled
2. Tracking emails opened