Created
March 31, 2015 14:44
-
-
Save settermjd/3f0eb5b87f20f7832472 to your computer and use it in GitHub Desktop.
Querying with Winston
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node winston.query.js | tr "[{:,'" ' ' | tr -s " " | awk '/country/ { print $2 }' | sort | uniq | wc -l | tr -s " " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming a log entry of the following, retrieved with
node winston.query.js
:This script firsts strips out the initial
[{:,
, and passes the remaining text to awk, which strips out everything, except for lines containing ‘country’, and returns the country name. Finally, the list of countries is sorted, the duplicates removed, and the count of each country tallied.