mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
vmui: fix rendering of raw data on the graph
This commit is contained in:
parent
449e2ead43
commit
843d363d09
6 changed files with 47 additions and 20 deletions
|
@ -15,7 +15,7 @@ export interface InstantMetricResult extends MetricBase {
|
||||||
values?: [number, string][]
|
values?: [number, string][]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RawMetricResult extends MetricBase {
|
export interface ExportMetricResult extends MetricBase {
|
||||||
values: number[];
|
values: number[];
|
||||||
timestamps: number[];
|
timestamps: number[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ const GraphView: FC<GraphViewProps> = ({
|
||||||
if (isAnomalyView) {
|
if (isAnomalyView) {
|
||||||
setHideSeries(legend.map(s => s.label || "").slice(1));
|
setHideSeries(legend.map(s => s.label || "").slice(1));
|
||||||
}
|
}
|
||||||
}, [data, timezone, isHistogram]);
|
}, [data, timezone, isHistogram, currentStep]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const tempLegend: LegendItemType[] = [];
|
const tempLegend: LegendItemType[] = [];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useRef, useState } from "preact/compat";
|
import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useRef, useState } from "preact/compat";
|
||||||
import { MetricBase, MetricResult, RawMetricResult } from "../../../api/types";
|
import { MetricBase, MetricResult, ExportMetricResult } from "../../../api/types";
|
||||||
import { ErrorTypes, SeriesLimits } from "../../../types";
|
import { ErrorTypes, SeriesLimits } from "../../../types";
|
||||||
import { useQueryState } from "../../../state/query/QueryStateContext";
|
import { useQueryState } from "../../../state/query/QueryStateContext";
|
||||||
import { useTimeState } from "../../../state/time/TimeStateContext";
|
import { useTimeState } from "../../../state/time/TimeStateContext";
|
||||||
|
@ -24,7 +24,7 @@ interface FetchQueryReturn {
|
||||||
abortFetch: () => void
|
abortFetch: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseLineToJSON = (line: string): RawMetricResult | null => {
|
const parseLineToJSON = (line: string): ExportMetricResult | null => {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(line);
|
return JSON.parse(line);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -74,6 +74,7 @@ export const useFetchExport = ({ hideQuery, showAllSeries }: FetchQueryParams):
|
||||||
try {
|
try {
|
||||||
const tempData: MetricBase[] = [];
|
const tempData: MetricBase[] = [];
|
||||||
const seriesLimit = showAllSeries ? Infinity : +stateSeriesLimits[displayType] || Infinity;
|
const seriesLimit = showAllSeries ? Infinity : +stateSeriesLimits[displayType] || Infinity;
|
||||||
|
console.log(+stateSeriesLimits[displayType]);
|
||||||
let counter = 1;
|
let counter = 1;
|
||||||
let totalLength = 0;
|
let totalLength = 0;
|
||||||
|
|
||||||
|
@ -97,14 +98,16 @@ export const useFetchExport = ({ hideQuery, showAllSeries }: FetchQueryParams):
|
||||||
setQueryErrors(prev => [...prev, ""]);
|
setQueryErrors(prev => [...prev, ""]);
|
||||||
const freeTempSize = seriesLimit - tempData.length;
|
const freeTempSize = seriesLimit - tempData.length;
|
||||||
const lines = text.split("\n").filter(line => line);
|
const lines = text.split("\n").filter(line => line);
|
||||||
const linesLimited = lines.slice(0, freeTempSize);
|
const lineLimited = lines.slice(0, freeTempSize).sort();
|
||||||
const responseData = linesLimited.map(parseLineToJSON).filter(line => line) as RawMetricResult[];
|
lineLimited.forEach((line: string) => {
|
||||||
const metricResult = responseData.map((d: RawMetricResult) => ({
|
const jsonLine = parseLineToJSON(line);
|
||||||
group: counter,
|
if (!jsonLine) return;
|
||||||
metric: d.metric,
|
tempData.push({
|
||||||
values: d.values.map((value, index) => [(d.timestamps[index]/1000), value]),
|
group: counter,
|
||||||
}));
|
metric: jsonLine.metric,
|
||||||
tempData.push(...metricResult);
|
values: jsonLine.values.map((value, index) => [(jsonLine.timestamps[index]/1000), value]),
|
||||||
|
} as MetricBase);
|
||||||
|
});
|
||||||
totalLength += lines.length;
|
totalLength += lines.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +133,11 @@ export const useFetchExport = ({ hideQuery, showAllSeries }: FetchQueryParams):
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetchUrl?.length) return;
|
if (!fetchUrl?.length) return;
|
||||||
fetchData({
|
const timer = setTimeout(fetchData, 400, { fetchUrl, stateSeriesLimits, showAllSeries });
|
||||||
fetchUrl,
|
return () => {
|
||||||
stateSeriesLimits,
|
abortControllerRef.current?.abort();
|
||||||
showAllSeries,
|
clearTimeout(timer);
|
||||||
});
|
};
|
||||||
return () => abortControllerRef.current?.abort();
|
|
||||||
}, [fetchUrl, stateSeriesLimits, showAllSeries]);
|
}, [fetchUrl, stateSeriesLimits, showAllSeries]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -81,9 +81,13 @@ const RawQueryPage: FC = () => {
|
||||||
<div className="vm-explore-metrics-header-description">
|
<div className="vm-explore-metrics-header-description">
|
||||||
<p>
|
<p>
|
||||||
This page provides a dedicated view for querying and displaying raw data directly from VictoriaMetrics.
|
This page provides a dedicated view for querying and displaying raw data directly from VictoriaMetrics.
|
||||||
Users often assume that the <Hyperlink href="https://docs.victoriametrics.com/keyconcepts/#query-data">Query
|
Users often assume that the <Hyperlink
|
||||||
|
underlined
|
||||||
|
href="https://docs.victoriametrics.com/keyconcepts/#query-data"
|
||||||
|
>Query
|
||||||
API</Hyperlink> returns data exactly as stored, but data samples and timestamps may be modified by the API.
|
API</Hyperlink> returns data exactly as stored, but data samples and timestamps may be modified by the API.
|
||||||
For more details, see <Hyperlink
|
For more details, see <Hyperlink
|
||||||
|
underlined
|
||||||
href="https://docs.victoriametrics.com/single-server-victoriametrics/#how-to-export-data-in-json-line-format"
|
href="https://docs.victoriametrics.com/single-server-victoriametrics/#how-to-export-data-in-json-line-format"
|
||||||
>How
|
>How
|
||||||
to export data in JSON line format</Hyperlink>
|
to export data in JSON line format</Hyperlink>
|
||||||
|
|
|
@ -185,7 +185,27 @@ const getPointsSeries = (metricInfo: ForecastMetricInfo | null): uPlotSeries.Poi
|
||||||
if (isAnomalyMetric) {
|
if (isAnomalyMetric) {
|
||||||
return { size: 8, width: 4, space: 0 };
|
return { size: 8, width: 4, space: 0 };
|
||||||
}
|
}
|
||||||
return { size: 4.2, width: 1.4 };
|
return {
|
||||||
|
size: 4,
|
||||||
|
width: 0,
|
||||||
|
show: true,
|
||||||
|
filter: filterPoints,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const filterPoints = (self: uPlot, seriesIdx: number): number[] | null => {
|
||||||
|
const data = self.data[seriesIdx];
|
||||||
|
const indices = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
const prev = data[i - 1];
|
||||||
|
const next = data[i + 1];
|
||||||
|
if (prev === null && next === null) {
|
||||||
|
indices.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return indices.length > 0 ? indices : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GetStrokeSeriesArgs = {
|
type GetStrokeSeriesArgs = {
|
||||||
|
|
|
@ -27,6 +27,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/).
|
||||||
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert): properly set `group_name` and `file` fields for recording rules in `/api/v1/rules`.
|
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert): properly set `group_name` and `file` fields for recording rules in `/api/v1/rules`.
|
||||||
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmstorage` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): prevent panic when ingesting samples which are outisde of configured [retention filters](https://docs.victoriametrics.com/#retention-filters). This could happen when backfilling data with retention filters which exclude samples from the backfill range.
|
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmstorage` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): prevent panic when ingesting samples which are outisde of configured [retention filters](https://docs.victoriametrics.com/#retention-filters). This could happen when backfilling data with retention filters which exclude samples from the backfill range.
|
||||||
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl/): fix issue with series matching for `vmctl vm-native` with `--vm-native-disable-per-metric-migration` flag enabled. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7309).
|
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl/): fix issue with series matching for `vmctl vm-native` with `--vm-native-disable-per-metric-migration` flag enabled. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7309).
|
||||||
|
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix rendering of isolated data points on the graph that are not connected to other points.
|
||||||
|
|
||||||
## [v1.105.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.105.0)
|
## [v1.105.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.105.0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue