diff --git a/public/app/plugins/datasource/loki/querybuilder/operations.ts b/public/app/plugins/datasource/loki/querybuilder/operations.ts index 02bdd90dd94..a250b9520e7 100644 --- a/public/app/plugins/datasource/loki/querybuilder/operations.ts +++ b/public/app/plugins/datasource/loki/querybuilder/operations.ts @@ -323,16 +323,30 @@ export function getOperationDefinitions(): QueryBuilderOperationDef[] { { id: LokiOperationId.Unwrap, name: 'Unwrap', - params: [{ name: 'Identifier', type: 'string', hideName: true, minWidth: 16, placeholder: 'Label key' }], - defaultParams: [''], + params: [ + { name: 'Identifier', type: 'string', hideName: true, minWidth: 16, placeholder: 'Label key' }, + { + name: 'Conversion function', + hideName: true, + type: 'string', + options: ['duration', 'duration_seconds', 'bytes'], + optional: true, + }, + ], + defaultParams: ['', ''], alternativesKey: 'format', category: LokiVisualQueryOperationCategory.Formats, orderRank: LokiOperationOrder.Unwrap, - renderer: (op, def, innerExpr) => `${innerExpr} | unwrap ${op.params[0]}`, + renderer: (op, def, innerExpr) => + `${innerExpr} | unwrap ${op.params[1] ? `${op.params[1]}(${op.params[0]})` : op.params[0]}`, addOperationHandler: addLokiOperation, explainHandler: (op) => { let label = String(op.params[0]).length > 0 ? op.params[0] : '