Evolving Software

Sending JSON formatted logstash data into your ELK cluster is great. It is a real help when you are searching through the proverbial haystack in production for clues to what went wrong. However, sometimes when you are developing you might want to read the data off the test server just like it was going to your console … now you hate the JSON format. Tailing the logs is now basically worthless.

Here is a bash script that tails the log and just prints out the ‘@message’ field in the JSON object.

1
2
3
4
5
tail -f debug-json.log | \
  xargs -L1 --delimiter='\n' -n1  \
  python -c 'import json,sys; \
             d = json.loads(sys.argv[1]); \
             print d["@message"];';
  • seh

    Alternately, use jq:

    tail -f debug-json.log | jq -r ‘.[“@message”]’

  • True, however in some of the shared hosting environments jq isn’t available. However I haven’t seen one that doesn’t have tail, xargs, and python available.

  • Tony

    Hi,

    Thank You for having the 68 Pony Wiring Diagram easily accessible on the net.
    I brought the wiring diagram in book form but couldn’t find it when i needed it.

    Appreciated.

    Regards
    Tony