mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 08:18:10 -05:00
Remove _source just for metrics, not logs
This commit is contained in:
@@ -417,7 +417,13 @@ export class ElasticResponse {
|
||||
if (response.hits && response.hits.hits.length > 0) {
|
||||
const { propNames, docs } = flattenHits(response.hits.hits);
|
||||
if (docs.length > 0) {
|
||||
const series = createEmptyDataFrame(propNames, this.targets[0].timeField, logMessageField, logLevelField);
|
||||
const series = createEmptyDataFrame(
|
||||
propNames,
|
||||
this.targets[0].timeField,
|
||||
isLogsRequest,
|
||||
logMessageField,
|
||||
logLevelField
|
||||
);
|
||||
|
||||
// Add a row for each document
|
||||
for (const doc of docs) {
|
||||
@@ -554,6 +560,7 @@ const flattenHits = (hits: Doc[]): { docs: Array<Record<string, any>>; propNames
|
||||
const createEmptyDataFrame = (
|
||||
propNames: string[],
|
||||
timeField: string,
|
||||
isLogsRequest: boolean,
|
||||
logMessageField?: string,
|
||||
logLevelField?: string
|
||||
): MutableDataFrame => {
|
||||
@@ -589,8 +596,8 @@ const createEmptyDataFrame = (
|
||||
if (fieldNames.includes(propName)) {
|
||||
continue;
|
||||
}
|
||||
// Do not add _source field as we are showing each _source field in table instead.
|
||||
if (propName === '_source') {
|
||||
// Do not add _source field (besides logs) as we are showing each _source field in table instead.
|
||||
if (!isLogsRequest && propName === '_source') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user