@@ -31,7 +31,7 @@ import {
3131 ViewPlugin ,
3232 ViewUpdate ,
3333} from '@codemirror/view' ;
34- import { PrometheusEndpoint } from '@openshift-console/dynamic-plugin-sdk' ;
34+ import { PrometheusEndpoint , useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk' ;
3535import {
3636 Button ,
3737 Form ,
@@ -51,7 +51,7 @@ import { useTranslation } from 'react-i18next';
5151
5252import { useSafeFetch } from '../console/utils/safe-fetch-hook' ;
5353
54- import { PROMETHEUS_BASE_PATH } from '../console/graphs/helpers' ;
54+ import { PROMETHEUS_BASE_PATH , PROMETHEUS_TENANCY_BASE_PATH } from '../console/graphs/helpers' ;
5555import { LabelNamesResponse } from '@perses-dev/prometheus-plugin' ;
5656import {
5757 t_global_color_status_custom_default ,
@@ -70,6 +70,7 @@ import {
7070 t_global_color_nonstatus_purple_default ,
7171} from '@patternfly/react-tokens' ;
7272import { usePatternFlyTheme } from '../hooks/usePatternflyTheme' ;
73+ import { usePerspective } from '../hooks/usePerspective' ;
7374
7475const box_shadow = `
7576 var(--pf-t--global--box-shadow--X--md--default)
@@ -334,15 +335,20 @@ export const PromQLExpressionInput: FC<PromQLExpressionInputProps> = ({
334335 const [ metricNames , setMetricNames ] = useState < Array < string > > ( [ ] ) ;
335336 const [ errorMessage , setErrorMessage ] = useState < string | undefined > ( ) ;
336337
338+ const { perspective } = usePerspective ( ) ;
337339 const placeholder = t ( 'Expression (press Shift+Enter for newlines)' ) ;
340+ const [ namespace ] = useActiveNamespace ( ) ;
338341
339342 // eslint-disable-next-line react-hooks/exhaustive-deps
340343 const safeFetch = useCallback ( useSafeFetch ( ) , [ ] ) ;
341344
342345 useEffect ( ( ) => {
343- safeFetch < LabelNamesResponse > (
344- `${ PROMETHEUS_BASE_PATH } /${ PrometheusEndpoint . LABEL } /__name__/values` ,
345- )
346+ let url = `${ PROMETHEUS_BASE_PATH } /${ PrometheusEndpoint . LABEL } /__name__/values` ;
347+ if ( perspective === 'dev' ) {
348+ // eslint-disable-next-line max-len
349+ url = `${ PROMETHEUS_TENANCY_BASE_PATH } /${ PrometheusEndpoint . LABEL } /__name__/values?namespace=${ namespace } ` ;
350+ }
351+ safeFetch < LabelNamesResponse > ( url )
346352 . then ( ( response ) => {
347353 const metrics = response ?. data ;
348354 setMetricNames ( metrics ) ;
@@ -356,7 +362,7 @@ export const PromQLExpressionInput: FC<PromQLExpressionInputProps> = ({
356362 setErrorMessage ( message ) ;
357363 }
358364 } ) ;
359- } , [ safeFetch , t ] ) ;
365+ } , [ safeFetch , t , namespace , perspective ] ) ;
360366
361367 const onClear = ( ) => {
362368 if ( viewRef . current !== null ) {
0 commit comments