Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions x-pack/legacy/plugins/uptime/common/constants/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,3 @@ export const QUERY = {
'error.type',
],
};

export const STATES = {
// Number of results returned for a states query
LEGACY_STATES_QUERY_SIZE: 10,
// The maximum number of monitors that should be supported
MAX_MONITORS: 35000,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

import { get, sortBy } from 'lodash';
import { QueryContext } from './query_context';
import { getHistogramIntervalFormatted } from '../../helper';
import { STATES } from '../../../../../../legacy/plugins/uptime/common/constants';
import { QUERY } from '../../../../common/constants';
import {
MonitorSummary,
SummaryHistogram,
Check,
Histogram,
MonitorSummary,
CursorDirection,
SortOrder,
} from '../../../../../../legacy/plugins/uptime/common/graphql/types';
} from '../../../../common/runtime_types';
import { MonitorEnricher } from './fetch_page';

export const enrichMonitorGroups: MonitorEnricher = async (
Expand Down Expand Up @@ -251,11 +250,8 @@ export const enrichMonitorGroups: MonitorEnricher = async (
const summaries: MonitorSummary[] = monitorBuckets.map((monitor: any) => {
const monitorId = get<string>(monitor, 'key.monitor_id');
monitorIds.push(monitorId);
let state = get<any>(monitor, 'state.value');
state = {
...state,
timestamp: state['@timestamp'],
};
const state: any = monitor.state?.value;
state.timestamp = state['@timestamp'];
const { checks } = state;
if (checks) {
state.checks = sortBy<SortChecks, Check>(checks, checksSortBy);
Expand Down Expand Up @@ -290,7 +286,7 @@ export const enrichMonitorGroups: MonitorEnricher = async (
const getHistogramForMonitors = async (
queryContext: QueryContext,
monitorIds: string[]
): Promise<{ [key: string]: SummaryHistogram }> => {
): Promise<{ [key: string]: Histogram }> => {
const params = {
index: queryContext.heartbeatIndices,
body: {
Expand Down Expand Up @@ -318,16 +314,13 @@ const getHistogramForMonitors = async (
by_id: {
terms: {
field: 'monitor.id',
size: STATES.LEGACY_STATES_QUERY_SIZE,
size: queryContext.size,
},
aggs: {
histogram: {
date_histogram: {
auto_date_histogram: {
field: '@timestamp',
fixed_interval: getHistogramIntervalFormatted(
queryContext.dateRangeStart,
queryContext.dateRangeEnd
),
buckets: QUERY.DEFAULT_BUCKET_COUNT,
missing: 0,
},
aggs: {
Expand Down