From 80162146a02f3c6626aad0b4a1a4f5fa5f55f14a Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 5 May 2023 10:25:26 -0500 Subject: [PATCH] Correlations: Add links to prometheus dataframe where labels are split out (#67736) Add links to prometheus dataframe where labels are split out --- public/app/features/correlations/utils.ts | 11 ++++++++++- .../explore/PrometheusListView/ItemLabels.tsx | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/public/app/features/correlations/utils.ts b/public/app/features/correlations/utils.ts index 71f4f5732b9..1e363577ef1 100644 --- a/public/app/features/correlations/utils.ts +++ b/public/app/features/correlations/utils.ts @@ -1,5 +1,7 @@ import { DataFrame, DataLinkConfigOrigin } from '@grafana/data'; +import { formatValueName } from '../explore/PrometheusListView/ItemLabels'; + import { CorrelationData } from './useCorrelations'; type DataFrameRefIdToDataSourceUid = Record; @@ -21,7 +23,14 @@ export const attachCorrelationsToDataFrames = ( if (!frameRefId) { return; } - const dataSourceUid = dataFrameRefIdToDataSourceUid[frameRefId]; + let dataSourceUid = dataFrameRefIdToDataSourceUid[frameRefId]; + + // rawPrometheus queries append a value to refId to a separate dataframe for the table view + if (dataSourceUid === undefined && dataFrame.meta?.preferredVisualisationType === 'rawPrometheus') { + const formattedRefID = formatValueName(frameRefId); + dataSourceUid = dataFrameRefIdToDataSourceUid[formattedRefID]; + } + const sourceCorrelations = correlations.filter((correlation) => correlation.source.uid === dataSourceUid); decorateDataFrameWithInternalDataLinks(dataFrame, sourceCorrelations); }); diff --git a/public/app/features/explore/PrometheusListView/ItemLabels.tsx b/public/app/features/explore/PrometheusListView/ItemLabels.tsx index b5db12afe93..289de9e2994 100644 --- a/public/app/features/explore/PrometheusListView/ItemLabels.tsx +++ b/public/app/features/explore/PrometheusListView/ItemLabels.tsx @@ -24,7 +24,7 @@ const getItemLabelsStyles = (theme: GrafanaTheme2, expanded: boolean) => { }; }; -const formatValueName = (name: string): string => { +export const formatValueName = (name: string): string => { if (name.includes(InstantQueryRefIdIndex)) { return name.replace(InstantQueryRefIdIndex, ''); }