Skip to content

Instantly share code, notes, and snippets.

@parsibox
Created April 27, 2025 14:58
Show Gist options
  • Save parsibox/5ccc1d0ee79598f10db7f68bc29e9b79 to your computer and use it in GitHub Desktop.
Save parsibox/5ccc1d0ee79598f10db7f68bc29e9b79 to your computer and use it in GitHub Desktop.
calculate rate of new lines in log
stdbuf -oL tail -f /var/www/golang/logs/2025-04-27/esb_worker_db_queue_peertopeer_0_404012_2_access.log | \
> stdbuf -oL grep -oP '"time":"\K[^"]+' | \
> stdbuf -oL awk -F'[:T.]' '{print $2":"$3}' | \
> stdbuf -oL uniq -c | \
> while read count minute; do
> echo "Rate for $minute: $count logs";
> done
stdbuf -oL tail -f /var/www/golang/logs/2025-04-27/esb_worker_db_queue_peertopeer_0_404012_2_access.log | \
> stdbuf -oL grep -oP '"time":"\K[^"]+' | \
> stdbuf -oL awk -F'[T.]' '{print $2}' | \
> stdbuf -oL uniq -c | \
> while read count second; do
> echo "Rate for $second: $count logs";
> done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment