Created
September 22, 2014 12:00
-
-
Save athoune/97226d094d240a98a642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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