@ -269,7 +269,7 @@ function separateLogsAndMetrics(dataFrames: DataFrame[]) {
const logSeries : DataFrame [ ] = [ ] ;
for ( const dataFrame of dataFrames ) {
if ( isLogsData ( dataFrame ) ) {
if ( isLogsData ( dataFrame ) || ! dataFrame . fields . length ) {
logSeries . push ( dataFrame ) ;
continue ;
}
@ -303,23 +303,29 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi
const allLabels : Labels [ ] = [ ] ;
// Find the fields we care about and collect all labels
const allSeries : LogFields [ ] = logSeries . map ( series = > {
const fieldCache = new FieldCache ( series ) ;
const stringField = fieldCache . getFirstFieldOfType ( FieldType . string ) ;
if ( stringField ? . labels ) {
allLabels . push ( stringField . labels ) ;
}
return {
series ,
timeField : fieldCache.getFirstFieldOfType ( FieldType . time ) ,
timeNanosecondField : fieldCache.hasFieldWithNameAndType ( 'tsNs' , FieldType . time )
? fieldCache . getFieldByName ( 'tsNs' )
: undefined ,
stringField ,
logLevelField : fieldCache.getFieldByName ( 'level' ) ,
idField : getIdField ( fieldCache ) ,
} as LogFields ;
} ) ;
let allSeries : LogFields [ ] = [ ] ;
if ( hasFields ( logSeries ) ) {
allSeries = logSeries . map ( series = > {
const fieldCache = new FieldCache ( series ) ;
const stringField = fieldCache . getFirstFieldOfType ( FieldType . string ) ;
if ( stringField ? . labels ) {
allLabels . push ( stringField . labels ) ;
}
return {
series ,
timeField : fieldCache.getFirstFieldOfType ( FieldType . time ) ,
timeNanosecondField : fieldCache.hasFieldWithNameAndType ( 'tsNs' , FieldType . time )
? fieldCache . getFieldByName ( 'tsNs' )
: undefined ,
stringField ,
logLevelField : fieldCache.getFieldByName ( 'level' ) ,
idField : getIdField ( fieldCache ) ,
} as LogFields ;
} ) ;
}
const commonLabels = allLabels . length > 0 ? findCommonLabels ( allLabels ) : { } ;
@ -445,6 +451,10 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi
} ;
}
function hasFields ( logSeries : DataFrame [ ] ) : boolean {
return logSeries . some ( series = > series . fields . length ) ;
}
function getIdField ( fieldCache : FieldCache ) : FieldWithIndex | undefined {
const idFieldNames = [ 'id' ] ;
for ( const fieldName of idFieldNames ) {