mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
c006df375a
commit
5ad7cca9d4
@ -4,6 +4,8 @@ import React from 'react';
|
|||||||
import { Field, GrafanaTheme2 } from '@grafana/data/';
|
import { Field, GrafanaTheme2 } from '@grafana/data/';
|
||||||
import { useStyles2 } from '@grafana/ui/';
|
import { useStyles2 } from '@grafana/ui/';
|
||||||
|
|
||||||
|
import { InstantQueryRefIdIndex } from '../../../plugins/datasource/prometheus/datasource';
|
||||||
|
|
||||||
import { rawListItemColumnWidth } from './RawListItem';
|
import { rawListItemColumnWidth } from './RawListItem';
|
||||||
|
|
||||||
const getItemLabelsStyles = (theme: GrafanaTheme2, expanded: boolean) => {
|
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 }) => {
|
export const ItemLabels = ({ valueLabels, expanded }: { valueLabels: Field[]; expanded: boolean }) => {
|
||||||
const styles = useStyles2((theme) => getItemLabelsStyles(theme, expanded));
|
const styles = useStyles2((theme) => getItemLabelsStyles(theme, expanded));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.itemLabelsWrap}>
|
<div className={styles.itemLabelsWrap}>
|
||||||
<div className={styles.valueNavigationWrapper}>
|
<div className={styles.valueNavigationWrapper}>
|
||||||
{valueLabels.map((value, index) => (
|
{valueLabels.map((value, index) => (
|
||||||
<span className={styles.valueNavigation} key={value.name}>
|
<span className={styles.valueNavigation} key={value.name}>
|
||||||
{value.name}
|
{formatValueName(value.name)}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,6 +70,8 @@ import { PrometheusVariableSupport } from './variables';
|
|||||||
const ANNOTATION_QUERY_STEP_DEFAULT = '60s';
|
const ANNOTATION_QUERY_STEP_DEFAULT = '60s';
|
||||||
const GET_AND_POST_METADATA_ENDPOINTS = ['api/v1/query', 'api/v1/query_range', 'api/v1/series', 'api/v1/labels'];
|
const GET_AND_POST_METADATA_ENDPOINTS = ['api/v1/query', 'api/v1/query_range', 'api/v1/series', 'api/v1/labels'];
|
||||||
|
|
||||||
|
export const InstantQueryRefIdIndex = '-Instant';
|
||||||
|
|
||||||
export class PrometheusDatasource
|
export class PrometheusDatasource
|
||||||
extends DataSourceWithBackend<PromQuery, PromOptions>
|
extends DataSourceWithBackend<PromQuery, PromOptions>
|
||||||
implements DataSourceWithQueryImportSupport<PromQuery>, DataSourceWithQueryExportSupport<PromQuery>
|
implements DataSourceWithQueryImportSupport<PromQuery>, DataSourceWithQueryExportSupport<PromQuery>
|
||||||
@ -430,7 +432,7 @@ export class PrometheusDatasource
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
...processedTarget,
|
...processedTarget,
|
||||||
refId: processedTarget.refId + '-Instant',
|
refId: processedTarget.refId + InstantQueryRefIdIndex,
|
||||||
range: false,
|
range: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user