Correlations: Handle special field for loki labels (using data plane) (#94033)

Use dataplane data if available
This commit is contained in:
Kristina
2024-11-19 10:12:53 -06:00
committed by GitHub
parent f44bc2bfd8
commit 005de7db95
2 changed files with 15 additions and 1 deletions
@@ -19,11 +19,13 @@ import {
DataLinkPostProcessor, DataLinkPostProcessor,
ExploreUrlState, ExploreUrlState,
urlUtil, urlUtil,
DataFrameType,
} from '@grafana/data'; } from '@grafana/data';
import { getTemplateSrv, reportInteraction, VariableInterpolation } from '@grafana/runtime'; import { getTemplateSrv, reportInteraction, VariableInterpolation } from '@grafana/runtime';
import { DataQuery } from '@grafana/schema'; import { DataQuery } from '@grafana/schema';
import { contextSrv } from 'app/core/services/context_srv'; import { contextSrv } from 'app/core/services/context_srv';
import { getTransformationVars } from 'app/features/correlations/transformations'; import { getTransformationVars } from 'app/features/correlations/transformations';
import { parseDataplaneLogsFrame } from 'app/features/logs/logsFrame';
import { ExploreItemState } from 'app/types/explore'; import { ExploreItemState } from 'app/types/explore';
import { getLinkSrv } from '../../panel/panellinks/link_srv'; import { getLinkSrv } from '../../panel/panellinks/link_srv';
@@ -137,6 +139,18 @@ export const getFieldLinksForExplore = (options: {
text: 'Data', text: 'Data',
}; };
if (dataFrame.meta?.type === DataFrameType.LogLines) {
const dataPlane = parseDataplaneLogsFrame(dataFrame);
const labels = dataPlane?.getLogFrameLabels();
if (labels != null) {
Object.entries(labels[rowIndex]).forEach((value) => {
scopedVars[value[0]] = {
value: value[1],
};
});
}
}
dataFrame.fields.forEach((f) => { dataFrame.fields.forEach((f) => {
if (fieldDisplayValuesProxy && fieldDisplayValuesProxy[f.name]) { if (fieldDisplayValuesProxy && fieldDisplayValuesProxy[f.name]) {
scopedVars[f.name] = { scopedVars[f.name] = {
+1 -1
View File
@@ -45,7 +45,7 @@ export function logFrameLabelsToLabels(logFrameLabels: LogFrameLabels): Labels {
return result; return result;
} }
function parseDataplaneLogsFrame(frame: DataFrame): LogsFrame | null { export function parseDataplaneLogsFrame(frame: DataFrame): LogsFrame | null {
const cache = new FieldCache(frame); const cache = new FieldCache(frame);
const timestampField = getField(cache, DATAPLANE_TIMESTAMP_NAME, FieldType.time); const timestampField = getField(cache, DATAPLANE_TIMESTAMP_NAME, FieldType.time);