Parsers Configuration
A parser defines how the logs produced by your commands will be parsed and displayed.
Configuration
To configure a parser, you can go to Settings > Parsers
.
A parser is a JavaScript script that takes as input the line produced by a command and returns it modified. JSDoc is written on the parser to guide you on the available options.
For example, let's say I want to parse lines containing a 400 error and convert it to JSON:
javascript
module.exports = (line) => {
if (line.raw.includes('400')) {
line.json = { code: 400, error: line.raw.replaceAll('400', '')}
line.source = 'stderr'
}
return line;
}
When I load this into the service settings, it should look like this:
Feel free to unleash your imagination!