fix: search history should not contain the search related to usage org (#4673)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced search history functionality with organization-specific
filtering.
- Added a warning message for potential delays in search history
retrieval.
- Introduced new configuration fields for usage tracking in the health
status response.

- **Bug Fixes**
	- Improved error handling for search functions, enhancing traceability.

- **Chores**
- Updated the configuration management and health monitoring
capabilities for better system oversight.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Sai Nikhil <nikhil@openobserve.ai>
This commit is contained in:
Subhra264
2024-10-01 15:38:00 +05:30
committed by GitHub
co-authored by Sai Nikhil
parent 760bd819c8
commit 69f16dae32
3 changed files with 33 additions and 6 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ use config::{
search::{SearchEventType, SearchHistoryHitResponse},
sql::resolve_stream_names,
stream::StreamType,
usage::{RequestStats, UsageType},
usage::{RequestStats, UsageType, USAGE_STREAM},
},
metrics,
utils::{base64, json},
@@ -1486,7 +1486,7 @@ pub async fn search_history(
req.user_email = user_id.clone();
// Search
let stream_name = "usage";
let stream_name = USAGE_STREAM;
let search_query_req = match req.to_query_req(stream_name, &cfg.common.column_timestamp) {
Ok(r) => r,
Err(e) => {
@@ -1522,7 +1522,7 @@ pub async fn search_history(
.with_label_values(&[&org_id])
.dec();
let history_org_id = "_meta";
let history_org_id = &cfg.common.usage_org;
let stream_type = StreamType::Logs;
let search_res = SearchService::search(
&trace_id,
@@ -1612,7 +1612,7 @@ pub async fn search_history(
let num_fn = search_query_req.query.query_fn.is_some() as u16;
report_request_usage_stats(
req_stats,
&org_id,
history_org_id,
stream_name,
StreamType::Logs,
UsageType::SearchHistory,
+4
View File
@@ -110,6 +110,8 @@ struct ConfigResponse<'a> {
quick_mode_enabled: bool,
user_defined_schemas_enabled: bool,
all_fields_name: String,
usage_enabled: bool,
usage_publish_interval: i64,
}
#[derive(Serialize)]
@@ -267,6 +269,8 @@ pub async fn zo_config() -> Result<HttpResponse, Error> {
quick_mode_enabled: cfg.limit.quick_mode_enabled,
user_defined_schemas_enabled: cfg.common.allow_user_defined_schemas,
all_fields_name: cfg.common.column_all.to_string(),
usage_enabled: cfg.common.usage_enabled,
usage_publish_interval: cfg.common.usage_publish_interval,
}))
}
+25 -2
View File
@@ -18,6 +18,12 @@
</div>
</div>
<div class="flex items-center q-py-sm q-pr-md">
<div class="warning-text flex items-center q-py-xs q-px-sm q-mr-md ">
<q-icon name="info" class="q-mr-xs " size="16px" />
<div>
Search History might be delayed by <b> {{ delayMessage }}</b>
</div>
</div>
<date-time
data-test-name="search-history-date-time"
ref="searchDateTimeRef"
@@ -98,7 +104,8 @@
</div>
</q-td>
</q-tr>
</template>
</template>
</q-table>
@@ -122,7 +129,7 @@
</template>
<script lang="ts">
//@ts-nocheck
import { ref, watch, onMounted , nextTick} from 'vue';
import { ref, watch, onMounted , nextTick,computed} from 'vue';
import {
timestampToTimezoneDate , b64EncodeUnicode,convertDateToTimestamp } from "@/utils/zincutils";
import { useRouter, useRoute } from 'vue-router';
@@ -270,6 +277,16 @@
});
});
}
const delayMessage = computed (() => {
const delay = store.state.zoConfig.usage_publish_interval;
if (delay <= 60) {
return '60 seconds';
} else {
const minutes = Math.floor(delay / 60);
return `${minutes} minute(s)`;
}
});
const updateDateTime = async (value: any) => {
const {startTime, endTime} = value;
@@ -407,6 +424,7 @@
triggerExpand,
copyToClipboard,
formatTime,
delayMessage,
};
// Watch the searchObj for changes
@@ -438,6 +456,11 @@
.custom-table .q-tr > .q-td:first-child {
text-align: left;
}
.warning-text {
color: #F5A623;
border: 1px solid #F5A623;
border-radius: 2px ;
}
</style>