Skip to content

Commit

Permalink
[8.15] [Uptime] Remove unnecessary queries !! (#191722) (#192087)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.15`:
- [[Uptime] Remove unnecessary queries !!
(#191722)](#191722)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-04T13:37:51Z","message":"[Uptime]
Remove unnecessary queries !! (#191722)\n\n## Summary\r\n\r\nWe added
these clauses 4 years ago in a follow up
to\r\nhttps://github.com/elastic/beats/pull/14778 !!\r\n\r\nSince
monitor.timespan is now always present in docs , we don't need\r\nthese
queries !!\r\n\r\nI found these sometimes to be very slow while
investigating slow\r\nperformance of queries in a trace !!\r\n\r\n###
Autorefresh interval !!\r\n\r\nAlso updated auto refresh interval to 5
minutes, based on multiple\r\ncustomers feedback, default 1 minute is
too aggressive
!!","sha":"e88499a27c7ae1ec668d6b4fe0e11ce9a487d0be","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"title":"[Uptime]
Remove unnecessary queries
!!","number":191722,"url":"https://github.com/elastic/kibana/pull/191722","mergeCommit":{"message":"[Uptime]
Remove unnecessary queries !! (#191722)\n\n## Summary\r\n\r\nWe added
these clauses 4 years ago in a follow up
to\r\nhttps://github.com/elastic/beats/pull/14778 !!\r\n\r\nSince
monitor.timespan is now always present in docs , we don't need\r\nthese
queries !!\r\n\r\nI found these sometimes to be very slow while
investigating slow\r\nperformance of queries in a trace !!\r\n\r\n###
Autorefresh interval !!\r\n\r\nAlso updated auto refresh interval to 5
minutes, based on multiple\r\ncustomers feedback, default 1 minute is
too aggressive
!!","sha":"e88499a27c7ae1ec668d6b4fe0e11ce9a487d0be"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191722","number":191722,"mergeCommit":{"message":"[Uptime]
Remove unnecessary queries !! (#191722)\n\n## Summary\r\n\r\nWe added
these clauses 4 years ago in a follow up
to\r\nhttps://github.com/elastic/beats/pull/14778 !!\r\n\r\nSince
monitor.timespan is now always present in docs , we don't need\r\nthese
queries !!\r\n\r\nI found these sometimes to be very slow while
investigating slow\r\nperformance of queries in a trace !!\r\n\r\n###
Autorefresh interval !!\r\n\r\nAlso updated auto refresh interval to 5
minutes, based on multiple\r\ncustomers feedback, default 1 minute is
too aggressive !!","sha":"e88499a27c7ae1ec668d6b4fe0e11ce9a487d0be"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <[email protected]>
  • Loading branch information
kibanamachine and shahzad31 authored Sep 4, 2024
1 parent db826e3 commit fe8ca69
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const CLIENT_DEFAULTS = {
// 15 minutes
ABSOLUTE_DATE_RANGE_END: 1000 * 60 * 15,
/**
* The application auto refreshes every 60s by default.
* The application auto refreshes every 5mins by default.
*/
AUTOREFRESH_INTERVAL: 60 * 1000,
AUTOREFRESH_INTERVAL: 5 * 60 * 1000,
/**
* The application's autorefresh feature is enabled.
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class QueryContext {
filterClause: any | null;
size: number;
statusFilter?: string;
hasTimespanCache?: boolean;
query?: string;

constructor(
Expand All @@ -48,13 +47,6 @@ export class QueryContext {
return this.callES.search(params, operationName);
}

async count(params: any): Promise<any> {
const {
result: { body },
} = await this.callES.count(params);
return body;
}

async dateAndCustomFilters(): Promise<ESFilter[]> {
const clauses = [await this.dateRangeFilter()];
if (this.filterClause) {
Expand All @@ -68,10 +60,6 @@ export class QueryContext {
range: { '@timestamp': { gte: this.dateRangeStart, lte: this.dateRangeEnd } },
};

if (!(await this.hasTimespan())) {
return timestampClause;
}

return {
bool: {
filter: [
Expand Down Expand Up @@ -128,28 +116,6 @@ export class QueryContext {
};
}

async hasTimespan(): Promise<boolean> {
if (this.hasTimespanCache) {
return this.hasTimespanCache;
}

this.hasTimespanCache =
(
await this.count({
body: {
query: {
bool: {
filter: [this.timespanClause()],
},
},
},
terminate_after: 1,
})
).count > 0;

return this.hasTimespanCache;
}

clone(): QueryContext {
return new QueryContext(
this.callES,
Expand Down

0 comments on commit fe8ca69

Please sign in to comment.