vmui/logs: change time range to start and end query args (#6296)

change time range limitation from `_time` in the expression to `start`
and `end` query args.
This commit is contained in:
Yury Molodov 2024-05-20 14:13:15 +02:00 committed by GitHub
parent 7ce052b32d
commit a6a599cbdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 14 deletions

View file

@ -13,27 +13,18 @@ export const useFetchLogs = (server: string, query: string, limit: number) => {
const url = useMemo(() => getLogsUrl(server), [server]);
// include time range in query if not already present
const queryWithTime = useMemo(() => {
if (!/_time/.test(query)) {
const start = dayjs(period.start * 1000).tz().toISOString();
const end = dayjs(period.end * 1000).tz().toISOString();
const timerange = `_time:[${start}, ${end}]`;
return `${timerange} AND (${query})`;
}
return query;
}, [query, period]);
const options = useMemo(() => ({
method: "POST",
headers: {
"Accept": "application/stream+json",
},
body: new URLSearchParams({
query: queryWithTime.trim(),
limit: `${limit}`
query: query.trim(),
limit: `${limit}`,
start: dayjs(period.start * 1000).tz().toISOString(),
end: dayjs(period.end * 1000).tz().toISOString()
})
}), [queryWithTime, limit]);
}), [query, limit, period]);
const parseLineToJSON = (line: string): Logs | null => {
try {

View file

@ -19,6 +19,8 @@ according to [these docs](https://docs.victoriametrics.com/VictoriaLogs/QuickSta
## tip
* FEATURE: [web UI](https://docs.victoriametrics.com/VictoriaLogs/querying/#web-ui): change time range limitation from `_time` in the expression to `start` and `end` query args.
## [v0.8.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v0.8.0-victorialogs)
Released at 2024-05-20