Skip to content

Instantly share code, notes, and snippets.

@rlindooren
Created March 9, 2015 12:00
Show Gist options
  • Save rlindooren/e600c59b68801cc6273d to your computer and use it in GitHub Desktop.
Save rlindooren/e600c59b68801cc6273d to your computer and use it in GitHub Desktop.
Simple Python script that can convert Elasticsearch JSON output (based on Log4j events logged via Logstash) to human readable text
#!/usr/bin/python
import sys
import json
jsonData = json.load(sys.stdin)
for hit in jsonData["hits"]["hits"]:
source = hit["_source"]
print "{0} {1:<5} - <{2}> {3}.{4}.({5}): {6}".format(source["@timestamp"], source["priority"], source["thread"], source["class"], source["method"], source["file"], source["message"])
if "stack_trace" in source:
print "{0}".format(source["stack_trace"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment