Skip to content

Instantly share code, notes, and snippets.

@dmig
Created May 13, 2018 06:10
Show Gist options
  • Save dmig/10362efffe89f96d2fa466b717555f55 to your computer and use it in GitHub Desktop.
Save dmig/10362efffe89f96d2fa466b717555f55 to your computer and use it in GitHub Desktop.
lnav MongoDB log format
{
"mongod_log": {
"title": "MongoDB server log format",
"regex": {
"main": {
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[,\\.]\\d+\\+\\d+)\\s+(?<level>\\w)\\s+(?<component>\\w+|-)\\s+\\[?(?<context>-?\\w+)?\\]\\s+(?<body>.*)$"
}
},
"level": {
"critical": "F",
"debug": "D",
"error": "E",
"info": "I",
"warning": "W"
},
"opid-field": "context",
"value": {
"context": {
"kind": "string",
"identifier": true
},
"component": {
"kind": "string",
"identifier": true
},
"body": {
"kind": "string"
}
},
"sample": [{
"line": "2016-11-21T11:55:09.601+0000 I CONTROL [initandlisten] MongoDB starting : pid=19972 port=27017 dbpath=/var/lib/mongodb 32-bit host=ubuntu-512mb-fra1-012"
},
{
"line": "2016-12-24T05:05:49.136+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted"
}
]
}
}
@macintacos
Copy link

Note: if there any non-standard lines in the mongod log you are viewing, the formatting described above will not work. lnav will fall back to a generic log file viewer. I have no plans to update this formatter to account for this use case, but I welcome any and all to take this and modify it for this so that others can use it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment