Skip to content

Instantly share code, notes, and snippets.

@rjsvaljean
Created February 18, 2016 19:53
Show Gist options
  • Select an option

  • Save rjsvaljean/1880957aeeb787a3fdc0 to your computer and use it in GitHub Desktop.

Select an option

Save rjsvaljean/1880957aeeb787a3fdc0 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Requires `jq`
searchLogs() {
USER=$2
PASSWORD=$3
ORG=$4
MSG_ID="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1")"
RSID=$(curl -s -u $USER:$PASSWORD "https://$ORG.loggly.com/apiv2/search?q=$MSG_ID&from=-9h&until=now&size=30" | jq -r '.rsid.id' 2>/dev/null)
sleep 5
curl -s -u $USER:$PASSWORD "https://$ORG.loggly.com/apiv2/events?rsid=$RSID" | jq '.events[] | {logMsg: .logmsg, tags: .tags[0]} | '$4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment