mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmui/logs: switched requests to sequential execution (#6624)
### Describe Your Changes This PR changes `/select/logsql/query` and `/select/logsql/hits` to execute sequentially Fixed https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6558#issuecomment-2219298984 ### Checklist The following checks are **mandatory**: - [x] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/).
This commit is contained in:
parent
cda6a31ae8
commit
efd70b2c52
3 changed files with 13 additions and 7 deletions
|
@ -48,9 +48,9 @@ const ExploreLogs: FC = () => {
|
||||||
|
|
||||||
const newPeriod = getPeriod();
|
const newPeriod = getPeriod();
|
||||||
setPeriod(newPeriod);
|
setPeriod(newPeriod);
|
||||||
fetchLogs(newPeriod);
|
fetchLogs(newPeriod).then((isSuccess) => {
|
||||||
fetchLogHits(newPeriod);
|
isSuccess && fetchLogHits(newPeriod);
|
||||||
|
}).catch(e => e);
|
||||||
setSearchParamsFromKeys( {
|
setSearchParamsFromKeys( {
|
||||||
query,
|
query,
|
||||||
"g0.range_input": duration,
|
"g0.range_input": duration,
|
||||||
|
@ -90,7 +90,7 @@ const ExploreLogs: FC = () => {
|
||||||
onRun={handleRunQuery}
|
onRun={handleRunQuery}
|
||||||
onChangeMarkdownParsing={handleChangeMarkdownParsing}
|
onChangeMarkdownParsing={handleChangeMarkdownParsing}
|
||||||
/>
|
/>
|
||||||
{isLoading && <Spinner />}
|
{isLoading && <Spinner message={"Loading logs..."}/>}
|
||||||
{error && <Alert variant="error">{error}</Alert>}
|
{error && <Alert variant="error">{error}</Alert>}
|
||||||
{!error && (
|
{!error && (
|
||||||
<ExploreLogsBarChart
|
<ExploreLogsBarChart
|
||||||
|
|
|
@ -57,7 +57,10 @@ const ExploreLogsBarChart: FC<Props> = ({ logHits, period, error, isLoading }) =
|
||||||
"vm-block_mobile": isMobile,
|
"vm-block_mobile": isMobile,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{isLoading && <Spinner containerStyles={{ position: "absolute" }}/>}
|
{isLoading && <Spinner
|
||||||
|
message={"Loading hits stats..."}
|
||||||
|
containerStyles={{ position: "absolute" }}
|
||||||
|
/>}
|
||||||
{!error && noDataMessage && (
|
{!error && noDataMessage && (
|
||||||
<div className="vm-explore-logs-chart__empty">
|
<div className="vm-explore-logs-chart__empty">
|
||||||
<Alert variant="info">{noDataMessage}</Alert>
|
<Alert variant="info">{noDataMessage}</Alert>
|
||||||
|
|
|
@ -52,20 +52,23 @@ export const useFetchLogs = (server: string, query: string, limit: number) => {
|
||||||
setError(text);
|
setError(text);
|
||||||
setLogs([]);
|
setLogs([]);
|
||||||
setIsLoading(prev => ({ ...prev, [id]: false }));
|
setIsLoading(prev => ({ ...prev, [id]: false }));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lines = text.split("\n").filter(line => line).slice(0, limit);
|
const lines = text.split("\n").filter(line => line).slice(0, limit);
|
||||||
const data = lines.map(parseLineToJSON).filter(line => line) as Logs[];
|
const data = lines.map(parseLineToJSON).filter(line => line) as Logs[];
|
||||||
setLogs(data);
|
setLogs(data);
|
||||||
|
setIsLoading(prev => ({ ...prev, [id]: false }));
|
||||||
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
setIsLoading(prev => ({ ...prev, [id]: false }));
|
||||||
if (e instanceof Error && e.name !== "AbortError") {
|
if (e instanceof Error && e.name !== "AbortError") {
|
||||||
setError(String(e));
|
setError(String(e));
|
||||||
console.error(e);
|
console.error(e);
|
||||||
setLogs([]);
|
setLogs([]);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
setIsLoading(prev => ({ ...prev, [id]: false }));
|
|
||||||
}, [url, query, limit]);
|
}, [url, query, limit]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue