From 5ad7cca9d49ad22996ce1949902164f21e1d78e1 Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Fri, 27 Jan 2023 10:40:12 -0600 Subject: [PATCH] Prometheus: Fix "-Instant" string showing up in prometheus instant query UI (#62265) Add string constant and make sure to remove from name before outputting to frontend --- .../explore/PrometheusListView/ItemLabels.tsx | 12 +++++++++++- .../app/plugins/datasource/prometheus/datasource.tsx | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/public/app/features/explore/PrometheusListView/ItemLabels.tsx b/public/app/features/explore/PrometheusListView/ItemLabels.tsx index 40fb7ba9712..b5db12afe93 100644 --- a/public/app/features/explore/PrometheusListView/ItemLabels.tsx +++ b/public/app/features/explore/PrometheusListView/ItemLabels.tsx @@ -4,6 +4,8 @@ import React from 'react'; import { Field, GrafanaTheme2 } from '@grafana/data/'; import { useStyles2 } from '@grafana/ui/'; +import { InstantQueryRefIdIndex } from '../../../plugins/datasource/prometheus/datasource'; + import { rawListItemColumnWidth } from './RawListItem'; const getItemLabelsStyles = (theme: GrafanaTheme2, expanded: boolean) => { @@ -22,14 +24,22 @@ const getItemLabelsStyles = (theme: GrafanaTheme2, expanded: boolean) => { }; }; +const formatValueName = (name: string): string => { + if (name.includes(InstantQueryRefIdIndex)) { + return name.replace(InstantQueryRefIdIndex, ''); + } + return name; +}; + export const ItemLabels = ({ valueLabels, expanded }: { valueLabels: Field[]; expanded: boolean }) => { const styles = useStyles2((theme) => getItemLabelsStyles(theme, expanded)); + return (