Skip to content

Instantly share code, notes, and snippets.

@athoune
Created September 22, 2014 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athoune/97226d094d240a98a642 to your computer and use it in GitHub Desktop.
Save athoune/97226d094d240a98a642 to your computer and use it in GitHub Desktop.
import json
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
while True:
chan, packet = r.blpop('packetbeat')
packet = json.loads(packet)
if packet['http'] is None:
continue
content_length = packet['http']['content_length']
responsetime = packet['responsetime']
agent = packet['agent']
host = packet['http']['host']
request_len = len(packet['request_raw'])
response_len = len(packet['response_raw'])
uri = packet['http']['request']['uri']
method = packet['http']['request']['method']
src_ip = packet['src_ip']
code = packet['http']['response']['code']
ts = packet['@timestamp']
print agent, ts, src_ip, code, method, responsetime, 'ms', request_len, 'bytes', response_len, 'bytes', uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment