From 1e1952acf58cbdd7709b0370a0cbe4784b238c5a Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Wed, 6 Nov 2024 19:33:35 +0100 Subject: [PATCH] vmui/logs: add log sorting (#7344) ### Describe Your Changes add sorting of logs by groups and within each group by time in desc order. See #7184 and #7045 ### Checklist The following checks are **mandatory**: - [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). Co-authored-by: Aliaksandr Valialkin --- .../src/pages/ExploreLogs/GroupLogs/GroupLogs.tsx | 12 ++++++++---- docs/VictoriaLogs/CHANGELOG.md | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/vmui/packages/vmui/src/pages/ExploreLogs/GroupLogs/GroupLogs.tsx b/app/vmui/packages/vmui/src/pages/ExploreLogs/GroupLogs/GroupLogs.tsx index a73a5bbff..83b77ecb6 100644 --- a/app/vmui/packages/vmui/src/pages/ExploreLogs/GroupLogs/GroupLogs.tsx +++ b/app/vmui/packages/vmui/src/pages/ExploreLogs/GroupLogs/GroupLogs.tsx @@ -64,11 +64,15 @@ const GroupLogs: FC = ({ logs, settingsRef }) => { return groupByMultipleKeys(logs, [groupBy]).map((item) => { const streamValue = item.values[0]?.[groupBy] || ""; const pairs = getStreamPairs(streamValue); + // values sorting by time + const values = item.values.sort((a,b) => new Date(b._time).getTime() - new Date(a._time).getTime()); return { - ...item, + keys: item.keys, + keysString: item.keys.join(""), + values, pairs, }; - }); + }).sort((a, b) => a.keysString.localeCompare(b.keysString)); // groups sorting }, [logs, groupBy]); const handleClickByPair = (value: string) => async (e: MouseEvent) => { @@ -117,7 +121,7 @@ const GroupLogs: FC = ({ logs, settingsRef }) => { {groupData.map((item, i) => (
= ({ logs, settingsRef }) => { {item.pairs.map((pair) => (