From fbe83dd25e011fc6b8ec08f4c30b0f2f159ea191 Mon Sep 17 00:00:00 2001 From: Bhargav Date: Tue, 2 Jan 2024 13:24:37 +0530 Subject: [PATCH] fix: split histogram query on logs page (#2348) --- web/src/components/MenuLink.vue | 5 +++ web/src/composables/useLogs.ts | 55 ++++++++++++++++++++++++--- web/src/plugins/logs/Index.vue | 13 ++++++- web/src/plugins/logs/SearchBar.vue | 8 +++- web/src/plugins/logs/SearchResult.vue | 16 ++++++++ 5 files changed, 89 insertions(+), 8 deletions(-) diff --git a/web/src/components/MenuLink.vue b/web/src/components/MenuLink.vue index b7ae17fef6..edc900d920 100644 --- a/web/src/components/MenuLink.vue +++ b/web/src/components/MenuLink.vue @@ -34,6 +34,7 @@ along with this program. If not, see . 'ql-item-mini': mini, 'q-router-link--active': router.currentRoute.value.path.indexOf(link) == 0 && link != '/', + 'q-link-function': title == 'Functions', }" :target="target" @click="external ? openWebPage(link) : ''" @@ -154,4 +155,8 @@ export default defineComponent({ padding: 0; min-width: 40px; } + +.q-item--dark.q-link-function { + filter: brightness(100); +} diff --git a/web/src/composables/useLogs.ts b/web/src/composables/useLogs.ts index ff092a076d..a58ab0cf46 100644 --- a/web/src/composables/useLogs.ts +++ b/web/src/composables/useLogs.ts @@ -636,6 +636,8 @@ const useLogs = () => { } searchObj.data.errorCode = 0; + const histogramQueryReq = JSON.parse(JSON.stringify(queryReq)); + delete queryReq.aggs; searchService .search({ org_identifier: searchObj.organizationIdetifier, @@ -687,15 +689,14 @@ const useLogs = () => { //extract fields from query response extractFields(); - if (!isPagination) generateHistogramData(); - else { - searchObj.data.histogram.chartParams.title = - getHistogramTitle(); - } + searchObj.data.histogram.chartParams.title = getHistogramTitle(); //update grid columns updateGridColumns(); searchObj.loading = false; + if (histogramQueryReq.hasOwnProperty("aggs")) { + getHistogramQueryData(histogramQueryReq); + } resolve(true); }) .catch((err) => { @@ -729,6 +730,50 @@ const useLogs = () => { }); }; + const getHistogramQueryData = (queryReq: any) => { + return new Promise((resolve, reject) => { + const dismiss = () => {}; + try { + searchService + .search({ + org_identifier: searchObj.organizationIdetifier, + query: queryReq, + page_type: searchObj.data.stream.streamType, + }) + .then((res) => { + dismiss(); + searchObj.data.queryResults.aggs = res.data.aggs; + generateHistogramData(); + + searchObj.loading = false; + resolve(true); + }) + .catch((err) => { + searchObj.loading = false; + if (err.response != undefined) { + searchObj.data.errorMsg = err.response.data.error; + } else { + searchObj.data.errorMsg = err.message; + } + + const customMessage = logsErrorMessage(err?.response?.data.code); + searchObj.data.errorCode = err?.response?.data.code; + + if (customMessage != "") { + searchObj.data.errorMsg = t(customMessage); + } + + reject(false); + }); + } catch (e: any) { + dismiss(); + searchObj.loading = false; + showErrorNotification("Error while fetching histogram data"); + reject(false); + } + }); + }; + const updateFieldValues = () => { const excludedFields = [ store.state.zoConfig.timestamp_column, diff --git a/web/src/plugins/logs/Index.vue b/web/src/plugins/logs/Index.vue index 6abb88b43d..379b70b06e 100644 --- a/web/src/plugins/logs/Index.vue +++ b/web/src/plugins/logs/Index.vue @@ -180,7 +180,7 @@ along with this program. If not, see . " > diff --git a/web/src/plugins/logs/SearchBar.vue b/web/src/plugins/logs/SearchBar.vue index f5590257c2..1a16ac9415 100644 --- a/web/src/plugins/logs/SearchBar.vue +++ b/web/src/plugins/logs/SearchBar.vue @@ -120,7 +120,7 @@ color="grey" size="xs" /> :icon-right="'img:' + getImageURL('images/common/function.svg')" :title="t('search.savedViewsLabel')" split - class="no-outline saved-views-dropdown no-border" + class="no-outline saved-views-dropdown no-border btn-function" @click="fnSavedFunctionDialog" > @@ -1864,4 +1864,10 @@ export default defineComponent({ .saved-view-item { padding: 4px 5px !important; } + +.body--dark{ + .btn-function { + filter: brightness(100); + } +} diff --git a/web/src/plugins/logs/SearchResult.vue b/web/src/plugins/logs/SearchResult.vue index f4b18c34eb..dd58caa7eb 100644 --- a/web/src/plugins/logs/SearchResult.vue +++ b/web/src/plugins/logs/SearchResult.vue @@ -37,6 +37,22 @@ along with this program. If not, see . style="max-height: 100px" @updated:dataZoom="onChartUpdate" /> +
+ +