diff --git a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts index be014a298..4ab13b24d 100644 --- a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts +++ b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts @@ -11,6 +11,8 @@ import { useQueryState } from "../state/query/QueryStateContext"; import { useTimeState } from "../state/time/TimeStateContext"; import { useCustomPanelState } from "../state/customPanel/CustomPanelStateContext"; import { isHistogramData } from "../utils/metric"; +import { useGraphState } from "../state/graph/GraphStateContext"; +import { getStepFromDuration } from "../utils/time"; interface FetchQueryParams { predefinedQuery?: string[] @@ -57,6 +59,7 @@ export const useFetchQuery = ({ const { period } = useTimeState(); const { displayType, nocache, isTracingEnabled, seriesLimits: stateSeriesLimits } = useCustomPanelState(); const { serverUrl } = useAppState(); + const { isHistogram: isHistogramState } = useGraphState(); const [isLoading, setIsLoading] = useState(false); const [graphData, setGraphData] = useState(); @@ -69,6 +72,10 @@ export const useFetchQuery = ({ const [fetchQueue, setFetchQueue] = useState([]); const [isHistogram, setIsHistogram] = useState(false); + const defaultStep = useMemo(() => { + const { end, start } = period; + return getStepFromDuration(end - start, isHistogramState); + }, [period, isHistogramState]); const fetchData = async ({ fetchUrl, @@ -137,7 +144,7 @@ export const useFetchQuery = ({ setWarning(totalLength > seriesLimit ? limitText : ""); isDisplayChart ? setGraphData(tempData as MetricResult[]) : setLiveData(tempData as InstantMetricResult[]); setTraces(tempTraces); - setIsHistogram(totalLength ? isHistogramResult: false); + setIsHistogram(prev => totalLength ? isHistogramResult : prev); } catch (e) { if (e instanceof Error && e.name !== "AbortError") { setError(`${e.name}: ${e.message}`); @@ -197,5 +204,9 @@ export const useFetchQuery = ({ setFetchQueue(fetchQueue.filter(f => !f.signal.aborted)); }, [fetchQueue]); + useEffect(() => { + if (defaultStep === customStep) setGraphData([]); + }, [isHistogram]); + return { fetchUrl, isLoading, graphData, liveData, error, queryErrors, setQueryErrors, queryStats, warning, traces, isHistogram }; }; diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a378597c5..2ea5f281a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -41,6 +41,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components * FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): added ability to set, override and clear request and response headers on a per-user and per-path basis. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4825) and [these docs](https://docs.victoriametrics.com/vmauth.html#auth-config) for details. * BUGFIX: [Official Grafana dashboards for VictoriaMetrics](https://grafana.com/orgs/victoriametrics): fix display of ingested rows rate for `Samples ingested/s` and `Samples rate` panels for vmagent's dasbhoard. Previously, not all ingested protocols were accounted in these panels. An extra panel `Rows rate` was added to `Ingestion` section to display the split for rows ingested rate by protocol. +* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the bug causing render looping when switching to heatmap. ## [v1.93.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.3)