fix: change the logic for hide query (#3514)

This commit is contained in:
Yury Molodov 2022-12-20 23:29:46 +01:00 committed by Aliaksandr Valialkin
parent decf46d72b
commit 88f408941c
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 12 additions and 7 deletions

View file

@ -37,6 +37,7 @@ interface FetchDataParams {
query: string[],
stateSeriesLimits: SeriesLimits,
showAllSeries?: boolean,
hideQuery?: number[]
}
export const useFetchQuery = ({
@ -75,6 +76,7 @@ export const useFetchQuery = ({
query,
stateSeriesLimits,
showAllSeries,
hideQuery,
}: FetchDataParams) => {
const controller = new AbortController();
setFetchQueue([...fetchQueue, controller]);
@ -87,6 +89,13 @@ export const useFetchQuery = ({
let totalLength = 0;
for await (const url of fetchUrl) {
const isHideQuery = hideQuery?.includes(counter - 1);
if (isHideQuery) {
counter++;
continue;
}
const response = await fetch(url, { signal: controller.signal });
const resp = await response.json();
@ -126,12 +135,6 @@ export const useFetchQuery = ({
const throttledFetchData = useCallback(debounce(fetchData, 800), []);
const filterExpr = (q: string, i: number) => {
const byQuery = q.trim();
const byHideQuery = hideQuery ? !hideQuery.includes(i) : true;
return byQuery && byHideQuery;
};
const fetchUrl = useMemo(() => {
const expr = predefinedQuery ?? query;
const displayChart = (display || displayType) === "chart";
@ -143,7 +146,7 @@ export const useFetchQuery = ({
} else if (isValidHttpUrl(serverUrl)) {
const updatedPeriod = { ...period };
updatedPeriod.step = customStep;
return expr.filter(filterExpr).map(q => displayChart
return expr.map(q => displayChart
? getQueryRangeUrl(serverUrl, q, updatedPeriod, nocache, isTracingEnabled)
: getQueryUrl(serverUrl, q, updatedPeriod, isTracingEnabled));
} else {
@ -163,6 +166,7 @@ export const useFetchQuery = ({
query: expr,
stateSeriesLimits,
showAllSeries,
hideQuery,
});
}, [fetchUrl, visible, stateSeriesLimits, showAllSeries]);

View file

@ -20,6 +20,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
* BUGFIX: fix `error when searching for TSIDs by metricIDs in the previous indexdb: EOF` error, which can occur during queries after unclean shutdown of VictoriaMetrics (e.g. via hardware reset, out of memory crash or `kill -9`). The error has been introduced in [v1.85.2](https://docs.victoriametrics.com/CHANGELOG.html#v1852). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3515).
* BUGFIX: [VictoriaMetrics enterprise](https://docs.victoriametrics.com/enterprise.html): expose proper values for `vm_downsampling_partitions_scheduled` and `vm_downsampling_partitions_scheduled_size_bytes` metrics, which were added at [v1.78.0](https://docs.victoriametrics.com/CHANGELOG.html#v1780). See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2612).
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): never extend explicitly set lookbehind window for [rate()](https://docs.victoriametrics.com/MetricsQL.html#rate) function. This reduces the level of confusion when the user expects the needed results after explicitly seting the lookbehind window `[d]` in the query `rate(m[d])`. Previously VictoriaMetrics could silently extend the lookbehind window, so it covers at least two raw samples. Now this behavior works only if the lookbehind window in square brackets isn't set explicitly, e.g. in the case of `rate(m)`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3483) for details.
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the wrong legend when queries are hidden. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3512).
## [v1.85.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.2)