From a2bc287d937020876a98e6fe3d423e032ee5194e Mon Sep 17 00:00:00 2001 From: omkarK06 <127078473+omkarK06@users.noreply.github.com> Date: Mon, 5 Jun 2023 12:48:22 +0530 Subject: [PATCH] fix: fixed enrichment table query timeline (#896) 1. start time and end time in enrichment table query 2. #893 --- web/src/plugins/logs/Index.vue | 21 +++++++++++++++------ web/src/plugins/logs/IndexList.vue | 15 ++++++++++++--- web/src/plugins/logs/SearchResult.vue | 19 +++++++++++-------- web/src/plugins/traces/DetailTable.vue | 18 +++++++++++------- web/src/plugins/traces/Index.vue | 2 +- web/src/utils/zincutils.ts | 8 +++++++- 6 files changed, 57 insertions(+), 26 deletions(-) diff --git a/web/src/plugins/logs/Index.vue b/web/src/plugins/logs/Index.vue index f349613d66..19c45c10a4 100644 --- a/web/src/plugins/logs/Index.vue +++ b/web/src/plugins/logs/Index.vue @@ -212,7 +212,11 @@ import { import segment from "@/services/segment_analytics"; import config from "@/aws-exports"; import { logsErrorMessage } from "@/utils/common"; -import { verifyOrganizationStatus } from "@/utils/zincutils"; +import { + verifyOrganizationStatus, + convertTimeFromMicroToMilli, +} from "@/utils/zincutils"; +import { cloneDeep } from "lodash-es"; export default defineComponent({ name: "PageSearch", @@ -460,8 +464,16 @@ export default defineComponent({ ); if (stream.stats) { return { - start_time: new Date(stream.stats.doc_time_min), - end_time: new Date(stream.stats.doc_time_max), + start_time: new Date( + convertTimeFromMicroToMilli( + stream.stats.doc_time_min - 300000000 + ) + ), + end_time: new Date( + convertTimeFromMicroToMilli( + stream.stats.doc_time_max + 300000000 + ) + ), }; } } @@ -559,7 +571,6 @@ export default defineComponent({ }; var timestamps: any = getConsumableDateTime(); - if ( timestamps.start_time != "Invalid Date" && timestamps.end_time != "Invalid Date" @@ -829,7 +840,6 @@ export default defineComponent({ } else { searchObj.data.errorMsg = err.message; } - console.log(err.response); const customMessage = logsErrorMessage(err.response.data.code); searchObj.data.errorCode = err.response.data.code; if (customMessage != "") { @@ -1518,7 +1528,6 @@ export default defineComponent({ this.searchObj.loading = true; this.searchObj.data.errorMsg = ""; this.searchObj.data.stream.streamLists = []; - this.searchObj.data.stream.selectedStream = { label: "", value: "" }; this.searchObj.data.stream.selectedStreamFields = []; this.searchObj.data.queryResults = {}; this.searchObj.data.sortedQueryResults = []; diff --git a/web/src/plugins/logs/IndexList.vue b/web/src/plugins/logs/IndexList.vue index 98cc9a3a13..337a6e4beb 100644 --- a/web/src/plugins/logs/IndexList.vue +++ b/web/src/plugins/logs/IndexList.vue @@ -316,7 +316,11 @@ import { useStore } from "vuex"; import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; import useLogs from "../../composables/useLogs"; -import { b64EncodeUnicode, getImageURL } from "../../utils/zincutils"; +import { + b64EncodeUnicode, + getImageURL, + convertTimeFromMicroToMilli, +} from "../../utils/zincutils"; import streamService from "../../services/stream"; import { getConsumableDateTime } from "@/utils/commons"; import { Parser } from "node-sql-parser"; @@ -405,11 +409,16 @@ export default defineComponent({ ); if (stream.stats) { timestamps = { - start_time: new Date(stream.stats.doc_time_min), - end_time: new Date(stream.stats.doc_time_max), + start_time: new Date( + convertTimeFromMicroToMilli(stream.stats.doc_time_min - 300000000) + ), + end_time: new Date( + convertTimeFromMicroToMilli(stream.stats.doc_time_max + 300000000) + ), }; } } + const startISOTimestamp: any = new Date(timestamps.start_time.toISOString()).getTime() * 1000; const endISOTimestamp: any = diff --git a/web/src/plugins/logs/SearchResult.vue b/web/src/plugins/logs/SearchResult.vue index 3e2c7a9824..f7766e00d1 100644 --- a/web/src/plugins/logs/SearchResult.vue +++ b/web/src/plugins/logs/SearchResult.vue @@ -138,21 +138,24 @@ class="field_overlay" :title="row.name" > - - diff --git a/web/src/plugins/traces/DetailTable.vue b/web/src/plugins/traces/DetailTable.vue index 862f25acd9..d8a13d1f41 100644 --- a/web/src/plugins/traces/DetailTable.vue +++ b/web/src/plugins/traces/DetailTable.vue @@ -252,6 +252,7 @@ import { defineComponent, ref, onBeforeMount, onBeforeUnmount } from "vue"; import { useI18n } from "vue-i18n"; import { useRouter } from "vue-router"; import { getImageURL } from "../../utils/zincutils"; +import { useStore } from "vuex"; const defaultValue: any = () => { return { @@ -297,14 +298,8 @@ export default defineComponent({ // this.$emit("remove:searchterm", term); // } }, - searchTimeBoxed(rowData: any, size: number) { - this.$emit("search:timeboxed", { - key: rowData._timestamp, - size: size, - }); - }, }, - setup() { + setup(props, { emit }) { const { t } = useI18n(); const rowData: any = ref({}); const router = useRouter(); @@ -312,6 +307,7 @@ export default defineComponent({ const selectedRelativeValue = ref("10"); const recordSizeOptions: any = ref([10, 20, 50, 100, 200, 500, 1000]); const shouldWrapValues: any = ref(false); + const store = useStore(); onBeforeMount(() => { if (window.localStorage.getItem("wrap-log-details") === null) { @@ -345,6 +341,13 @@ export default defineComponent({ return newObj; }; + function searchTimeBoxed(rowData: any, size: number) { + emit("search:timeboxed", { + key: rowData[store.state.zoConfig.timestamp_column], + size: size, + }); + } + return { t, router, @@ -356,6 +359,7 @@ export default defineComponent({ getImageURL, shouldWrapValues, toggleWrapLogDetails, + searchTimeBoxed, }; }, async created() { diff --git a/web/src/plugins/traces/Index.vue b/web/src/plugins/traces/Index.vue index 3dc667b9cd..3672dc381e 100644 --- a/web/src/plugins/traces/Index.vue +++ b/web/src/plugins/traces/Index.vue @@ -483,7 +483,7 @@ export default defineComponent({ const getDefaultRequest = () => { return { query: { - sql: `select min(${store.state.zoConfig.timestamp_column}) as ${store.state.zoConfig.timestamp_column}, min(start_time) as start_time, service_name, operation_name, count(span_id) as spans, max(duration) as duration, trace_id [QUERY_FUNCTIONS] from "[INDEX_NAME]" [WHERE_CLAUSE] group by trace_id, service_name, operation_name`, + sql: `select min(${store.state.zoConfig.timestamp_column}) as ${store.state.zoConfig.timestamp_column}, min(start_time) as start_time, service_name, operation_name, count(span_id) as spans, max(duration) as duration, trace_id [QUERY_FUNCTIONS] from "[INDEX_NAME]" [WHERE_CLAUSE] group by trace_id, service_name, operation_name order by ${store.state.zoConfig.timestamp_column}`, start_time: (new Date().getTime() - 900000) * 1000, end_time: new Date().getTime() * 1000, from: 0, diff --git a/web/src/utils/zincutils.ts b/web/src/utils/zincutils.ts index 28d18f36cd..7983ce821c 100644 --- a/web/src/utils/zincutils.ts +++ b/web/src/utils/zincutils.ts @@ -259,7 +259,7 @@ export const getPath = () => { ? "/" : pos > -1 ? window.location.pathname.slice(0, pos + 5) - : window.location.pathname; + : window.location.pathname; const cloudPath = import.meta.env.BASE_URL; return config.isCloud == "true" ? cloudPath : path; }; @@ -313,3 +313,9 @@ export const verifyOrganizationStatus = (Organizations: any, Router: any) => { // } // } }; + +export const convertTimeFromMicroToMilli = (time: number) => { + const milliseconds = Math.floor(time / 1000); + const date = new Date(milliseconds); + return date.getTime(); +};