Skip to content

Instantly share code, notes, and snippets.

@gswallow
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gswallow/9011322 to your computer and use it in GitHub Desktop.
Save gswallow/9011322 to your computer and use it in GitHub Desktop.
grok patterns for mongodb logs
WORDDASH \b[\w-]+\b
QUERY \{ (?<={ ).*(?= } ntoreturn:) \}
MONGODB %{SYSLOGTIMESTAMP:timestamp} \[%{WORD:component}\] %{GREEDYDATA:message}
After extracting [message] using %{MONGODB}, pass [message] through grok once again using %{SLOWQUERY}
SLOWQUERY %{WORD} %{WORDDASH:database}\.%{WORDDASH:collection} %{WORD}: %{QUERY:query} %{WORD}:%{NONNEGINT:ntoreturn} %{WORD}:%{NONNEGINT:ntoskip} %{WORD}:%{NONNEGINT:nscanned}.*nreturned:%{NONNEGINT:nreturned}..+ (?<duration>[0-9]+)ms
query ascent_production_alere1.assay_configurations query: { converted_chromatogram_id: { $in: [ ObjectId('b1cbbf5ce3ab610d74830642') ] } } ntoreturn:1 ntoskip:0 nscanned:1 keyUpdates:0 locks(micros) r:268396 nreturned:1 reslen:1926148 268ms
becomes...
{
"database": [
"ascent_production_alere1"
],
"collection": [
"assay_configurations"
],
"query": [
"{ converted_chromatogram_id: { $in: [ ObjectId('b1cbbf5ce3ab610d74830642') ] } }"
],
"ntoreturn": [
"1"
],
"ntoskip": [
"0"
],
"nscanned": [
"1"
],
"nreturned": [
"1"
],
"duration": [
"268"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment