vmui: heatmap fixes (#4086)

* fix: correct display of errors for query

* fix: change the logic of histogram detection

* feat: hide empty buckets from the graph

* fix: revert server url
This commit is contained in:
Yury Molodov 2023-04-07 00:02:44 +02:00 committed by GitHub
parent ee80e71d17
commit 01fc228fb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -89,6 +89,7 @@ export const useFetchQuery = ({
const isHideQuery = hideQuery?.includes(counter - 1);
if (isHideQuery) {
setQueryErrors(prev => [...prev, ""]);
counter++;
continue;
}
@ -105,6 +106,7 @@ export const useFetchQuery = ({
}
const isHistogramResult = isDisplayChart && isHistogramData(resp.data.result);
if (resp.data.result.length) setIsHistogram(isHistogramResult);
if (isHistogramResult) seriesLimit = Infinity;
const freeTempSize = seriesLimit - tempData.length;
resp.data.result.slice(0, freeTempSize).forEach((d: MetricBase) => {
@ -122,8 +124,6 @@ export const useFetchQuery = ({
const limitText = `Showing ${seriesLimit} series out of ${totalLength} series due to performance reasons. Please narrow down the query, so it returns less series`;
setWarning(totalLength > seriesLimit ? limitText : "");
setIsHistogram(isDisplayChart && isHistogramData(tempData));
isDisplayChart ? setGraphData(tempData as MetricResult[]) : setLiveData(tempData as InstantMetricResult[]);
setTraces(tempTraces);
} catch (e) {

View file

@ -149,7 +149,7 @@ export const normalizeData = (buckets: MetricResult[], isHistogram?: boolean): M
const vmBuckets = convertPrometheusToVictoriaMetrics(sortedBuckets);
const allValues = vmBuckets.map(b => b.values).flat();
return vmBuckets.map(bucket => {
const result = vmBuckets.map(bucket => {
const values = bucket.values.map((v) => {
const totalHits = allValues
.filter(av => av[0] === v[0])
@ -160,4 +160,6 @@ export const normalizeData = (buckets: MetricResult[], isHistogram?: boolean): M
return { ...bucket, values };
}) as MetricResult[];
return result.filter(r => !r.values.every(v => v[1] === "0"));
};