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.
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment