From 4c19bdf78ce4816d3117c5826ea30f7249549bcf Mon Sep 17 00:00:00 2001 From: Omkar Kesarkhane <127078473+omkarK06@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:38:36 +0530 Subject: [PATCH] fix: updated alerts preview and query validation time-range to 2mins (#4392) fixed #4389 Make wrap columns false by default #4344 ## Summary by CodeRabbit - **New Features** - Enhanced alert data retrieval to focus on the last 2 minutes instead of the last 15 minutes. - Improved refresh behavior for alerts, allowing for more frequent updates based on a new timing threshold. - **Bug Fixes** - Enhanced error handling in log management to prevent runtime exceptions when accessing potentially undefined properties. - Improved robustness in local storage handling to ensure reliable value assignments. - **Refactor** - Streamlined logic and data structures in various components for better clarity and maintainability. --- web/src/components/alerts/AddAlert.vue | 4 +++- web/src/components/alerts/PreviewAlert.vue | 6 +++--- web/src/composables/useLogs.ts | 2 +- web/src/plugins/logs/SearchBar.vue | 18 +++++++++++------- web/src/plugins/logs/TenstackTable.vue | 2 +- web/src/utils/zincutils.ts | 5 +++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/web/src/components/alerts/AddAlert.vue b/web/src/components/alerts/AddAlert.vue index 0860a20cd8..acf704a9f6 100644 --- a/web/src/components/alerts/AddAlert.vue +++ b/web/src/components/alerts/AddAlert.vue @@ -750,7 +750,6 @@ export default defineComponent({ isFetchingStreams.value = true; return getStreams(formData.value.stream_type, false) .then((res: any) => { - streams.value[formData.value.stream_type] = res.list; schemaList.value = res.list; indexOptions.value = res.list.map((data: any) => { @@ -1120,6 +1119,9 @@ export default defineComponent({ delete query.aggs; + // We get 15 minutes time range for the query, so reducing it by 13 minutes to get 2 minute data + query.query.start_time = query.query.start_time + 780000000; + query.query.sql = formData.value.query_condition.sql; if (formData.value.query_condition.vrl_function) diff --git a/web/src/components/alerts/PreviewAlert.vue b/web/src/components/alerts/PreviewAlert.vue index f2ac329ff5..97a4c318d2 100644 --- a/web/src/components/alerts/PreviewAlert.vue +++ b/web/src/components/alerts/PreviewAlert.vue @@ -165,8 +165,8 @@ const refreshData = () => { const relativeTime = props.formData.trigger_condition.period; const endTime = new Date().getTime() * 1000; - let new_relative_time = 5; - if (relativeTime < 5) { + let new_relative_time = 2; + if (relativeTime < 2) { new_relative_time = relativeTime; } @@ -241,7 +241,7 @@ defineExpose({ refreshData });