Skip to content

Commit

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

We added these clauses 4 years ago in a follow up to
elastic/beats#14778 !!

Since monitor.timespan is now always present in docs , we don't need
these queries !!

I found these sometimes to be very slow while investigating slow
performance of queries in a trace !!

### Autorefresh interval !!

Also updated auto refresh interval to 5 minutes, based on multiple
customers feedback, default 1 minute is too aggressive !!
  • Loading branch information
shahzad31 authored Sep 4, 2024
1 parent 1b2cbf1 commit e88499a
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 e88499a

Please sign in to comment.