From 847fe646acfb4afa9871089ccbfbff8f66cc21a7 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Mon, 12 Jul 2021 17:48:38 -0400 Subject: [PATCH 1/3] [APM] Fixes support for APM index pattern with data streams (#94702) --- .../observability/create_layer_descriptor.test.ts | 2 +- .../solution_layers/observability/create_layer_descriptor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.test.ts b/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.test.ts index 1ac2690d6bada..74ab35e6cb360 100644 --- a/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.test.ts @@ -54,7 +54,7 @@ describe('createLayerDescriptor', () => { applyGlobalTime: true, id: '12345', indexPatternId: 'apm_static_index_pattern_id', - indexPatternTitle: 'apm-*', + indexPatternTitle: 'traces-apm*,logs-apm*,metrics-apm*,apm-*', metrics: [ { field: 'transaction.duration.us', diff --git a/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.ts b/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.ts index adf6f1d7f270d..0b57afb38d585 100644 --- a/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.ts +++ b/x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.ts @@ -39,7 +39,7 @@ import { getDefaultDynamicProperties } from '../../../styles/vector/vector_style // redefining APM constant to avoid making maps app depend on APM plugin export const APM_INDEX_PATTERN_ID = 'apm_static_index_pattern_id'; -export const APM_INDEX_PATTERN_TITLE = 'apm-*'; +export const APM_INDEX_PATTERN_TITLE = 'traces-apm*,logs-apm*,metrics-apm*,apm-*'; const defaultDynamicProperties = getDefaultDynamicProperties(); From a3a27df4b6b57bbe143254736a4dbe7050cb9fc6 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 13 Jul 2021 00:10:17 -0400 Subject: [PATCH 2/3] fix unit test --- .../security/create_layer_descriptors.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts index 9c6e72fc11d3a..e6c282f427acb 100644 --- a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts @@ -30,14 +30,16 @@ import { createSecurityLayerDescriptors } from './create_layer_descriptors'; describe('createLayerDescriptor', () => { test('apm index', () => { - expect(createSecurityLayerDescriptors('id', 'apm-*-transaction*')).toEqual([ + expect( + createSecurityLayerDescriptors('id', 'traces-apm*,logs-apm*,metrics-apm*,apm-*') + ).toEqual([ { __dataRequests: [], alpha: 0.75, id: '12345', includeInFitToBounds: true, joins: [], - label: 'apm-*-transaction* | Source Point', + label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Source Point', maxZoom: 24, minZoom: 0, sourceDescriptor: { @@ -146,7 +148,7 @@ describe('createLayerDescriptor', () => { id: '12345', includeInFitToBounds: true, joins: [], - label: 'apm-*-transaction* | Destination point', + label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Destination point', maxZoom: 24, minZoom: 0, sourceDescriptor: { @@ -255,7 +257,7 @@ describe('createLayerDescriptor', () => { id: '12345', includeInFitToBounds: true, joins: [], - label: 'apm-*-transaction* | Line', + label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Line', maxZoom: 24, minZoom: 0, sourceDescriptor: { From b4904f693137363fda4fb4a79554266ffbd1f483 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 13 Jul 2021 18:02:56 -0400 Subject: [PATCH 3/3] - Revert "fix unit test" - tests each component of index pattern title for index matches This reverts commit a3a27df4b6b57bbe143254736a4dbe7050cb9fc6. --- .../security/create_layer_descriptors.test.ts | 349 +++++++++++++++++- .../security/create_layer_descriptors.ts | 6 +- 2 files changed, 348 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts index e6c282f427acb..a3a3e8b20f678 100644 --- a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.test.ts @@ -30,16 +30,14 @@ import { createSecurityLayerDescriptors } from './create_layer_descriptors'; describe('createLayerDescriptor', () => { test('apm index', () => { - expect( - createSecurityLayerDescriptors('id', 'traces-apm*,logs-apm*,metrics-apm*,apm-*') - ).toEqual([ + expect(createSecurityLayerDescriptors('id', 'apm-*-transaction*')).toEqual([ { __dataRequests: [], alpha: 0.75, id: '12345', includeInFitToBounds: true, joins: [], - label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Source Point', + label: 'apm-*-transaction* | Source Point', maxZoom: 24, minZoom: 0, sourceDescriptor: { @@ -148,7 +146,7 @@ describe('createLayerDescriptor', () => { id: '12345', includeInFitToBounds: true, joins: [], - label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Destination point', + label: 'apm-*-transaction* | Destination point', maxZoom: 24, minZoom: 0, sourceDescriptor: { @@ -257,7 +255,7 @@ describe('createLayerDescriptor', () => { id: '12345', includeInFitToBounds: true, joins: [], - label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Line', + label: 'apm-*-transaction* | Line', maxZoom: 24, minZoom: 0, sourceDescriptor: { @@ -708,4 +706,343 @@ describe('createLayerDescriptor', () => { }, ]); }); + + test('apm data stream', () => { + expect(createSecurityLayerDescriptors('id', 'traces-apm-opbean-node')).toEqual([ + { + __dataRequests: [], + alpha: 0.75, + id: '12345', + includeInFitToBounds: true, + joins: [], + label: 'traces-apm-opbean-node | Source Point', + maxZoom: 24, + minZoom: 0, + sourceDescriptor: { + applyGlobalQuery: true, + applyGlobalTime: true, + filterByMapBounds: true, + geoField: 'client.geo.location', + id: '12345', + indexPatternId: 'id', + scalingType: 'TOP_HITS', + sortField: '', + sortOrder: 'desc', + tooltipProperties: [ + 'host.name', + 'client.ip', + 'client.domain', + 'client.geo.country_iso_code', + 'client.as.organization.name', + ], + topHitsSize: 1, + topHitsSplitField: 'client.ip', + type: 'ES_SEARCH', + }, + style: { + isTimeAware: true, + properties: { + fillColor: { + options: { + color: '#6092C0', + }, + type: 'STATIC', + }, + icon: { + options: { + value: 'home', + }, + type: 'STATIC', + }, + iconOrientation: { + options: { + orientation: 0, + }, + type: 'STATIC', + }, + iconSize: { + options: { + size: 8, + }, + type: 'STATIC', + }, + labelBorderColor: { + options: { + color: '#FFFFFF', + }, + type: 'STATIC', + }, + labelBorderSize: { + options: { + size: 'SMALL', + }, + }, + labelColor: { + options: { + color: '#000000', + }, + type: 'STATIC', + }, + labelSize: { + options: { + size: 14, + }, + type: 'STATIC', + }, + labelText: { + options: { + value: '', + }, + type: 'STATIC', + }, + lineColor: { + options: { + color: '#FFFFFF', + }, + type: 'STATIC', + }, + lineWidth: { + options: { + size: 2, + }, + type: 'STATIC', + }, + symbolizeAs: { + options: { + value: 'icon', + }, + }, + }, + type: 'VECTOR', + }, + type: 'VECTOR', + visible: true, + }, + { + __dataRequests: [], + alpha: 0.75, + id: '12345', + includeInFitToBounds: true, + joins: [], + label: 'traces-apm-opbean-node | Destination point', + maxZoom: 24, + minZoom: 0, + sourceDescriptor: { + applyGlobalQuery: true, + applyGlobalTime: true, + filterByMapBounds: true, + geoField: 'server.geo.location', + id: '12345', + indexPatternId: 'id', + scalingType: 'TOP_HITS', + sortField: '', + sortOrder: 'desc', + tooltipProperties: [ + 'host.name', + 'server.ip', + 'server.domain', + 'server.geo.country_iso_code', + 'server.as.organization.name', + ], + topHitsSize: 1, + topHitsSplitField: 'server.ip', + type: 'ES_SEARCH', + }, + style: { + isTimeAware: true, + properties: { + fillColor: { + options: { + color: '#D36086', + }, + type: 'STATIC', + }, + icon: { + options: { + value: 'marker', + }, + type: 'STATIC', + }, + iconOrientation: { + options: { + orientation: 0, + }, + type: 'STATIC', + }, + iconSize: { + options: { + size: 8, + }, + type: 'STATIC', + }, + labelBorderColor: { + options: { + color: '#FFFFFF', + }, + type: 'STATIC', + }, + labelBorderSize: { + options: { + size: 'SMALL', + }, + }, + labelColor: { + options: { + color: '#000000', + }, + type: 'STATIC', + }, + labelSize: { + options: { + size: 14, + }, + type: 'STATIC', + }, + labelText: { + options: { + value: '', + }, + type: 'STATIC', + }, + lineColor: { + options: { + color: '#FFFFFF', + }, + type: 'STATIC', + }, + lineWidth: { + options: { + size: 2, + }, + type: 'STATIC', + }, + symbolizeAs: { + options: { + value: 'icon', + }, + }, + }, + type: 'VECTOR', + }, + type: 'VECTOR', + visible: true, + }, + { + __dataRequests: [], + alpha: 0.75, + id: '12345', + includeInFitToBounds: true, + joins: [], + label: 'traces-apm-opbean-node | Line', + maxZoom: 24, + minZoom: 0, + sourceDescriptor: { + applyGlobalQuery: true, + applyGlobalTime: true, + destGeoField: 'server.geo.location', + id: '12345', + indexPatternId: 'id', + metrics: [ + { + field: 'client.bytes', + type: 'sum', + }, + { + field: 'server.bytes', + type: 'sum', + }, + ], + sourceGeoField: 'client.geo.location', + type: 'ES_PEW_PEW', + }, + style: { + isTimeAware: true, + properties: { + fillColor: { + options: { + color: '#54B399', + }, + type: 'STATIC', + }, + icon: { + options: { + value: 'marker', + }, + type: 'STATIC', + }, + iconOrientation: { + options: { + orientation: 0, + }, + type: 'STATIC', + }, + iconSize: { + options: { + size: 6, + }, + type: 'STATIC', + }, + labelBorderColor: { + options: { + color: '#FFFFFF', + }, + type: 'STATIC', + }, + labelBorderSize: { + options: { + size: 'SMALL', + }, + }, + labelColor: { + options: { + color: '#000000', + }, + type: 'STATIC', + }, + labelSize: { + options: { + size: 14, + }, + type: 'STATIC', + }, + labelText: { + options: { + value: '', + }, + type: 'STATIC', + }, + lineColor: { + options: { + color: '#6092C0', + }, + type: 'STATIC', + }, + lineWidth: { + options: { + field: { + name: 'doc_count', + origin: 'source', + }, + fieldMetaOptions: { + isEnabled: true, + sigma: 3, + }, + maxSize: 8, + minSize: 1, + }, + type: 'DYNAMIC', + }, + symbolizeAs: { + options: { + value: 'circle', + }, + }, + }, + type: 'VECTOR', + }, + type: 'VECTOR', + visible: true, + }, + ]); + }); }); diff --git a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.ts b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.ts index b2283196a41dd..8a40ba63bed0d 100644 --- a/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.ts +++ b/x-pack/plugins/maps/public/classes/layers/solution_layers/security/create_layer_descriptors.ts @@ -35,7 +35,11 @@ const defaultDynamicProperties = getDefaultDynamicProperties(); const euiVisColorPalette = euiPaletteColorBlind(); function isApmIndex(indexPatternTitle: string) { - return minimatch(indexPatternTitle, APM_INDEX_PATTERN_TITLE); + return APM_INDEX_PATTERN_TITLE.split(',') + .map((pattern) => { + return minimatch(indexPatternTitle, pattern); + }) + .some(Boolean); } function getSourceField(indexPatternTitle: string) {