mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -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 type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import DateMath from '@kbn/datemath';
|
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 type { CertificatesResults } from '../../server/queries/get_certs';
|
||||||
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
||||||
import { createEsQuery } from '../utils/es_search';
|
import { createEsQuery } from '../utils/es_search';
|
||||||
|
@ -79,6 +80,8 @@ export const getCertsRequestBody = ({
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
filter: [
|
filter: [
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
...(filters ? [filters] : []),
|
...(filters ? [filters] : []),
|
||||||
...(monitorIds && monitorIds.length > 0
|
...(monitorIds && monitorIds.length > 0
|
||||||
? [{ terms: { 'monitor.id': monitorIds } }]
|
? [{ terms: { 'monitor.id': monitorIds } }]
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import DateMath from '@kbn/datemath';
|
import DateMath from '@kbn/datemath';
|
||||||
|
import { EXCLUDE_RUN_ONCE_FILTER, SUMMARY_FILTER } from '../constants/client_defaults';
|
||||||
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
import { CertResult, GetCertsParams, Ping } from '../runtime_types';
|
||||||
import { createEsQuery } from '../utils/es_search';
|
import { createEsQuery } from '../utils/es_search';
|
||||||
|
|
||||||
|
@ -79,6 +80,8 @@ export const getCertsRequestBody = ({
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
filter: [
|
filter: [
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
...(filters ? [filters] : []),
|
...(filters ? [filters] : []),
|
||||||
...(monitorIds && monitorIds.length > 0
|
...(monitorIds && monitorIds.length > 0
|
||||||
? [{ terms: { 'monitor.id': monitorIds } }]
|
? [{ terms: { 'monitor.id': monitorIds } }]
|
||||||
|
|
|
@ -185,7 +185,7 @@ export class UptimeEsClient {
|
||||||
const showInspectData =
|
const showInspectData =
|
||||||
(isInspectorEnabled || this.isDev) && path !== API_URLS.DYNAMIC_SETTINGS;
|
(isInspectorEnabled || this.isDev) && path !== API_URLS.DYNAMIC_SETTINGS;
|
||||||
|
|
||||||
if (showInspectData) {
|
if (showInspectData && this.inspectableEsQueries.length > 0) {
|
||||||
return { _inspect: this.inspectableEsQueries };
|
return { _inspect: this.inspectableEsQueries };
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -30,6 +30,20 @@ Array [
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
|
|
@ -184,6 +184,20 @@ describe('getCerts', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"exists": Object {
|
"exists": Object {
|
||||||
"field": "tls.server.hash.sha256",
|
"field": "tls.server.hash.sha256",
|
||||||
|
|
|
@ -24,6 +24,15 @@ describe('getLatestMonitor', () => {
|
||||||
field: 'summary',
|
field: 'summary',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
must_not: {
|
||||||
|
exists: {
|
||||||
|
field: 'run_once',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
range: {
|
range: {
|
||||||
'@timestamp': {
|
'@timestamp': {
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
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 { UMElasticsearchQueryFn } from '../adapters';
|
||||||
import { Ping } from '../../../../common/runtime_types';
|
import { Ping } from '../../../../common/runtime_types';
|
||||||
|
|
||||||
|
@ -34,7 +38,8 @@ export const getLatestMonitor: UMElasticsearchQueryFn<GetLatestMonitorParams, Pi
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
{ exists: { field: 'summary' } },
|
SUMMARY_FILTER,
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
{
|
{
|
||||||
range: {
|
range: {
|
||||||
'@timestamp': {
|
'@timestamp': {
|
||||||
|
|
|
@ -202,6 +202,15 @@ describe('monitor availability', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
@ -384,6 +393,15 @@ describe('monitor availability', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
@ -710,6 +728,15 @@ describe('monitor availability', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
@ -813,6 +840,15 @@ describe('monitor availability', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
@ -940,6 +976,15 @@ describe('monitor availability', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": Object {
|
"@timestamp": Object {
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
} from '../../../../common/constants/client_defaults';
|
||||||
import { UMElasticsearchQueryFn } from '../adapters';
|
import { UMElasticsearchQueryFn } from '../adapters';
|
||||||
import { GetMonitorAvailabilityParams, Ping } from '../../../../common/runtime_types';
|
import { GetMonitorAvailabilityParams, Ping } from '../../../../common/runtime_types';
|
||||||
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||||
|
@ -62,11 +66,8 @@ export const getMonitorAvailability: UMElasticsearchQueryFn<
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
{
|
SUMMARY_FILTER,
|
||||||
exists: {
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
field: 'summary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
range: {
|
range: {
|
||||||
'@timestamp': {
|
'@timestamp': {
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
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 { UMElasticsearchQueryFn } from '../adapters';
|
||||||
import { LocationDurationLine, MonitorDurationResult } from '../../../../common/types';
|
import { LocationDurationLine, MonitorDurationResult } from '../../../../common/types';
|
||||||
import { QUERY, UNNAMED_LOCATION } from '../../../../common/constants';
|
import { QUERY, UNNAMED_LOCATION } from '../../../../common/constants';
|
||||||
|
@ -30,6 +34,8 @@ export const getMonitorDurationChart: UMElasticsearchQueryFn<
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
{ range: { '@timestamp': { gte: dateStart, lte: dateEnd } } },
|
{ range: { '@timestamp': { gte: dateStart, lte: dateEnd } } },
|
||||||
{ term: { 'monitor.id': monitorId } },
|
{ term: { 'monitor.id': monitorId } },
|
||||||
{ range: { 'monitor.duration.us': { gt: 0 } } },
|
{ range: { 'monitor.duration.us': { gt: 0 } } },
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
} from '../../../../common/constants/client_defaults';
|
||||||
import { UMElasticsearchQueryFn } from '../adapters';
|
import { UMElasticsearchQueryFn } from '../adapters';
|
||||||
import { MonitorLocations, MonitorLocation } from '../../../../common/runtime_types';
|
import { MonitorLocations, MonitorLocation } from '../../../../common/runtime_types';
|
||||||
import { UNNAMED_LOCATION } from '../../../../common/constants';
|
import { UNNAMED_LOCATION } from '../../../../common/constants';
|
||||||
|
@ -43,11 +47,8 @@ export const getMonitorLocations: UMElasticsearchQueryFn<
|
||||||
'monitor.id': monitorId,
|
'monitor.id': monitorId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
SUMMARY_FILTER,
|
||||||
exists: {
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
field: 'summary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
range: {
|
range: {
|
||||||
'@timestamp': {
|
'@timestamp': {
|
||||||
|
|
|
@ -150,6 +150,15 @@ describe('getMonitorStatus', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"summary.down": Object {
|
"summary.down": Object {
|
||||||
|
@ -291,6 +300,15 @@ describe('getMonitorStatus', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"summary.down": Object {
|
"summary.down": Object {
|
||||||
|
@ -469,6 +487,15 @@ describe('getMonitorStatus', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"summary.down": Object {
|
"summary.down": Object {
|
||||||
|
@ -640,6 +667,15 @@ describe('getMonitorStatus', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"summary.down": Object {
|
"summary.down": Object {
|
||||||
|
@ -786,6 +822,15 @@ describe('getMonitorStatus', () => {
|
||||||
"field": "summary",
|
"field": "summary",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"summary.down": Object {
|
"summary.down": Object {
|
||||||
|
|
|
@ -9,6 +9,10 @@ import { JsonObject } from '@kbn/utility-types';
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { PromiseType } from 'utility-types';
|
import { PromiseType } from 'utility-types';
|
||||||
import { formatDurationFromTimeUnitChar, TimeUnitChar } from '@kbn/observability-plugin/common';
|
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 { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||||
import { UMElasticsearchQueryFn } from '../adapters';
|
import { UMElasticsearchQueryFn } from '../adapters';
|
||||||
import { Ping } from '../../../../common/runtime_types/ping';
|
import { Ping } from '../../../../common/runtime_types/ping';
|
||||||
|
@ -91,11 +95,8 @@ const executeQueryParams = async ({
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
{
|
SUMMARY_FILTER,
|
||||||
exists: {
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
field: 'summary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
range: {
|
range: {
|
||||||
'summary.down': {
|
'summary.down': {
|
||||||
|
|
|
@ -12,7 +12,10 @@ import { QUERY } from '../../../../common/constants';
|
||||||
import { UMElasticsearchQueryFn } from '../adapters/framework';
|
import { UMElasticsearchQueryFn } from '../adapters/framework';
|
||||||
import { createEsQuery } from '../../../../common/utils/es_search';
|
import { createEsQuery } from '../../../../common/utils/es_search';
|
||||||
import { getHistogramInterval } from '../../../../common/lib/get_histogram_interval';
|
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<
|
export const getPingHistogram: UMElasticsearchQueryFn<
|
||||||
GetPingHistogramParams,
|
GetPingHistogramParams,
|
||||||
|
@ -47,15 +50,7 @@ export const getPingHistogram: UMElasticsearchQueryFn<
|
||||||
body: {
|
body: {
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [...filter, SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER],
|
||||||
...filter,
|
|
||||||
{
|
|
||||||
exists: {
|
|
||||||
field: 'summary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
EXCLUDE_RUN_ONCE_FILTER,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
size: 0,
|
size: 0,
|
||||||
|
|
|
@ -129,6 +129,20 @@ describe('getAll', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": 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,
|
"size": 12,
|
||||||
|
@ -201,6 +191,20 @@ describe('getAll', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": 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,
|
"size": 12,
|
||||||
|
@ -273,6 +253,20 @@ describe('getAll', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": 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,
|
"size": 25,
|
||||||
|
@ -345,6 +315,20 @@ describe('getAll', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": 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,
|
"size": 25,
|
||||||
|
@ -420,15 +380,11 @@ describe('getAll', () => {
|
||||||
expect(mockEsClient.search.mock.calls[0][0].body.query.bool.filter[1]).toMatchInlineSnapshot(`
|
expect(mockEsClient.search.mock.calls[0][0].body.query.bool.filter[1]).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"must_not": Array [
|
"must_not": Object {
|
||||||
Object {
|
"exists": Object {
|
||||||
"terms": Object {
|
"field": "run_once",
|
||||||
"observer.geo.name": Array [
|
|
||||||
"fairbanks",
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
@ -467,6 +423,20 @@ describe('getAll', () => {
|
||||||
"query": Object {
|
"query": Object {
|
||||||
"bool": Object {
|
"bool": Object {
|
||||||
"filter": Array [
|
"filter": Array [
|
||||||
|
Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "summary",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"bool": Object {
|
||||||
|
"must_not": Object {
|
||||||
|
"exists": Object {
|
||||||
|
"field": "run_once",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"range": Object {
|
"range": Object {
|
||||||
"@timestamp": 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,
|
"size": 25,
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
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 { UMElasticsearchQueryFn } from '../adapters/framework';
|
||||||
import {
|
import {
|
||||||
GetPingsParams,
|
GetPingsParams,
|
||||||
|
@ -16,43 +20,6 @@ import {
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 25;
|
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[] {
|
function isStringArray(value: unknown): value is string[] {
|
||||||
if (!Array.isArray(value)) return false;
|
if (!Array.isArray(value)) return false;
|
||||||
// are all array items strings
|
// are all array items strings
|
||||||
|
@ -79,11 +46,12 @@ export const getPings: UMElasticsearchQueryFn<GetPingsParams, PingsResponse> = a
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
|
SUMMARY_FILTER,
|
||||||
|
EXCLUDE_RUN_ONCE_FILTER,
|
||||||
{ range: { '@timestamp': { gte: from, lte: to } } },
|
{ range: { '@timestamp': { gte: from, lte: to } } },
|
||||||
...(monitorId ? [{ term: { 'monitor.id': monitorId } }] : []),
|
...(monitorId ? [{ term: { 'monitor.id': monitorId } }] : []),
|
||||||
...(status ? [{ term: { 'monitor.status': status } }] : []),
|
...(status ? [{ term: { 'monitor.status': status } }] : []),
|
||||||
] as QueryDslQueryContainer[],
|
] as QueryDslQueryContainer[],
|
||||||
...REMOVE_NON_SUMMARY_BROWSER_CHECKS,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sort: [{ '@timestamp': { order: (sort ?? 'desc') as 'asc' | 'desc' } }],
|
sort: [{ '@timestamp': { order: (sort ?? 'desc') as 'asc' | 'desc' } }],
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export const PINGS_DATE_RANGE_START = moment('2018-10-30T00:00:23.889Z').valueOf();
|
export const PINGS_DATE_RANGE_START = moment('2019-09-11T03:31:04.396Z').valueOf();
|
||||||
export const PINGS_DATE_RANGE_END = moment('2018-10-31T00:00:00.889Z').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');
|
const esArchiver = getService('esArchiver');
|
||||||
|
|
||||||
describe('get_all_pings', () => {
|
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));
|
before('load heartbeat data', async () => await esArchiver.load(archive));
|
||||||
after('unload heartbeat data', async () => await esArchiver.unload(archive));
|
after('unload heartbeat data', async () => await esArchiver.unload(archive));
|
||||||
|
@ -31,9 +31,10 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(apiResponse.total).to.be(2);
|
expect(apiResponse.total).to.be(1931);
|
||||||
expect(apiResponse.pings.length).to.be(2);
|
expect(apiResponse.pings.length).to.be(25);
|
||||||
expect(apiResponse.pings[0].monitor.id).to.be('http@https://www.github.com/');
|
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 () => {
|
it('should sort pings according to timestamp', async () => {
|
||||||
|
@ -46,10 +47,10 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(apiResponse.total).to.be(2);
|
expect(apiResponse.total).to.be(1931);
|
||||||
expect(apiResponse.pings.length).to.be(2);
|
expect(apiResponse.pings.length).to.be(25);
|
||||||
expect(apiResponse.pings[0]['@timestamp']).to.be('2018-10-30T14:49:23.889Z');
|
expect(apiResponse.pings[0]['@timestamp']).to.be('2019-09-11T03:31:04.396Z');
|
||||||
expect(apiResponse.pings[1]['@timestamp']).to.be('2018-10-30T18:51:56.792Z');
|
expect(apiResponse.pings[1]['@timestamp']).to.be('2019-09-11T03:31:04.396Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return results of n length', async () => {
|
it('should return results of n length', async () => {
|
||||||
|
@ -63,9 +64,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
expect(apiResponse.total).to.be(2);
|
expect(apiResponse.total).to.be(1931);
|
||||||
expect(apiResponse.pings.length).to.be(1);
|
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 () => {
|
it('should miss pings outside of date range', async () => {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// 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`] = `
|
exports[`uptime uptime REST endpoints with real-world data monitor states endpoint will fetch monitor state data for the given down filters 1`] = `
|
||||||
Object {
|
Array [
|
||||||
"nextPagePagination": "{\\"cursorDirection\\":\\"AFTER\\",\\"sortOrder\\":\\"ASC\\",\\"cursorKey\\":{\\"monitor_id\\":\\"0020-down\\"}}",
|
|
||||||
"prevPagePagination": null,
|
|
||||||
"summaries": Array [
|
|
||||||
Object {
|
Object {
|
||||||
"monitor_id": "0010-down",
|
"monitor_id": "0010-down",
|
||||||
"state": Object {
|
"state": Object {
|
||||||
|
@ -275,6 +272,5 @@ Object {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
`${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&statusFilter=${statusFilter}&pageSize=${size}`
|
`${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 () => {
|
it('can navigate forward and backward using pagination', async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue