diff --git a/x-pack/legacy/plugins/uptime/common/types/index.ts b/x-pack/legacy/plugins/uptime/common/types/index.ts index 1d0003addd7618..fcbb92caf26d5b 100644 --- a/x-pack/legacy/plugins/uptime/common/types/index.ts +++ b/x-pack/legacy/plugins/uptime/common/types/index.ts @@ -34,10 +34,4 @@ export interface LocationDurationLine { export interface MonitorDurationResult { /** The average values for the monitor duration. */ locationDurationLines: LocationDurationLine[]; - /** The counts of up/down checks for the monitor. */ - status: StatusData[]; - /** The maximum status doc count in this chart. */ - statusMaxCount: number; - /** The maximum duration value in this chart. */ - durationMaxValue: number; } diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/duration_charts.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/duration_charts.test.tsx index aac84c69d8d7b1..57f9ce9abbca6d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/duration_charts.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/duration_charts.test.tsx @@ -43,21 +43,6 @@ describe('MonitorCharts component', () => { ], }, ], - status: [ - { x: 1548697620000, up: 74, down: null, total: 74 }, - { x: 1548697920000, up: 75, down: null, total: 75 }, - { x: 1548698220000, up: 75, down: null, total: 75 }, - { x: 1548698520000, up: 73, down: null, total: 73 }, - { x: 1548698820000, up: 75, down: null, total: 75 }, - { x: 1548699120000, up: 74, down: null, total: 74 }, - { x: 1548699420000, up: 75, down: null, total: 75 }, - { x: 1548699720000, up: 75, down: null, total: 75 }, - { x: 1548700020000, up: 75, down: null, total: 75 }, - { x: 1548700320000, up: 75, down: null, total: 75 }, - { x: 1548700620000, up: 75, down: null, total: 75 }, - ], - statusMaxCount: 75, - durationMaxValue: 6669234, }, }; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts b/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts index bcd2582fe18b92..f10745a50f56a4 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts @@ -48,11 +48,8 @@ export const createMLJob = async ({ query: { bool: { filter: [ - { - term: { - 'monitor.id': lowerCaseMonitorId, - }, - }, + { term: { 'monitor.id': lowerCaseMonitorId } }, + { range: { 'monitor.duration.us': { gt: 0 } } }, ], }, }, diff --git a/x-pack/plugins/uptime/server/lib/requests/__tests__/__snapshots__/get_monitor_charts.test.ts.snap b/x-pack/plugins/uptime/server/lib/requests/__tests__/__snapshots__/get_monitor_charts.test.ts.snap index 7b717949c70c52..97b97f84407584 100644 --- a/x-pack/plugins/uptime/server/lib/requests/__tests__/__snapshots__/get_monitor_charts.test.ts.snap +++ b/x-pack/plugins/uptime/server/lib/requests/__tests__/__snapshots__/get_monitor_charts.test.ts.snap @@ -15,13 +15,6 @@ Array [ "field": "monitor.duration.us", }, }, - "status": Object { - "terms": Object { - "field": "monitor.status", - "shard_size": 2, - "size": 2, - }, - }, }, "terms": Object { "field": "observer.geo.name", @@ -55,8 +48,10 @@ Array [ }, }, Object { - "term": Object { - "monitor.status": "up", + "range": Object { + "monitor.duration.us": Object { + "gt": 0, + }, }, }, ], @@ -71,7 +66,6 @@ Array [ exports[`ElasticsearchMonitorsAdapter inserts empty buckets for missing data 1`] = ` Object { - "durationMaxValue": 0, "locationDurationLines": Array [ Object { "line": Array [ @@ -244,128 +238,5 @@ Object { "name": "us-west-4", }, ], - "status": Array [ - Object { - "down": null, - "total": 4, - "up": null, - "x": 1568411568000, - }, - Object { - "down": null, - "total": 0, - "up": null, - "x": 1568411604000, - }, - Object { - "down": null, - "total": 8, - "up": null, - "x": 1568411640000, - }, - Object { - "down": null, - "total": 8, - "up": null, - "x": 1568411784000, - }, - Object { - "down": null, - "total": 0, - "up": null, - "x": 1568411820000, - }, - Object { - "down": null, - "total": 0, - "up": null, - "x": 1568411856000, - }, - Object { - "down": null, - "total": 0, - "up": null, - "x": 1568411892000, - }, - Object { - "down": null, - "total": 4, - "up": null, - "x": 1568411928000, - }, - Object { - "down": null, - "total": 7, - "up": null, - "x": 1568411964000, - }, - Object { - "down": null, - "total": 5, - "up": null, - "x": 1568412036000, - }, - Object { - "down": null, - "total": 4, - "up": null, - "x": 1568412072000, - }, - Object { - "down": null, - "total": 3, - "up": null, - "x": 1568412108000, - }, - Object { - "down": null, - "total": 4, - "up": null, - "x": 1568412144000, - }, - Object { - "down": null, - "total": 4, - "up": null, - "x": 1568412180000, - }, - Object { - "down": null, - "total": 3, - "up": null, - "x": 1568412216000, - }, - Object { - "down": null, - "total": 1, - "up": null, - "x": 1568412252000, - }, - Object { - "down": null, - "total": 3, - "up": null, - "x": 1568412288000, - }, - Object { - "down": null, - "total": 8, - "up": null, - "x": 1568412324000, - }, - Object { - "down": null, - "total": 8, - "up": null, - "x": 1568412432000, - }, - Object { - "down": null, - "total": 1, - "up": null, - "x": 1568412468000, - }, - ], - "statusMaxCount": 0, } `; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts index 01bfc52489bf3a..e9c745b0a87133 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts @@ -20,26 +20,6 @@ export interface GetMonitorChartsParams { dateEnd: string; } -const formatStatusBuckets = (time: any, buckets: any, docCount: any) => { - let up = null; - let down = null; - - buckets.forEach((bucket: any) => { - if (bucket.key === 'up') { - up = bucket.doc_count; - } else if (bucket.key === 'down') { - down = bucket.doc_count; - } - }); - - return { - x: time, - up, - down, - total: docCount, - }; -}; - /** * Fetches data used to populate monitor charts */ @@ -55,7 +35,7 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn< filter: [ { range: { '@timestamp': { gte: dateStart, lte: dateEnd } } }, { term: { 'monitor.id': monitorId } }, - { term: { 'monitor.status': 'up' } }, + { range: { 'monitor.duration.us': { gt: 0 } } }, ], }, }, @@ -73,7 +53,6 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn< missing: 'N/A', }, aggs: { - status: { terms: { field: 'monitor.status', size: 2, shard_size: 2 } }, duration: { stats: { field: 'monitor.duration.us' } }, }, }, @@ -94,15 +73,10 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn< * * The third list is for an area chart expressing a range, and it requires an (x,y,y0) structure, * where y0 is the min value for the point and y is the max. - * - * Additionally, we supply the maximum value for duration and status, so the corresponding charts know - * what the domain size should be. */ + const monitorChartsData: MonitorDurationResult = { locationDurationLines: [], - status: [], - durationMaxValue: 0, - statusMaxCount: 0, }; /** @@ -119,9 +93,9 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn< // a set of all the locations found for this result const resultLocations = new Set(); const linesByLocation: { [key: string]: LocationDurationLine } = {}; + dateHistogramBuckets.forEach(dateHistogramBucket => { const x = dateHistogramBucket.key; - const docCount = dateHistogramBucket?.doc_count ?? 0; // a set of all the locations for the current bucket const bucketLocations = new Set(); @@ -161,10 +135,6 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn< } }); } - - monitorChartsData.status.push( - formatStatusBuckets(x, dateHistogramBucket?.status?.buckets ?? [], docCount) - ); }); return monitorChartsData; diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json index 8edcff158b0ae2..e96b3b3b562b9f 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json @@ -85,129 +85,5 @@ } ] } - ], - "status": [ - { - "x": 1568172664000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172694000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172724000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172754000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172784000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172814000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172844000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172874000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172904000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172934000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172964000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172994000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173024000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173054000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173084000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173114000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173144000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173174000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173204000, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173234000, - "up": null, - "down": null, - "total": 1 - } - ], - "durationMaxValue": 0, - "statusMaxCount": 0 + ] } \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json index 674338101bc5b5..5157eace006cf3 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json @@ -1,6 +1,3 @@ { - "locationDurationLines": [], - "status": [], - "durationMaxValue": 0, - "statusMaxCount": 0 + "locationDurationLines": [] } \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_latest_status.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_latest_status.json index 6a832ad8536f7f..9a33be807670ea 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_latest_status.json +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_latest_status.json @@ -1,11 +1,16 @@ { "observer": { - "geo": { "name": "mpls", "location": "37.926868, -78.024902" }, + "geo": { + "name": "mpls", + "location": "37.926868, -78.024902" + }, "hostname": "avc-x1x" }, "@timestamp": "2019-09-11T03:40:34.371Z", "monitor": { - "duration": { "us": 24627 }, + "duration": { + "us": 24627 + }, "ip": "127.0.0.1", "name": "", "check_group": "d76f0762-d445-11e9-88e3-3e80641b9c71", @@ -23,4 +28,4 @@ }, "docId": "h5toHm0B0I9WX_CznN_V", "timestamp": "2019-09-11T03:40:34.371Z" -} +} \ No newline at end of file