diff --git a/x-pack/plugins/maps/common/telemetry/layer_stats_collector.test.ts b/x-pack/plugins/maps/common/telemetry/layer_stats_collector.test.ts index fbdfad705a0d4..1b9c6adfa2eb5 100644 --- a/x-pack/plugins/maps/common/telemetry/layer_stats_collector.test.ts +++ b/x-pack/plugins/maps/common/telemetry/layer_stats_collector.test.ts @@ -12,14 +12,14 @@ import { MapSavedObjectAttributes } from '../map_saved_object_type'; const expecteds = [ { - layerCount: 3, + layerCount: 4, basemapCounts: { roadmap: 1 }, joinCounts: {}, - layerCounts: { ems_basemap: 1, ems_region: 1, es_agg_clusters: 1 }, + layerCounts: { ems_basemap: 1, ems_region: 1, es_agg_clusters: 1, layer_group: 1 }, resolutionCounts: { coarse: 1 }, scalingCounts: {}, emsFileCounts: { italy_provinces: 1 }, - layerTypeCounts: { TILE: 1, GEOJSON_VECTOR: 2 }, + layerTypeCounts: { GEOJSON_VECTOR: 2, LAYER_GROUP: 1, TILE: 1 }, sourceCount: 3, }, { @@ -93,6 +93,10 @@ describe.each(testsToRun)('LayerStatsCollector %#', (attributes, expected) => { expect(statsCollector.getLayerCounts()).toEqual(expected.layerCounts); }); + test('getLayerTypeCounts', () => { + expect(statsCollector.getLayerTypeCounts()).toEqual(expected.layerTypeCounts); + }); + test('getResolutionCounts', () => { expect(statsCollector.getResolutionCounts()).toEqual(expected.resolutionCounts); }); diff --git a/x-pack/plugins/maps/common/telemetry/layer_stats_collector.ts b/x-pack/plugins/maps/common/telemetry/layer_stats_collector.ts index 0978b3ace87ec..e31f4120194f6 100644 --- a/x-pack/plugins/maps/common/telemetry/layer_stats_collector.ts +++ b/x-pack/plugins/maps/common/telemetry/layer_stats_collector.ts @@ -155,14 +155,18 @@ function getJoinKey(layerDescriptor: LayerDescriptor): JOIN_KEYS | null { } function getLayerKey(layerDescriptor: LayerDescriptor): LAYER_KEYS | null { - if (!layerDescriptor.sourceDescriptor) { - return null; - } - if (layerDescriptor.type === LAYER_TYPE.HEATMAP) { return LAYER_KEYS.ES_AGG_HEATMAP; } + if (layerDescriptor.type === LAYER_TYPE.LAYER_GROUP) { + return LAYER_KEYS.LAYER_GROUP; + } + + if (!layerDescriptor.sourceDescriptor) { + return null; + } + if (layerDescriptor.sourceDescriptor.type === SOURCE_TYPES.EMS_FILE) { return LAYER_KEYS.EMS_REGION; } diff --git a/x-pack/plugins/maps/common/telemetry/test_resources/sample_map_saved_objects.json b/x-pack/plugins/maps/common/telemetry/test_resources/sample_map_saved_objects.json index 908bacb091aea..a8efb534de5c4 100644 --- a/x-pack/plugins/maps/common/telemetry/test_resources/sample_map_saved_objects.json +++ b/x-pack/plugins/maps/common/telemetry/test_resources/sample_map_saved_objects.json @@ -6,7 +6,7 @@ "title": "Italy Map", "description": "", "mapStateJSON": "{\"zoom\":4.82,\"center\":{\"lon\":11.41545,\"lat\":42.0865},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"language\":\"lucene\",\"query\":\"\"}}", - "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"GEOJSON_VECTOR\"}]", + "layerListJSON": "[{\"id\":\"123\",\"label\":\"Layer Group\",\"sourceDescriptor\":null,\"type\":\"LAYER_GROUP\"},{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"GEOJSON_VECTOR\"}]", "uiStateJSON": "{}" }, "references": [ diff --git a/x-pack/plugins/maps/common/telemetry/types.ts b/x-pack/plugins/maps/common/telemetry/types.ts index 7b0dfc4eae3bb..b0d740bf4f239 100644 --- a/x-pack/plugins/maps/common/telemetry/types.ts +++ b/x-pack/plugins/maps/common/telemetry/types.ts @@ -29,6 +29,7 @@ export enum LAYER_KEYS { EMS_REGION = 'ems_region', EMS_BASEMAP = 'ems_basemap', KBN_TMS_RASTER = 'kbn_tms_raster', + LAYER_GROUP = 'layer_group', UX_TMS_RASTER = 'ux_tms_raster', // configured in the UX layer wizard of Maps UX_TMS_MVT = 'ux_tms_mvt', // configured in the UX layer wizard of Maps UX_WMS = 'ux_wms', // configured in the UX layer wizard of Maps diff --git a/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts b/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts index 24b2707064c32..9f2e520c428a2 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts @@ -166,6 +166,18 @@ export function registerMapsUsageCollector(usageCollection?: UsageCollectionSetu _meta: { description: 'total number of kbn tms layers in cluster' }, }, }, + layer_group: { + min: { type: 'long', _meta: { description: 'min number of layer groups per map' } }, + max: { type: 'long', _meta: { description: 'max number of layer groups per map' } }, + avg: { + type: 'float', + _meta: { description: 'avg number of layer groups per map' }, + }, + total: { + type: 'long', + _meta: { description: 'total number of layer groups in cluster' }, + }, + }, ux_tms_mvt: { min: { type: 'long', _meta: { description: 'min number of ux tms-mvt layers per map' } }, max: { type: 'long', _meta: { description: 'max number of ux tms-mvt layers per map' } }, diff --git a/x-pack/plugins/maps/server/maps_telemetry/map_stats/map_stats_collector.test.ts b/x-pack/plugins/maps/server/maps_telemetry/map_stats/map_stats_collector.test.ts index 48860338ae11f..a4dd0df8e2712 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/map_stats/map_stats_collector.test.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/map_stats/map_stats_collector.test.ts @@ -84,6 +84,12 @@ test('returns expected telemetry data from saved objects', () => { min: 1, total: 1, }, + layer_group: { + avg: 0.2, + max: 1, + min: 1, + total: 1, + }, }, scalingOptions: { limit: { @@ -151,6 +157,11 @@ test('returns expected telemetry data from saved objects', () => { max: 1, min: 1, }, + LAYER_GROUP: { + avg: 0.2, + max: 1, + min: 1, + }, TILE: { avg: 0.6, max: 1, @@ -163,8 +174,8 @@ test('returns expected telemetry data from saved objects', () => { }, }, layersCount: { - avg: 2, - max: 3, + avg: 2.2, + max: 4, min: 1, }, }, diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index aa1ad20363166..af39095245086 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -5618,6 +5618,34 @@ } } }, + "layer_group": { + "properties": { + "min": { + "type": "long", + "_meta": { + "description": "min number of layer groups per map" + } + }, + "max": { + "type": "long", + "_meta": { + "description": "max number of layer groups per map" + } + }, + "avg": { + "type": "float", + "_meta": { + "description": "avg number of layer groups per map" + } + }, + "total": { + "type": "long", + "_meta": { + "description": "total number of layer groups in cluster" + } + } + } + }, "ux_tms_mvt": { "properties": { "min": {