From 77a70ef4fa39abae592cc20f13460d52cfc16bfb Mon Sep 17 00:00:00 2001 From: ktx-vaidehi <134508096+ktx-vaidehi@users.noreply.github.com> Date: Thu, 13 Mar 2025 21:43:05 +0530 Subject: [PATCH] fix: search type to lowercase (#6197) Co-authored-by: Taiming Liu Co-authored-by: Bhargav --- src/config/src/meta/self_reporting/usage.rs | 1 + src/handler/http/request/pipeline.rs | 2 +- src/service/alerts/scheduler/handlers.rs | 2 +- src/service/self_reporting/ingestion.rs | 29 ++++++++++--------- .../dashboards/visualize.spec.js | 1 + .../pipeline/NodeForm/PreviewPromqlQuery.vue | 2 +- .../components/pipeline/NodeForm/Query.vue | 2 +- web/src/components/queries/RunningQueries.vue | 6 ++-- .../dashboard/usePanelDataLoader.ts | 4 +-- web/src/composables/useLogs.ts | 8 ++--- web/src/plugins/logs/JsonPreview.vue | 2 +- web/src/plugins/logs/SearchBar.vue | 2 +- web/src/plugins/traces/Index.vue | 2 +- web/src/plugins/traces/TraceDetails.vue | 2 +- web/src/services/search.ts | 14 ++++----- .../views/Dashboards/addPanel/AddPanel.vue | 4 +-- web/src/views/StreamExplorer.vue | 2 +- 17 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/config/src/meta/self_reporting/usage.rs b/src/config/src/meta/self_reporting/usage.rs index 06bbb60bbb..f3b1c2c030 100644 --- a/src/config/src/meta/self_reporting/usage.rs +++ b/src/config/src/meta/self_reporting/usage.rs @@ -53,6 +53,7 @@ pub enum TriggerDataType { } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] pub struct TriggerData { pub _timestamp: i64, pub org: String, diff --git a/src/handler/http/request/pipeline.rs b/src/handler/http/request/pipeline.rs index 5524270c5a..a79eb8698b 100644 --- a/src/handler/http/request/pipeline.rs +++ b/src/handler/http/request/pipeline.rs @@ -60,7 +60,7 @@ pub async fn save_pipeline( ) -> Result { let org_id = path.into_inner(); let mut pipeline = pipeline.into_inner(); - pipeline.name = pipeline.name.trim().to_string(); + pipeline.name = pipeline.name.trim().to_lowercase(); pipeline.org = org_id; pipeline.id = ider::generate(); match pipeline::save_pipeline(pipeline).await { diff --git a/src/service/alerts/scheduler/handlers.rs b/src/service/alerts/scheduler/handlers.rs index 308fc2c898..49cc780a46 100644 --- a/src/service/alerts/scheduler/handlers.rs +++ b/src/service/alerts/scheduler/handlers.rs @@ -865,7 +865,7 @@ async fn handle_derived_stream_triggers( _timestamp: Utc::now().timestamp_micros(), org: new_trigger.org.clone(), module: TriggerDataType::DerivedStream, - key: new_trigger.module_key.clone(), + key: new_trigger.module_key.to_lowercase(), next_run_at: new_trigger.next_run_at, is_realtime: new_trigger.is_realtime, is_silenced: new_trigger.is_silenced, diff --git a/src/service/self_reporting/ingestion.rs b/src/service/self_reporting/ingestion.rs index a6d7836fab..b1147f8d65 100644 --- a/src/service/self_reporting/ingestion.rs +++ b/src/service/self_reporting/ingestion.rs @@ -28,7 +28,7 @@ use config::{ }, utils::json, }; -use hashbrown::HashMap; +use hashbrown::{HashMap, hash_map::Entry}; use proto::cluster_rpc; use crate::{common::meta::ingestion, service}; @@ -82,19 +82,20 @@ pub(super) async fn ingest_usages(mut curr_usages: Vec) { node, }; - let is_new = groups.contains_key(&key); - - let entry = groups.entry(key).or_insert_with(|| AggregatedData { - count: 1, - usage_data: usage_data.clone(), - }); - if !is_new { - continue; - } else { - entry.usage_data.num_records += usage_data.num_records; - entry.usage_data.size += usage_data.size; - entry.usage_data.response_time += usage_data.response_time; - entry.count += 1; + match groups.entry(key) { + Entry::Vacant(vacant) => { + vacant.insert(AggregatedData { + count: 1, + usage_data: usage_data.clone(), + }); + } + Entry::Occupied(mut occupied) => { + let entry = occupied.get_mut(); + entry.usage_data.num_records += usage_data.num_records; + entry.usage_data.size += usage_data.size; + entry.usage_data.response_time += usage_data.response_time; + entry.count += 1; + } } } diff --git a/tests/ui-testing/playwright-tests/dashboards/visualize.spec.js b/tests/ui-testing/playwright-tests/dashboards/visualize.spec.js index 70ebdd05e9..2d5d4f897b 100644 --- a/tests/ui-testing/playwright-tests/dashboards/visualize.spec.js +++ b/tests/ui-testing/playwright-tests/dashboards/visualize.spec.js @@ -30,6 +30,7 @@ const selectStreamAndStreamTypeForLogs = async (page, stream) => { await page .locator('[data-test="log-search-index-list-select-stream"]') .click({ force: true }); + await page.waitForTimeout(2000); await page .locator("div.q-item") .getByText(`${stream}`) diff --git a/web/src/components/pipeline/NodeForm/PreviewPromqlQuery.vue b/web/src/components/pipeline/NodeForm/PreviewPromqlQuery.vue index d5394bd77d..6a2541b477 100644 --- a/web/src/components/pipeline/NodeForm/PreviewPromqlQuery.vue +++ b/web/src/components/pipeline/NodeForm/PreviewPromqlQuery.vue @@ -21,7 +21,7 @@ along with this program. If not, see . :panelSchema="chartData" :selectedTimeObj="dashboardPanelData.meta.dateTime" :variablesData="{}" - searchType="UI" + searchType="ui" /> diff --git a/web/src/components/pipeline/NodeForm/Query.vue b/web/src/components/pipeline/NodeForm/Query.vue index bd297e4291..a96543dba9 100644 --- a/web/src/components/pipeline/NodeForm/Query.vue +++ b/web/src/components/pipeline/NodeForm/Query.vue @@ -389,7 +389,7 @@ const saveQueryData = async () => { promql_condition: null, aggregation: formData.query_condition.aggregation, vrl_function: null, - search_event_type: "DerivedStream", + search_event_type: "derivedstream", }, trigger_condition: { // same as before diff --git a/web/src/components/queries/RunningQueries.vue b/web/src/components/queries/RunningQueries.vue index 861f491c16..6d67d774a8 100644 --- a/web/src/components/queries/RunningQueries.vue +++ b/web/src/components/queries/RunningQueries.vue @@ -215,8 +215,8 @@ export default defineComponent({ const selectedQueryTypeTab = ref<"summary" | "all">("summary"); - const selectedSearchType = ref("Dashboards"); - const searchTypes = ["Dashboards", "UI", "Others"]; // UI, Dashboards, Reports, Alerts, Values, Other, RUM, DerivedStream, + const selectedSearchType = ref("dashboards"); + const searchTypes = ["dashboards", "ui", "Others"]; // UI, Dashboards, Reports, Alerts, Values, Other, RUM, DerivedStream, const runningQueryTypes = [ { label: "User Summary", value: "summary" }, @@ -642,7 +642,7 @@ export default defineComponent({ return { ...query, search_type_label: - query.search_type === "Dashboards" || query.search_type === "UI" + query.search_type === "dashboards" || query.search_type === "ui" ? query.search_type : "Others", }; diff --git a/web/src/composables/dashboard/usePanelDataLoader.ts b/web/src/composables/dashboard/usePanelDataLoader.ts index 706ab0656e..12fa502098 100644 --- a/web/src/composables/dashboard/usePanelDataLoader.ts +++ b/web/src/composables/dashboard/usePanelDataLoader.ts @@ -457,7 +457,7 @@ export const usePanelDataLoader = ( dashboard_id: dashboardId?.value, folder_id: folderId?.value, }, - searchType.value ?? "Dashboards", + searchType.value ?? "dashboards", ), abortControllerRef.signal, ); @@ -1098,7 +1098,7 @@ export const usePanelDataLoader = ( dashboard_id: dashboardId?.value, folder_id: folderId?.value, }, - searchType.value ?? "Dashboards", + searchType.value ?? "dashboards", ), abortControllerRef.signal, ); diff --git a/web/src/composables/useLogs.ts b/web/src/composables/useLogs.ts index 512e71fb59..705a96e460 100644 --- a/web/src/composables/useLogs.ts +++ b/web/src/composables/useLogs.ts @@ -1901,7 +1901,7 @@ const useLogs = () => { query: queryReq, page_type: searchObj.data.stream.streamType, }, - "UI", + "ui", ).then((res: any) => { $q.notify({ type: "positive", @@ -2091,7 +2091,7 @@ const useLogs = () => { page_type: searchObj.data.stream.streamType, traceparent, }, - "UI", + "ui", ) .then(async (res) => { // check for total records update for the partition and update pagination accordingly @@ -2261,7 +2261,7 @@ const useLogs = () => { page_type: searchObj.data.stream.streamType, traceparent, }, - "UI", + "ui", ) .then(async (res) => { if ( @@ -2583,7 +2583,7 @@ const useLogs = () => { page_type: searchObj.data.stream.streamType, traceparent, }, - "UI", + "ui", ) .then(async (res: any) => { removeTraceId(traceId); diff --git a/web/src/plugins/logs/JsonPreview.vue b/web/src/plugins/logs/JsonPreview.vue index e50fd9b84d..a35effccd4 100644 --- a/web/src/plugins/logs/JsonPreview.vue +++ b/web/src/plugins/logs/JsonPreview.vue @@ -417,7 +417,7 @@ export default { page_type: searchObj.data.stream.streamType, traceparent, }, - "UI", + "ui", ); unflattendData.value = res.data.hits[0]._original; } catch (err: any) { diff --git a/web/src/plugins/logs/SearchBar.vue b/web/src/plugins/logs/SearchBar.vue index f8b250bf4e..55c2b4aaee 100644 --- a/web/src/plugins/logs/SearchBar.vue +++ b/web/src/plugins/logs/SearchBar.vue @@ -1256,7 +1256,7 @@ export default defineComponent({ query: this.searchObj.data.customDownloadQueryObj, page_type: this.searchObj.data.stream.streamType, }, - "UI", + "ui", ) .then((res) => { this.customDownloadDialog = false; diff --git a/web/src/plugins/traces/Index.vue b/web/src/plugins/traces/Index.vue index 9c3d63552a..aa95038787 100644 --- a/web/src/plugins/traces/Index.vue +++ b/web/src/plugins/traces/Index.vue @@ -680,7 +680,7 @@ export default defineComponent({ query: req, page_type: "traces", }, - "UI" + "ui" ) .then((res) => { searchObj.data.traceDetails.spanList = res.data?.hits || []; diff --git a/web/src/plugins/traces/TraceDetails.vue b/web/src/plugins/traces/TraceDetails.vue index 17f1b4d59f..2a1df11516 100644 --- a/web/src/plugins/traces/TraceDetails.vue +++ b/web/src/plugins/traces/TraceDetails.vue @@ -700,7 +700,7 @@ export default defineComponent({ query: req, page_type: "traces", }, - "UI" + "ui" ) .then((res: any) => { if (!res.data?.hits?.length) { diff --git a/web/src/services/search.ts b/web/src/services/search.ts index cd0661b934..bc6c338aa2 100644 --- a/web/src/services/search.ts +++ b/web/src/services/search.ts @@ -34,7 +34,7 @@ const search = { dashboard_id?: string; folder_id?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -239,7 +239,7 @@ const search = { page_type: string; traceparent?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -259,7 +259,7 @@ const search = { jobId: string; traceparent?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -279,7 +279,7 @@ const search = { jobId: string; traceparent?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -299,7 +299,7 @@ const search = { jobId: string; traceparent?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -319,7 +319,7 @@ const search = { page_type: string; traceparent?: string; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const use_cache: boolean = @@ -343,7 +343,7 @@ const search = { traceparent?: string; query: any; }, - search_type: string = "UI", + search_type: string = "ui", ) => { if (!traceparent) traceparent = generateTraceContext()?.traceparent; const { size, from } = query.query; diff --git a/web/src/views/Dashboards/addPanel/AddPanel.vue b/web/src/views/Dashboards/addPanel/AddPanel.vue index a6948a548a..8ce4f2073a 100644 --- a/web/src/views/Dashboards/addPanel/AddPanel.vue +++ b/web/src/views/Dashboards/addPanel/AddPanel.vue @@ -265,7 +265,7 @@ along with this program. If not, see . @last-triggered-at-update=" handleLastTriggeredAtUpdate " - searchType="Dashboards" + searchType="dashboards" /> . @last-triggered-at-update=" handleLastTriggeredAtUpdate " - searchType="Dashboards" + searchType="dashboards" /> diff --git a/web/src/views/StreamExplorer.vue b/web/src/views/StreamExplorer.vue index 81c7cde0a8..8a99e2810c 100644 --- a/web/src/views/StreamExplorer.vue +++ b/web/src/views/StreamExplorer.vue @@ -175,7 +175,7 @@ export default defineComponent({ org_identifier: store.state.selectedOrganization.identifier, query: queryReq, page_type: streamData.value?.stream_type || "logs", - }, "UI") + }, "ui") .then((res) => { isLoading.value.pop(); if (res.data.from > 0) {