diff --git a/public/app/features/explore/utils/links.ts b/public/app/features/explore/utils/links.ts index e36ba898134..f837c36a2fb 100644 --- a/public/app/features/explore/utils/links.ts +++ b/public/app/features/explore/utils/links.ts @@ -19,11 +19,13 @@ import { DataLinkPostProcessor, ExploreUrlState, urlUtil, + DataFrameType, } from '@grafana/data'; import { getTemplateSrv, reportInteraction, VariableInterpolation } from '@grafana/runtime'; import { DataQuery } from '@grafana/schema'; import { contextSrv } from 'app/core/services/context_srv'; import { getTransformationVars } from 'app/features/correlations/transformations'; +import { parseDataplaneLogsFrame } from 'app/features/logs/logsFrame'; import { ExploreItemState } from 'app/types/explore'; import { getLinkSrv } from '../../panel/panellinks/link_srv'; @@ -137,6 +139,18 @@ export const getFieldLinksForExplore = (options: { 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) => { if (fieldDisplayValuesProxy && fieldDisplayValuesProxy[f.name]) { scopedVars[f.name] = { diff --git a/public/app/features/logs/logsFrame.ts b/public/app/features/logs/logsFrame.ts index 513f56a3e1e..c8e00f96319 100644 --- a/public/app/features/logs/logsFrame.ts +++ b/public/app/features/logs/logsFrame.ts @@ -45,7 +45,7 @@ export function logFrameLabelsToLabels(logFrameLabels: LogFrameLabels): Labels { return result; } -function parseDataplaneLogsFrame(frame: DataFrame): LogsFrame | null { +export function parseDataplaneLogsFrame(frame: DataFrame): LogsFrame | null { const cache = new FieldCache(frame); const timestampField = getField(cache, DATAPLANE_TIMESTAMP_NAME, FieldType.time);