mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: show meta data when available (#25798)
* Return valid metadata even if data is empty * Make sure fields is not accessed when there is no data * Meta Info should depend only on meta data * Refactor condition for better reading * Change data to empty array for better condition handling * Remove unecessary checks * Add test for showing metaData even when data is empty
This commit is contained in:
@@ -312,22 +312,36 @@ export function lokiStreamsToDataframes(
|
||||
lokiQueryStatKey: 'Summary: total bytes processed',
|
||||
};
|
||||
|
||||
const meta: QueryResultMeta = {
|
||||
searchWords: getHighlighterExpressionsFromQuery(formatQuery(target.expr)),
|
||||
limit,
|
||||
stats,
|
||||
custom,
|
||||
preferredVisualisationType: 'logs',
|
||||
};
|
||||
|
||||
const series: DataFrame[] = data.map(stream => {
|
||||
const dataFrame = lokiStreamResultToDataFrame(stream, reverse);
|
||||
enhanceDataFrame(dataFrame, config);
|
||||
|
||||
return {
|
||||
...dataFrame,
|
||||
refId: target.refId,
|
||||
meta: {
|
||||
searchWords: getHighlighterExpressionsFromQuery(formatQuery(target.expr)),
|
||||
limit,
|
||||
stats,
|
||||
custom,
|
||||
preferredVisualisationType: 'logs',
|
||||
},
|
||||
meta,
|
||||
};
|
||||
});
|
||||
|
||||
if (stats.length && !data.length) {
|
||||
return [
|
||||
{
|
||||
fields: [],
|
||||
length: 0,
|
||||
refId: target.refId,
|
||||
meta,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user