Skip to content

Commit

Permalink
[Maps] [Telemetry] Track geo_point and geo_shape index patterns separ…
Browse files Browse the repository at this point in the history
…ately (#65195)
  • Loading branch information
thomasneirynck authored May 5, 2020
1 parent 602d102 commit d3ea775
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
6 changes: 6 additions & 0 deletions x-pack/legacy/plugins/maps/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"indexPatternsWithGeoFieldCount": {
"type": "long"
},
"indexPatternsWithGeoPointFieldCount": {
"type": "long"
},
"indexPatternsWithGeoShapeFieldCount": {
"type": "long"
},
"mapsTotalCount": {
"type": "long"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('buildMapsTelemetry', () => {

expect(result).toMatchObject({
indexPatternsWithGeoFieldCount: 0,
indexPatternsWithGeoPointFieldCount: 0,
indexPatternsWithGeoShapeFieldCount: 0,
attributesPerMap: {
dataSourcesCount: {
avg: 0,
Expand All @@ -45,7 +47,9 @@ describe('buildMapsTelemetry', () => {
const result = buildMapsTelemetry({ mapSavedObjects, indexPatternSavedObjects, settings });

expect(result).toMatchObject({
indexPatternsWithGeoFieldCount: 2,
indexPatternsWithGeoFieldCount: 3,
indexPatternsWithGeoPointFieldCount: 2,
indexPatternsWithGeoShapeFieldCount: 1,
attributesPerMap: {
dataSourcesCount: {
avg: 2.6666666666666665,
Expand Down
26 changes: 22 additions & 4 deletions x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,27 @@ function getIndexPatternsWithGeoFieldCount(indexPatterns: IIndexPattern[]) {
? JSON.parse(indexPattern.attributes.fields)
: []
);

const fieldListsWithGeoFields = fieldLists.filter(fields =>
fields.some(
(field: IFieldType) =>
field.type === ES_GEO_FIELD_TYPE.GEO_POINT || field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE
)
);
return fieldListsWithGeoFields.length;

const fieldListsWithGeoPointFields = fieldLists.filter(fields =>
fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_POINT)
);

const fieldListsWithGeoShapeFields = fieldLists.filter(fields =>
fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE)
);

return {
indexPatternsWithGeoFieldCount: fieldListsWithGeoFields.length,
indexPatternsWithGeoPointFieldCount: fieldListsWithGeoPointFields.length,
indexPatternsWithGeoShapeFieldCount: fieldListsWithGeoShapeFields.length,
};
}

export function buildMapsTelemetry({
Expand Down Expand Up @@ -110,12 +124,16 @@ export function buildMapsTelemetry({
const dataSourcesCountSum = _.sum(dataSourcesCount);
const layersCountSum = _.sum(layersCount);

const indexPatternsWithGeoFieldCount = getIndexPatternsWithGeoFieldCount(
indexPatternSavedObjects
);
const {
indexPatternsWithGeoFieldCount,
indexPatternsWithGeoPointFieldCount,
indexPatternsWithGeoShapeFieldCount,
} = getIndexPatternsWithGeoFieldCount(indexPatternSavedObjects);
return {
settings,
indexPatternsWithGeoFieldCount,
indexPatternsWithGeoPointFieldCount,
indexPatternsWithGeoShapeFieldCount,
// Total count of maps
mapsTotalCount: mapsCount,
// Time of capture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
"updated_at": "2019-11-19T20:05:37.607Z",
"version": "WzExMSwxXQ=="
},
{
"attributes": {
"fields": "[{\"name\":\"geometry\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",
"title": "indexpattern-with-geopoint2"
},
"id": "55d572f0-0b07-11ea-9dd2-95afd7ad44d4",
"migrationVersion": {
"index-pattern": "7.6.0"
},
"references": [],
"type": "index-pattern",
"updated_at": "2019-11-19T20:05:37.607Z",
"version": "WzExMSwxXQ=="
},
{
"attributes": {
"fields": "[{\"name\":\"assessment_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"date_exterior_condition\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"recording_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"sale_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",
Expand Down

0 comments on commit d3ea775

Please sign in to comment.