Skip to content

Commit

Permalink
Correlations: Add links to prometheus dataframe where labels are spli…
Browse files Browse the repository at this point in the history
…t out (#67736)

Add links to prometheus dataframe where labels are split out
  • Loading branch information
gelicia committed May 5, 2023
1 parent 15e3450 commit 8016214
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion 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<string, string>;
Expand All @@ -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);
});
Expand Down
Expand Up @@ -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, '');
}
Expand Down

0 comments on commit 8016214

Please sign in to comment.