mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Uptime] Filter out run once documents (#166704)
This commit is contained in:
parent
76b832e12e
commit
4221e79ff9
20 changed files with 519 additions and 466 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import DateMath from '@kbn/datemath';
|
||||
import { EXCLUDE_RUN_ONCE_FILTER, SUMMARY_FILTER } from '../constants/client_defaults';
|
||||
import type { CertificatesResults } from '../../server/queries/get_certs';
|
||||
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
||||
import { createEsQuery } from '../utils/es_search';
|
||||
|
@ -79,6 +80,8 @@ export const getCertsRequestBody = ({
|
|||
}
|
||||
: {}),
|
||||
filter: [
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
...(filters ? [filters] : []),
|
||||
...(monitorIds && monitorIds.length > 0
|
||||
? [{ terms: { 'monitor.id': monitorIds } }]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import DateMath from '@kbn/datemath';
|
||||
import { EXCLUDE_RUN_ONCE_FILTER, SUMMARY_FILTER } from '../constants/client_defaults';
|
||||
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
||||
import { createEsQuery } from '../utils/es_search';
|
||||
|
||||
|
@ -79,6 +80,8 @@ export const getCertsRequestBody = ({
|
|||
}
|
||||
: {}),
|
||||
filter: [
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
...(filters ? [filters] : []),
|
||||
...(monitorIds && monitorIds.length > 0
|
||||
? [{ terms: { 'monitor.id': monitorIds } }]
|
||||
|
|
|
@ -185,7 +185,7 @@ export class UptimeEsClient {
|
|||
const showInspectData =
|
||||
(isInspectorEnabled || this.isDev) && path !== API_URLS.DYNAMIC_SETTINGS;
|
||||
|
||||
if (showInspectData) {
|
||||
if (showInspectData && this.inspectableEsQueries.length > 0) {
|
||||
return { _inspect: this.inspectableEsQueries };
|
||||
}
|
||||
return {};
|
||||
|
|
|
@ -30,6 +30,20 @@ Array [
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
|
|
@ -184,6 +184,20 @@ describe('getCerts', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "tls.server.hash.sha256",
|
||||
|
|
|
@ -24,6 +24,15 @@ describe('getLatestMonitor', () => {
|
|||
field: 'summary',
|
||||
},
|
||||
},
|
||||
{
|
||||
bool: {
|
||||
must_not: {
|
||||
exists: {
|
||||
field: 'run_once',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { Ping } from '../../../../common/runtime_types';
|
||||
|
||||
|
@ -34,7 +38,8 @@ export const getLatestMonitor: UMElasticsearchQueryFn<GetLatestMonitorParams, Pi
|
|||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
{ exists: { field: 'summary' } },
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
|
|
|
@ -202,6 +202,15 @@ describe('monitor availability', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -384,6 +393,15 @@ describe('monitor availability', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -710,6 +728,15 @@ describe('monitor availability', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -813,6 +840,15 @@ describe('monitor availability', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -940,6 +976,15 @@ describe('monitor availability', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { GetMonitorAvailabilityParams, Ping } from '../../../../common/runtime_types';
|
||||
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||
|
@ -62,11 +66,8 @@ export const getMonitorAvailability: UMElasticsearchQueryFn<
|
|||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { LocationDurationLine, MonitorDurationResult } from '../../../../common/types';
|
||||
import { QUERY, UNNAMED_LOCATION } from '../../../../common/constants';
|
||||
|
@ -30,6 +34,8 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn<
|
|||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{ range: { '@timestamp': { gte: dateStart, lte: dateEnd } } },
|
||||
{ term: { 'monitor.id': monitorId } },
|
||||
{ range: { 'monitor.duration.us': { gt: 0 } } },
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { MonitorLocations, MonitorLocation } from '../../../../common/runtime_types';
|
||||
import { UNNAMED_LOCATION } from '../../../../common/constants';
|
||||
|
@ -43,11 +47,8 @@ export const getMonitorLocations: UMElasticsearchQueryFn<
|
|||
'monitor.id': monitorId,
|
||||
},
|
||||
},
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
|
|
|
@ -150,6 +150,15 @@ describe('getMonitorStatus', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"summary.down": Object {
|
||||
|
@ -291,6 +300,15 @@ describe('getMonitorStatus', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"summary.down": Object {
|
||||
|
@ -469,6 +487,15 @@ describe('getMonitorStatus', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"summary.down": Object {
|
||||
|
@ -640,6 +667,15 @@ describe('getMonitorStatus', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"summary.down": Object {
|
||||
|
@ -786,6 +822,15 @@ describe('getMonitorStatus', () => {
|
|||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"summary.down": Object {
|
||||
|
|
|
@ -9,6 +9,10 @@ import { JsonObject } from '@kbn/utility-types';
|
|||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { PromiseType } from 'utility-types';
|
||||
import { formatDurationFromTimeUnitChar, TimeUnitChar } from '@kbn/observability-plugin/common';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { Ping } from '../../../../common/runtime_types/ping';
|
||||
|
@ -91,11 +95,8 @@ const executeQueryParams = async ({
|
|||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{
|
||||
range: {
|
||||
'summary.down': {
|
||||
|
|
|
@ -12,7 +12,10 @@ import { QUERY } from '../../../../common/constants';
|
|||
import { UMElasticsearchQueryFn } from '../adapters/framework';
|
||||
import { createEsQuery } from '../../../../common/utils/es_search';
|
||||
import { getHistogramInterval } from '../../../../common/lib/get_histogram_interval';
|
||||
import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../common/constants/client_defaults';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
|
||||
export const getPingHistogram: UMElasticsearchQueryFn<
|
||||
GetPingHistogramParams,
|
||||
|
@ -47,15 +50,7 @@ export const getPingHistogram: UMElasticsearchQueryFn<
|
|||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
...filter,
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
],
|
||||
filter: [...filter, SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER],
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
|
|
|
@ -129,6 +129,20 @@ describe('getAll', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -138,30 +152,6 @@ describe('getAll', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"monitor.type": "browser",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"size": 12,
|
||||
|
@ -201,6 +191,20 @@ describe('getAll', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -210,30 +214,6 @@ describe('getAll', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"monitor.type": "browser",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"size": 12,
|
||||
|
@ -273,6 +253,20 @@ describe('getAll', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -282,30 +276,6 @@ describe('getAll', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"monitor.type": "browser",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"size": 25,
|
||||
|
@ -345,6 +315,20 @@ describe('getAll', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -359,30 +343,6 @@ describe('getAll', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"monitor.type": "browser",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"size": 25,
|
||||
|
@ -420,15 +380,11 @@ describe('getAll', () => {
|
|||
expect(mockEsClient.search.mock.calls[0][0].body.query.bool.filter[1]).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"terms": Object {
|
||||
"observer.geo.name": Array [
|
||||
"fairbanks",
|
||||
],
|
||||
},
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`);
|
||||
|
@ -467,6 +423,20 @@ describe('getAll', () => {
|
|||
"query": Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Object {
|
||||
"exists": Object {
|
||||
"field": "run_once",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
|
@ -481,30 +451,6 @@ describe('getAll', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"bool": Object {
|
||||
"filter": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"monitor.type": "browser",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"bool": Object {
|
||||
"must_not": Array [
|
||||
Object {
|
||||
"exists": Object {
|
||||
"field": "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"size": 25,
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
import { UMElasticsearchQueryFn } from '../adapters/framework';
|
||||
import {
|
||||
GetPingsParams,
|
||||
|
@ -16,43 +20,6 @@ import {
|
|||
|
||||
const DEFAULT_PAGE_SIZE = 25;
|
||||
|
||||
/**
|
||||
* This branch of filtering is used for monitors of type `browser`. This monitor
|
||||
* type represents an unbounded set of steps, with each `check_group` representing
|
||||
* a distinct journey. The document containing the `summary` field is indexed last, and
|
||||
* contains the data necessary for querying a journey.
|
||||
*
|
||||
* Because of this, when querying for "pings", it is important that we treat `browser` summary
|
||||
* checks as the "ping" we want. Without this filtering, we will receive >= N pings for a journey
|
||||
* of N steps, because an individual step may also contain multiple documents.
|
||||
*/
|
||||
const REMOVE_NON_SUMMARY_BROWSER_CHECKS = {
|
||||
must_not: [
|
||||
{
|
||||
bool: {
|
||||
filter: [
|
||||
{
|
||||
term: {
|
||||
'monitor.type': 'browser',
|
||||
},
|
||||
},
|
||||
{
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function isStringArray(value: unknown): value is string[] {
|
||||
if (!Array.isArray(value)) return false;
|
||||
// are all array items strings
|
||||
|
@ -79,11 +46,12 @@ export const getPings: UMElasticsearchQueryFn<GetPingsParams, PingsResponse> = a
|
|||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
SUMMARY_FILTER,
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
{ range: { '@timestamp': { gte: from, lte: to } } },
|
||||
...(monitorId ? [{ term: { 'monitor.id': monitorId } }] : []),
|
||||
...(status ? [{ term: { 'monitor.status': status } }] : []),
|
||||
] as QueryDslQueryContainer[],
|
||||
...REMOVE_NON_SUMMARY_BROWSER_CHECKS,
|
||||
},
|
||||
},
|
||||
sort: [{ '@timestamp': { order: (sort ?? 'desc') as 'asc' | 'desc' } }],
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
|
||||
import moment from 'moment';
|
||||
|
||||
export const PINGS_DATE_RANGE_START = moment('2018-10-30T00:00:23.889Z').valueOf();
|
||||
export const PINGS_DATE_RANGE_END = moment('2018-10-31T00:00:00.889Z').valueOf();
|
||||
export const PINGS_DATE_RANGE_START = moment('2019-09-11T03:31:04.396Z').valueOf();
|
||||
export const PINGS_DATE_RANGE_END = moment('2020-10-31T00:00:00.889Z').valueOf();
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const esArchiver = getService('esArchiver');
|
||||
|
||||
describe('get_all_pings', () => {
|
||||
const archive = 'x-pack/test/functional/es_archives/uptime/pings';
|
||||
const archive = 'x-pack/test/functional/es_archives/uptime/full_heartbeat';
|
||||
|
||||
before('load heartbeat data', async () => await esArchiver.load(archive));
|
||||
after('unload heartbeat data', async () => await esArchiver.unload(archive));
|
||||
|
@ -31,9 +31,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
expect(apiResponse.total).to.be(2);
|
||||
expect(apiResponse.pings.length).to.be(2);
|
||||
expect(apiResponse.pings[0].monitor.id).to.be('http@https://www.github.com/');
|
||||
expect(apiResponse.total).to.be(1931);
|
||||
expect(apiResponse.pings.length).to.be(25);
|
||||
expect(apiResponse.pings[0].monitor.id).to.be('0074-up');
|
||||
expect(apiResponse.pings[0].url.full).to.be('http://localhost:5678/pattern?r=200x1');
|
||||
});
|
||||
|
||||
it('should sort pings according to timestamp', async () => {
|
||||
|
@ -46,10 +47,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
expect(apiResponse.total).to.be(2);
|
||||
expect(apiResponse.pings.length).to.be(2);
|
||||
expect(apiResponse.pings[0]['@timestamp']).to.be('2018-10-30T14:49:23.889Z');
|
||||
expect(apiResponse.pings[1]['@timestamp']).to.be('2018-10-30T18:51:56.792Z');
|
||||
expect(apiResponse.total).to.be(1931);
|
||||
expect(apiResponse.pings.length).to.be(25);
|
||||
expect(apiResponse.pings[0]['@timestamp']).to.be('2019-09-11T03:31:04.396Z');
|
||||
expect(apiResponse.pings[1]['@timestamp']).to.be('2019-09-11T03:31:04.396Z');
|
||||
});
|
||||
|
||||
it('should return results of n length', async () => {
|
||||
|
@ -63,9 +64,9 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
expect(apiResponse.total).to.be(2);
|
||||
expect(apiResponse.total).to.be(1931);
|
||||
expect(apiResponse.pings.length).to.be(1);
|
||||
expect(apiResponse.pings[0].monitor.id).to.be('http@https://www.github.com/');
|
||||
expect(apiResponse.pings[0].monitor.id).to.be('0074-up');
|
||||
});
|
||||
|
||||
it('should miss pings outside of date range', async () => {
|
||||
|
|
|
@ -1,280 +1,276 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`uptime uptime REST endpoints with real-world data monitor states endpoint will fetch monitor state data for the given down filters 1`] = `
|
||||
Object {
|
||||
"nextPagePagination": "{\\"cursorDirection\\":\\"AFTER\\",\\"sortOrder\\":\\"ASC\\",\\"cursorKey\\":{\\"monitor_id\\":\\"0020-down\\"}}",
|
||||
"prevPagePagination": null,
|
||||
"summaries": Array [
|
||||
Object {
|
||||
"monitor_id": "0010-down",
|
||||
"state": Object {
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
Array [
|
||||
Object {
|
||||
"monitor_id": "0010-down",
|
||||
"state": Object {
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"monitor": Object {
|
||||
"checkGroup": "d76f07d1-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 37926,
|
||||
},
|
||||
"monitor": Object {
|
||||
"checkGroup": "d76f07d1-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 37926,
|
||||
},
|
||||
"name": "",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"name": Array [
|
||||
"mpls",
|
||||
],
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"status": "down",
|
||||
"up": 0,
|
||||
},
|
||||
"summaryPings": Array [
|
||||
Object {
|
||||
"@timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"agent": Object {
|
||||
"ephemeral_id": "412a92a8-2142-4b1a-a7a2-1afd32e12f85",
|
||||
"hostname": "avc-x1x",
|
||||
"id": "04e1d082-65bc-4929-8d65-d0768a2621c4",
|
||||
"type": "heartbeat",
|
||||
"version": "8.0.0",
|
||||
},
|
||||
"docId": "rZtoHm0B0I9WX_CznN_V",
|
||||
"ecs": Object {
|
||||
"version": "1.1.0",
|
||||
},
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"event": Object {
|
||||
"dataset": "uptime",
|
||||
},
|
||||
"host": Object {
|
||||
"name": "avc-x1x",
|
||||
},
|
||||
"http": Object {
|
||||
"response": Object {
|
||||
"body": Object {
|
||||
"bytes": 3,
|
||||
"content": "400",
|
||||
"hash": "26d228663f13a88592a12d16cf9587caab0388b262d6d9f126ed62f9333aca94",
|
||||
},
|
||||
"status_code": 400,
|
||||
},
|
||||
"rtt": Object {
|
||||
"content": Object {
|
||||
"us": 41,
|
||||
},
|
||||
"response_header": Object {
|
||||
"us": 36777,
|
||||
},
|
||||
"total": Object {
|
||||
"us": 37821,
|
||||
},
|
||||
"validate": Object {
|
||||
"us": 36818,
|
||||
},
|
||||
"write_request": Object {
|
||||
"us": 53,
|
||||
},
|
||||
},
|
||||
},
|
||||
"monitor": Object {
|
||||
"check_group": "d76f07d1-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 37926,
|
||||
},
|
||||
"id": "0010-down",
|
||||
"ip": "127.0.0.1",
|
||||
"name": "",
|
||||
"status": "down",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"location": "37.926868, -78.024902",
|
||||
"name": "mpls",
|
||||
},
|
||||
"hostname": "avc-x1x",
|
||||
},
|
||||
"resolve": Object {
|
||||
"ip": "127.0.0.1",
|
||||
"rtt": Object {
|
||||
"us": 56,
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"up": 0,
|
||||
},
|
||||
"tcp": Object {
|
||||
"rtt": Object {
|
||||
"connect": Object {
|
||||
"us": 890,
|
||||
},
|
||||
},
|
||||
},
|
||||
"timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
],
|
||||
"timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
"name": "",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"name": Array [
|
||||
"mpls",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"monitor_id": "0020-down",
|
||||
"state": Object {
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"monitor": Object {
|
||||
"checkGroup": "d7712ecb-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 14900,
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"status": "down",
|
||||
"up": 0,
|
||||
},
|
||||
"summaryPings": Array [
|
||||
Object {
|
||||
"@timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"agent": Object {
|
||||
"ephemeral_id": "412a92a8-2142-4b1a-a7a2-1afd32e12f85",
|
||||
"hostname": "avc-x1x",
|
||||
"id": "04e1d082-65bc-4929-8d65-d0768a2621c4",
|
||||
"type": "heartbeat",
|
||||
"version": "8.0.0",
|
||||
},
|
||||
"name": "",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"name": Array [
|
||||
"mpls",
|
||||
],
|
||||
"docId": "rZtoHm0B0I9WX_CznN_V",
|
||||
"ecs": Object {
|
||||
"version": "1.1.0",
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"status": "down",
|
||||
"up": 0,
|
||||
},
|
||||
"summaryPings": Array [
|
||||
Object {
|
||||
"@timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"agent": Object {
|
||||
"ephemeral_id": "412a92a8-2142-4b1a-a7a2-1afd32e12f85",
|
||||
"hostname": "avc-x1x",
|
||||
"id": "04e1d082-65bc-4929-8d65-d0768a2621c4",
|
||||
"type": "heartbeat",
|
||||
"version": "8.0.0",
|
||||
},
|
||||
"docId": "X5toHm0B0I9WX_CznN-6",
|
||||
"ecs": Object {
|
||||
"version": "1.1.0",
|
||||
},
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"event": Object {
|
||||
"dataset": "uptime",
|
||||
},
|
||||
"host": Object {
|
||||
"name": "avc-x1x",
|
||||
},
|
||||
"http": Object {
|
||||
"response": Object {
|
||||
"body": Object {
|
||||
"bytes": 3,
|
||||
"content": "400",
|
||||
"hash": "26d228663f13a88592a12d16cf9587caab0388b262d6d9f126ed62f9333aca94",
|
||||
},
|
||||
"status_code": 400,
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"event": Object {
|
||||
"dataset": "uptime",
|
||||
},
|
||||
"host": Object {
|
||||
"name": "avc-x1x",
|
||||
},
|
||||
"http": Object {
|
||||
"response": Object {
|
||||
"body": Object {
|
||||
"bytes": 3,
|
||||
"content": "400",
|
||||
"hash": "26d228663f13a88592a12d16cf9587caab0388b262d6d9f126ed62f9333aca94",
|
||||
},
|
||||
"rtt": Object {
|
||||
"content": Object {
|
||||
"us": 54,
|
||||
},
|
||||
"response_header": Object {
|
||||
"us": 180,
|
||||
},
|
||||
"total": Object {
|
||||
"us": 555,
|
||||
},
|
||||
"validate": Object {
|
||||
"us": 234,
|
||||
},
|
||||
"write_request": Object {
|
||||
"us": 63,
|
||||
},
|
||||
"status_code": 400,
|
||||
},
|
||||
"rtt": Object {
|
||||
"content": Object {
|
||||
"us": 41,
|
||||
},
|
||||
},
|
||||
"monitor": Object {
|
||||
"check_group": "d7712ecb-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 14900,
|
||||
"response_header": Object {
|
||||
"us": 36777,
|
||||
},
|
||||
"id": "0020-down",
|
||||
"ip": "127.0.0.1",
|
||||
"name": "",
|
||||
"status": "down",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"location": "37.926868, -78.024902",
|
||||
"name": "mpls",
|
||||
"total": Object {
|
||||
"us": 37821,
|
||||
},
|
||||
"hostname": "avc-x1x",
|
||||
},
|
||||
"resolve": Object {
|
||||
"ip": "127.0.0.1",
|
||||
"rtt": Object {
|
||||
"us": 14294,
|
||||
"validate": Object {
|
||||
"us": 36818,
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"up": 0,
|
||||
},
|
||||
"tcp": Object {
|
||||
"rtt": Object {
|
||||
"connect": Object {
|
||||
"us": 105,
|
||||
},
|
||||
"write_request": Object {
|
||||
"us": 53,
|
||||
},
|
||||
},
|
||||
"timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
],
|
||||
"timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
"monitor": Object {
|
||||
"check_group": "d76f07d1-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 37926,
|
||||
},
|
||||
"id": "0010-down",
|
||||
"ip": "127.0.0.1",
|
||||
"name": "",
|
||||
"status": "down",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"location": "37.926868, -78.024902",
|
||||
"name": "mpls",
|
||||
},
|
||||
"hostname": "avc-x1x",
|
||||
},
|
||||
"resolve": Object {
|
||||
"ip": "127.0.0.1",
|
||||
"rtt": Object {
|
||||
"us": 56,
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"up": 0,
|
||||
},
|
||||
"tcp": Object {
|
||||
"rtt": Object {
|
||||
"connect": Object {
|
||||
"us": 890,
|
||||
},
|
||||
},
|
||||
},
|
||||
"timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
],
|
||||
"timestamp": "2019-09-11T03:40:34.371Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
Object {
|
||||
"monitor_id": "0020-down",
|
||||
"state": Object {
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"monitor": Object {
|
||||
"checkGroup": "d7712ecb-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 14900,
|
||||
},
|
||||
"name": "",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"name": Array [
|
||||
"mpls",
|
||||
],
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"status": "down",
|
||||
"up": 0,
|
||||
},
|
||||
"summaryPings": Array [
|
||||
Object {
|
||||
"@timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"agent": Object {
|
||||
"ephemeral_id": "412a92a8-2142-4b1a-a7a2-1afd32e12f85",
|
||||
"hostname": "avc-x1x",
|
||||
"id": "04e1d082-65bc-4929-8d65-d0768a2621c4",
|
||||
"type": "heartbeat",
|
||||
"version": "8.0.0",
|
||||
},
|
||||
"docId": "X5toHm0B0I9WX_CznN-6",
|
||||
"ecs": Object {
|
||||
"version": "1.1.0",
|
||||
},
|
||||
"error": Object {
|
||||
"message": "400 Bad Request",
|
||||
"type": "validate",
|
||||
},
|
||||
"event": Object {
|
||||
"dataset": "uptime",
|
||||
},
|
||||
"host": Object {
|
||||
"name": "avc-x1x",
|
||||
},
|
||||
"http": Object {
|
||||
"response": Object {
|
||||
"body": Object {
|
||||
"bytes": 3,
|
||||
"content": "400",
|
||||
"hash": "26d228663f13a88592a12d16cf9587caab0388b262d6d9f126ed62f9333aca94",
|
||||
},
|
||||
"status_code": 400,
|
||||
},
|
||||
"rtt": Object {
|
||||
"content": Object {
|
||||
"us": 54,
|
||||
},
|
||||
"response_header": Object {
|
||||
"us": 180,
|
||||
},
|
||||
"total": Object {
|
||||
"us": 555,
|
||||
},
|
||||
"validate": Object {
|
||||
"us": 234,
|
||||
},
|
||||
"write_request": Object {
|
||||
"us": 63,
|
||||
},
|
||||
},
|
||||
},
|
||||
"monitor": Object {
|
||||
"check_group": "d7712ecb-d445-11e9-88e3-3e80641b9c71",
|
||||
"duration": Object {
|
||||
"us": 14900,
|
||||
},
|
||||
"id": "0020-down",
|
||||
"ip": "127.0.0.1",
|
||||
"name": "",
|
||||
"status": "down",
|
||||
"type": "http",
|
||||
},
|
||||
"observer": Object {
|
||||
"geo": Object {
|
||||
"location": "37.926868, -78.024902",
|
||||
"name": "mpls",
|
||||
},
|
||||
"hostname": "avc-x1x",
|
||||
},
|
||||
"resolve": Object {
|
||||
"ip": "127.0.0.1",
|
||||
"rtt": Object {
|
||||
"us": 14294,
|
||||
},
|
||||
},
|
||||
"summary": Object {
|
||||
"down": 1,
|
||||
"up": 0,
|
||||
},
|
||||
"tcp": Object {
|
||||
"rtt": Object {
|
||||
"connect": Object {
|
||||
"us": 105,
|
||||
},
|
||||
},
|
||||
},
|
||||
"timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
],
|
||||
"timestamp": "2019-09-11T03:40:34.372Z",
|
||||
"url": Object {
|
||||
"domain": "localhost",
|
||||
"full": "http://localhost:5678/pattern?r=400x1",
|
||||
"path": "/pattern",
|
||||
"port": 5678,
|
||||
"query": "r=400x1",
|
||||
"scheme": "http",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
|
|
@ -85,7 +85,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
`${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&statusFilter=${statusFilter}&pageSize=${size}`
|
||||
);
|
||||
|
||||
expectSnapshot(body).toMatch();
|
||||
expectSnapshot(body.summaries).toMatch();
|
||||
});
|
||||
|
||||
it('can navigate forward and backward using pagination', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue