@@ -97,7 +97,7 @@ export class QuickwitDataSource
97
97
return super . query ( request )
98
98
. pipe ( map ( ( response ) => {
99
99
response . data . forEach ( ( dataFrame ) => {
100
- enhanceDataFrameWithDataLinks ( dataFrame , this . dataLinks ) ;
100
+ enhanceDataFrameWithDataLinks ( dataFrame , this . dataLinks , this . logMessageField ) ;
101
101
} ) ;
102
102
return response ;
103
103
} ) ) ;
@@ -738,7 +738,44 @@ function luceneEscape(value: string) {
738
738
return value . replace ( / ( [ \! \* \+ \- \= < > \s \& \| \( \) \[ \] \{ \} \^ \~ \? \: \\ / " ] ) / g, '\\$1' ) ;
739
739
}
740
740
741
- export function enhanceDataFrameWithDataLinks ( dataFrame : DataFrame , dataLinks : DataLinkConfig [ ] ) {
741
+ export function enhanceDataFrameWithDataLinks ( dataFrame : DataFrame , dataLinks : DataLinkConfig [ ] , logMessageField : string | undefined ) {
742
+ // Ignore log volume dataframe, no need to add links or a displayed message field.
743
+ if ( ! dataFrame . refId || dataFrame . refId . startsWith ( 'log-volume' ) ) {
744
+ return ;
745
+ }
746
+ if ( logMessageField ) {
747
+ const messageFields = logMessageField . split ( ',' ) ;
748
+ let field_idx_list = [ ] ;
749
+ for ( const messageField of messageFields ) {
750
+ const field_idx = dataFrame . fields . findIndex ( ( field ) => field . name === messageField ) ;
751
+ if ( field_idx !== - 1 ) {
752
+ field_idx_list . push ( field_idx ) ;
753
+ }
754
+ }
755
+ const displayedMessages = Array ( dataFrame . length ) ;
756
+ for ( let idx = 0 ; idx < dataFrame . length ; idx ++ ) {
757
+ let displayedMessage = "" ;
758
+ // If we have only one field, we assume the field name is obvious for the user and we don't need to show it.
759
+ if ( field_idx_list . length === 1 ) {
760
+ displayedMessage = `${ dataFrame . fields [ field_idx_list [ 0 ] ] . values [ idx ] } ` ;
761
+ } else {
762
+ for ( const field_idx of field_idx_list ) {
763
+ displayedMessage += ` ${ dataFrame . fields [ field_idx ] . name } =${ dataFrame . fields [ field_idx ] . values [ idx ] } ` ;
764
+ }
765
+ }
766
+ displayedMessages [ idx ] = displayedMessage . trim ( ) ;
767
+ }
768
+
769
+ const newField = {
770
+ name : 'message' ,
771
+ type : FieldType . string ,
772
+ config : { } ,
773
+ values : displayedMessages ,
774
+ }
775
+ console . log ( 'newField' ) ;
776
+ dataFrame . fields = [ newField , ...dataFrame . fields ] ;
777
+ }
778
+
742
779
if ( ! dataLinks . length ) {
743
780
return ;
744
781
}
0 commit comments