From c952c9c90a4ae441f17740208aecade10b9ba092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Mar 2022 10:12:54 +0100 Subject: [PATCH] Loki: Adds more options to make line filter UX better (#46324) * Loki: Adds more options to make line filter UX better * Sync wording * Tweak width * More tweaks * Added descriptions as well --- .../loki/querybuilder/operations.ts | 52 ++++++++++++++++--- .../querybuilder/shared/OperationEditor.tsx | 8 +-- .../shared/OperationParamEditor.tsx | 4 ++ .../prometheus/querybuilder/shared/types.ts | 4 ++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/public/app/plugins/datasource/loki/querybuilder/operations.ts b/public/app/plugins/datasource/loki/querybuilder/operations.ts index 21a79b264fa..614fab36960 100644 --- a/public/app/plugins/datasource/loki/querybuilder/operations.ts +++ b/public/app/plugins/datasource/loki/querybuilder/operations.ts @@ -48,7 +48,16 @@ export function getOperationDefintions(): QueryBuilderOperationDef[] { { id: LokiOperationId.LineContains, name: 'Line contains', - params: [{ name: 'String', type: 'string' }], + params: [ + { + name: 'String', + type: 'string', + hideName: true, + placeholder: 'Text to find', + description: 'Find log lines that contains this text', + minWidth: 20, + }, + ], defaultParams: [''], alternativesKey: 'line filter', category: LokiVisualQueryOperationCategory.LineFilters, @@ -59,7 +68,16 @@ export function getOperationDefintions(): QueryBuilderOperationDef[] { { id: LokiOperationId.LineContainsNot, name: 'Line does not contain', - params: [{ name: 'String', type: 'string' }], + params: [ + { + name: 'String', + type: 'string', + hideName: true, + placeholder: 'Text to exclude', + description: 'Find log lines that does not contain this text', + minWidth: 26, + }, + ], defaultParams: [''], alternativesKey: 'line filter', category: LokiVisualQueryOperationCategory.LineFilters, @@ -70,7 +88,16 @@ export function getOperationDefintions(): QueryBuilderOperationDef[] { { id: LokiOperationId.LineMatchesRegex, name: 'Line contains regex match', - params: [{ name: 'Regex', type: 'string' }], + params: [ + { + name: 'Regex', + type: 'string', + hideName: true, + placeholder: 'Pattern to match', + description: 'Find log lines that match this regex pattern', + minWidth: 30, + }, + ], defaultParams: [''], alternativesKey: 'line filter', category: LokiVisualQueryOperationCategory.LineFilters, @@ -81,7 +108,16 @@ export function getOperationDefintions(): QueryBuilderOperationDef[] { { id: LokiOperationId.LineMatchesRegexNot, name: 'Line does not match regex', - params: [{ name: 'Regex', type: 'string' }], + params: [ + { + name: 'Regex', + type: 'string', + hideName: true, + placeholder: 'Pattern to exclude', + description: 'Find log lines that does not match this regex pattern', + minWidth: 30, + }, + ], defaultParams: [''], alternativesKey: 'line filter', category: LokiVisualQueryOperationCategory.LineFilters, @@ -116,13 +152,15 @@ export function getOperationDefintions(): QueryBuilderOperationDef[] { { id: LokiOperationId.Unwrap, name: 'Unwrap', - params: [{ name: 'Identifier', type: 'string' }], + params: [{ name: 'Identifier', type: 'string', hideName: true, minWidth: 16, placeholder: 'Label key' }], defaultParams: [''], category: LokiVisualQueryOperationCategory.Formats, renderer: (op, def, innerExpr) => `${innerExpr} | unwrap ${op.params[0]}`, addOperationHandler: addLokiOperation, - explainHandler: (op) => - `Use the extracted label \`${op.params[0]}\` as sample values instead of log lines for the subsequent range aggregation.`, + explainHandler: (op) => { + let label = String(op.params[0]).length > 0 ? op.params[0] : '