mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 15:36:48 +00:00
fix: pass metric name to get value suggestions api (#8671)
* fix: pass metric name to get value suggestions api * feat: add source to get value suggestions
This commit is contained in:
parent
6d97db1d9d
commit
3a952fa330
@ -8,14 +8,15 @@ import {
|
|||||||
export const getValueSuggestions = (
|
export const getValueSuggestions = (
|
||||||
props: QueryKeyValueRequestProps,
|
props: QueryKeyValueRequestProps,
|
||||||
): Promise<AxiosResponse<QueryKeyValueSuggestionsResponseProps>> => {
|
): Promise<AxiosResponse<QueryKeyValueSuggestionsResponseProps>> => {
|
||||||
const { signal, key, searchText, signalSource } = props;
|
const { signal, key, searchText, signalSource, metricName } = props;
|
||||||
|
|
||||||
const encodedSignal = encodeURIComponent(signal);
|
const encodedSignal = encodeURIComponent(signal);
|
||||||
const encodedKey = encodeURIComponent(key);
|
const encodedKey = encodeURIComponent(key);
|
||||||
|
const encodedMetricName = encodeURIComponent(metricName || '');
|
||||||
const encodedSearchText = encodeURIComponent(searchText);
|
const encodedSearchText = encodeURIComponent(searchText);
|
||||||
const encodedSource = encodeURIComponent(signalSource || '');
|
const encodedSource = encodeURIComponent(signalSource || '');
|
||||||
|
|
||||||
return axios.get(
|
return axios.get(
|
||||||
`/fields/values?signal=${encodedSignal}&name=${encodedKey}&searchText=${encodedSearchText}&source=${encodedSource}`,
|
`/fields/values?signal=${encodedSignal}&name=${encodedKey}&searchText=${encodedSearchText}&metricName=${encodedMetricName}&source=${encodedSource}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -383,6 +383,7 @@ function QuerySearch({
|
|||||||
searchText: sanitizedSearchText,
|
searchText: sanitizedSearchText,
|
||||||
signal: dataSource,
|
signal: dataSource,
|
||||||
signalSource: signalSource as 'meter' | '',
|
signalSource: signalSource as 'meter' | '',
|
||||||
|
metricName: debouncedMetricName ?? undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Skip updates if component unmounted or key changed
|
// Skip updates if component unmounted or key changed
|
||||||
@ -474,6 +475,7 @@ function QuerySearch({
|
|||||||
activeKey,
|
activeKey,
|
||||||
dataSource,
|
dataSource,
|
||||||
isLoadingSuggestions,
|
isLoadingSuggestions,
|
||||||
|
debouncedMetricName,
|
||||||
signalSource,
|
signalSource,
|
||||||
toggleSuggestions,
|
toggleSuggestions,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -10,6 +10,7 @@ export const useGetQueryKeyValueSuggestions = ({
|
|||||||
signal,
|
signal,
|
||||||
searchText,
|
searchText,
|
||||||
signalSource,
|
signalSource,
|
||||||
|
metricName,
|
||||||
}: {
|
}: {
|
||||||
key: string;
|
key: string;
|
||||||
signal: 'traces' | 'logs' | 'metrics';
|
signal: 'traces' | 'logs' | 'metrics';
|
||||||
@ -18,17 +19,26 @@ export const useGetQueryKeyValueSuggestions = ({
|
|||||||
options?: UseQueryOptions<
|
options?: UseQueryOptions<
|
||||||
SuccessResponse<QueryKeyValueSuggestionsResponseProps> | ErrorResponse
|
SuccessResponse<QueryKeyValueSuggestionsResponseProps> | ErrorResponse
|
||||||
>;
|
>;
|
||||||
|
metricName?: string;
|
||||||
}): UseQueryResult<
|
}): UseQueryResult<
|
||||||
AxiosResponse<QueryKeyValueSuggestionsResponseProps>,
|
AxiosResponse<QueryKeyValueSuggestionsResponseProps>,
|
||||||
AxiosError
|
AxiosError
|
||||||
> =>
|
> =>
|
||||||
useQuery<AxiosResponse<QueryKeyValueSuggestionsResponseProps>, AxiosError>({
|
useQuery<AxiosResponse<QueryKeyValueSuggestionsResponseProps>, AxiosError>({
|
||||||
queryKey: ['queryKeyValueSuggestions', key, signal, searchText, signalSource],
|
queryKey: [
|
||||||
|
'queryKeyValueSuggestions',
|
||||||
|
key,
|
||||||
|
signal,
|
||||||
|
searchText,
|
||||||
|
signalSource,
|
||||||
|
metricName,
|
||||||
|
],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
getValueSuggestions({
|
getValueSuggestions({
|
||||||
signal,
|
signal,
|
||||||
key,
|
key,
|
||||||
searchText: searchText || '',
|
searchText: searchText || '',
|
||||||
signalSource: signalSource as 'meter' | '',
|
signalSource: signalSource as 'meter' | '',
|
||||||
|
metricName: metricName || '',
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -46,6 +46,7 @@ export interface QueryKeyValueRequestProps {
|
|||||||
key: string;
|
key: string;
|
||||||
searchText: string;
|
searchText: string;
|
||||||
signalSource?: 'meter' | '';
|
signalSource?: 'meter' | '';
|
||||||
|
metricName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SignalType = 'traces' | 'logs' | 'metrics';
|
export type SignalType = 'traces' | 'logs' | 'metrics';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user