Skip to content

Instantly share code, notes, and snippets.

@mikechau
Created July 25, 2018 04:15
Show Gist options
  • Save mikechau/358e92dcd3bca0df66e03b3d4497c84a to your computer and use it in GitHub Desktop.
Save mikechau/358e92dcd3bca0df66e03b3d4497c84a to your computer and use it in GitHub Desktop.

Revisions

  1. mikechau created this gist Jul 25, 2018.
    1 change: 1 addition & 0 deletions logstash.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    cat /var/log/logstash/logstash-plain.log | grep -o "^\[.*\]\[DEBUG\]\[logstash.outputs.amazones\]" | awk '{ gsub(/\[DEBUG\].*/, ""); print }' | sed 's/[][]//g' | sed 's/,.*//g' | python timediff.py
    17 changes: 17 additions & 0 deletions timediff.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import dateutil.parser
    import sys

    counter = 0
    ptime = None;
    for line in sys.stdin:
    ctime = dateutil.parser.parse(line)

    if counter == 0:
    ptime = ctime
    print('[{}]: {}'.format(counter, '0:00:00'))
    else:
    dtime = ctime - ptime
    print('[{}]: {}'.format(counter, dtime))
    ptime = ctime

    counter +=1