"documentation":"Strict parsing. The logfmt parser stops scanning the log line and returns early with an error when it encounters any poorly formatted key/value pair.",
"insertText":"--strict",
"label":"--strict",
"type":"FUNCTION",
},
{
"documentation":"Retain standalone keys with empty value. The logfmt parser retains standalone keys (keys without a value) as labels with value set to empty string.",
"insertText":"--keep-empty",
"label":"--keep-empty",
"type":"FUNCTION",
},
{
"documentation":"Operator docs",
"insertText":"| json",
"label":"json",
"type":"PARSER",
},
{
"documentation":"Operator docs",
"insertText":"| logfmt",
"label":"logfmt",
"type":"PARSER",
},
{
"documentation":"Operator docs",
"insertText":"| pattern",
"label":"pattern",
"type":"PARSER",
},
{
"documentation":"Operator docs",
"insertText":"| regexp",
"label":"regexp",
"type":"PARSER",
},
{
"documentation":"Operator docs",
"insertText":"| unpack",
"label":"unpack",
"type":"PARSER",
},
{
"documentation":"Operator docs",
"insertText":"| line_format "{{.$0}}"",
"isSnippet":true,
"label":"line_format",
"type":"PIPE_OPERATION",
},
{
"documentation":"Operator docs",
"insertText":"| label_format",
"isSnippet":true,
"label":"label_format",
"type":"PIPE_OPERATION",
},
{
"documentation":"Operator docs",
"insertText":"| unwrap",
"label":"unwrap",
"type":"PIPE_OPERATION",
},
{
"documentation":"Operator docs",
"insertText":"| decolorize",
"label":"decolorize",
"type":"PIPE_OPERATION",
},
{
"documentation":"Operator docs",
"insertText":"| drop",
"label":"drop",
"type":"PIPE_OPERATION",
},
{
"documentation":"Operator docs",
"insertText":"| keep",
"label":"keep",
"type":"PIPE_OPERATION",
},
{
"insertText":"label1",
"label":"label1",
"triggerOnInsert":false,
"type":"LABEL_NAME",
},
{
"insertText":"label2",
"label":"label2",
"triggerOnInsert":false,
"type":"LABEL_NAME",
},
]
`);
});
it('autocompleting logfmt with flags should return parser, pipe operations, and labels',async()=>{
'Strict parsing. The logfmt parser stops scanning the log line and returns early with an error when it encounters any poorly formatted key/value pair.',
insertText:'--strict',
},
{
type:'FUNCTION',
label:'--keep-empty',
documentation:
'Retain standalone keys with empty value. The logfmt parser retains standalone keys (keys without a value) as labels with value set to empty string.',
insertText:'--keep-empty',
},
];
constLINE_FILTER_COMPLETIONS=[
{
operator:'|=',
@ -131,6 +148,55 @@ function getLineFilterCompletions(afterPipe: boolean): Completion[] {
@ -100,8 +100,33 @@ export function getOperationDefinitions(): QueryBuilderOperationDef[] {
{
id: LokiOperationId.Logfmt,
name:'Logfmt',
params:[],
defaultParams:[],
params:[
{
name:'Strict',
type:'boolean',
optional: true,
description:
'With strict parsing enabled, the logfmt parser immediately stops scanning the log line and returns early with an error when it encounters any poorly formatted key/value pair.',
},
{
name:'Keep empty',
type:'boolean',
optional: true,
description:
'The logfmt parser retains standalone keys (keys without a value) as labels with its value set to empty string. ',
},
{
name:'Expression',
type:'string',
optional: true,
restParam: true,
minWidth: 18,
placeholder:'field_name',
description:
'Using expressions with your logfmt parser will extract and rename (if provided) only the specified fields to labels. You can specify one or more expressions in this way.',