[Maps] Use new index patterns service for Maps telemetry (#86703)

Co-authored-by: Matt Kime <matt@mattki.me>
This commit is contained in:
Aaron Caldwell 2021-02-19 08:00:01 -07:00 committed by GitHub
parent 4d34a13bab
commit eea6f82e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 617 additions and 193 deletions

View file

@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [(constructor)](./kibana-plugin-plugins-data-server.indexpatternsservice._constructor_.md)
## IndexPatternsService.(constructor)
Constructs a new instance of the `IndexPatternsService` class
<b>Signature:</b>
```typescript
constructor({ uiSettings, savedObjectsClient, apiClient, fieldFormats, onNotification, onError, onRedirectNoIndexPattern, }: IndexPatternsServiceDeps);
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| { uiSettings, savedObjectsClient, apiClient, fieldFormats, onNotification, onError, onRedirectNoIndexPattern, } | <code>IndexPatternsServiceDeps</code> | |

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [clearCache](./kibana-plugin-plugins-data-server.indexpatternsservice.clearcache.md)
## IndexPatternsService.clearCache property
Clear index pattern list cache
<b>Signature:</b>
```typescript
clearCache: (id?: string | undefined) => void;
```

View file

@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [create](./kibana-plugin-plugins-data-server.indexpatternsservice.create.md)
## IndexPatternsService.create() method
Create a new index pattern instance
<b>Signature:</b>
```typescript
create(spec: IndexPatternSpec, skipFetchFields?: boolean): Promise<IndexPattern>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| spec | <code>IndexPatternSpec</code> | |
| skipFetchFields | <code>boolean</code> | |
<b>Returns:</b>
`Promise<IndexPattern>`
IndexPattern

View file

@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [createAndSave](./kibana-plugin-plugins-data-server.indexpatternsservice.createandsave.md)
## IndexPatternsService.createAndSave() method
Create a new index pattern and save it right away
<b>Signature:</b>
```typescript
createAndSave(spec: IndexPatternSpec, override?: boolean, skipFetchFields?: boolean): Promise<IndexPattern>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| spec | <code>IndexPatternSpec</code> | |
| override | <code>boolean</code> | |
| skipFetchFields | <code>boolean</code> | |
<b>Returns:</b>
`Promise<IndexPattern>`

View file

@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [createSavedObject](./kibana-plugin-plugins-data-server.indexpatternsservice.createsavedobject.md)
## IndexPatternsService.createSavedObject() method
Save a new index pattern
<b>Signature:</b>
```typescript
createSavedObject(indexPattern: IndexPattern, override?: boolean): Promise<IndexPattern>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| indexPattern | <code>IndexPattern</code> | |
| override | <code>boolean</code> | |
<b>Returns:</b>
`Promise<IndexPattern>`

View file

@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [delete](./kibana-plugin-plugins-data-server.indexpatternsservice.delete.md)
## IndexPatternsService.delete() method
Deletes an index pattern from .kibana index
<b>Signature:</b>
```typescript
delete(indexPatternId: string): Promise<{}>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| indexPatternId | <code>string</code> | |
<b>Returns:</b>
`Promise<{}>`

View file

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [ensureDefaultIndexPattern](./kibana-plugin-plugins-data-server.indexpatternsservice.ensuredefaultindexpattern.md)
## IndexPatternsService.ensureDefaultIndexPattern property
<b>Signature:</b>
```typescript
ensureDefaultIndexPattern: EnsureDefaultIndexPattern;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [fieldArrayToMap](./kibana-plugin-plugins-data-server.indexpatternsservice.fieldarraytomap.md)
## IndexPatternsService.fieldArrayToMap property
Converts field array to map
<b>Signature:</b>
```typescript
fieldArrayToMap: (fields: FieldSpec[], fieldAttrs?: FieldAttrs | undefined) => Record<string, FieldSpec>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [find](./kibana-plugin-plugins-data-server.indexpatternsservice.find.md)
## IndexPatternsService.find property
Find and load index patterns by title
<b>Signature:</b>
```typescript
find: (search: string, size?: number) => Promise<IndexPattern[]>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [get](./kibana-plugin-plugins-data-server.indexpatternsservice.get.md)
## IndexPatternsService.get property
Get an index pattern by id. Cache optimized
<b>Signature:</b>
```typescript
get: (id: string) => Promise<IndexPattern>;
```

View file

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getCache](./kibana-plugin-plugins-data-server.indexpatternsservice.getcache.md)
## IndexPatternsService.getCache property
<b>Signature:</b>
```typescript
getCache: () => Promise<SavedObject<IndexPatternSavedObjectAttrs>[] | null | undefined>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.getdefault.md)
## IndexPatternsService.getDefault property
Get default index pattern
<b>Signature:</b>
```typescript
getDefault: () => Promise<IndexPattern | null>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getFieldsForIndexPattern](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforindexpattern.md)
## IndexPatternsService.getFieldsForIndexPattern property
Get field list by providing an index patttern (or spec)
<b>Signature:</b>
```typescript
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getFieldsForWildcard](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforwildcard.md)
## IndexPatternsService.getFieldsForWildcard property
Get field list by providing { pattern }
<b>Signature:</b>
```typescript
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getIds](./kibana-plugin-plugins-data-server.indexpatternsservice.getids.md)
## IndexPatternsService.getIds property
Get list of index pattern ids
<b>Signature:</b>
```typescript
getIds: (refresh?: boolean) => Promise<string[]>;
```

View file

@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getIdsWithTitle](./kibana-plugin-plugins-data-server.indexpatternsservice.getidswithtitle.md)
## IndexPatternsService.getIdsWithTitle property
Get list of index pattern ids with titles
<b>Signature:</b>
```typescript
getIdsWithTitle: (refresh?: boolean) => Promise<Array<{
id: string;
title: string;
}>>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [getTitles](./kibana-plugin-plugins-data-server.indexpatternsservice.gettitles.md)
## IndexPatternsService.getTitles property
Get list of index pattern titles
<b>Signature:</b>
```typescript
getTitles: (refresh?: boolean) => Promise<string[]>;
```

View file

@ -7,13 +7,42 @@
<b>Signature:</b>
```typescript
export declare class IndexPatternsServiceProvider implements Plugin<void, IndexPatternsServiceStart>
export declare class IndexPatternsService
```
## Constructors
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)({ uiSettings, savedObjectsClient, apiClient, fieldFormats, onNotification, onError, onRedirectNoIndexPattern, })](./kibana-plugin-plugins-data-server.indexpatternsservice._constructor_.md) | | Constructs a new instance of the <code>IndexPatternsService</code> class |
## Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [clearCache](./kibana-plugin-plugins-data-server.indexpatternsservice.clearcache.md) | | <code>(id?: string &#124; undefined) =&gt; void</code> | Clear index pattern list cache |
| [ensureDefaultIndexPattern](./kibana-plugin-plugins-data-server.indexpatternsservice.ensuredefaultindexpattern.md) | | <code>EnsureDefaultIndexPattern</code> | |
| [fieldArrayToMap](./kibana-plugin-plugins-data-server.indexpatternsservice.fieldarraytomap.md) | | <code>(fields: FieldSpec[], fieldAttrs?: FieldAttrs &#124; undefined) =&gt; Record&lt;string, FieldSpec&gt;</code> | Converts field array to map |
| [find](./kibana-plugin-plugins-data-server.indexpatternsservice.find.md) | | <code>(search: string, size?: number) =&gt; Promise&lt;IndexPattern[]&gt;</code> | Find and load index patterns by title |
| [get](./kibana-plugin-plugins-data-server.indexpatternsservice.get.md) | | <code>(id: string) =&gt; Promise&lt;IndexPattern&gt;</code> | Get an index pattern by id. Cache optimized |
| [getCache](./kibana-plugin-plugins-data-server.indexpatternsservice.getcache.md) | | <code>() =&gt; Promise&lt;SavedObject&lt;IndexPatternSavedObjectAttrs&gt;[] &#124; null &#124; undefined&gt;</code> | |
| [getDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.getdefault.md) | | <code>() =&gt; Promise&lt;IndexPattern &#124; null&gt;</code> | Get default index pattern |
| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforindexpattern.md) | | <code>(indexPattern: IndexPattern &#124; IndexPatternSpec, options?: GetFieldsOptions &#124; undefined) =&gt; Promise&lt;any&gt;</code> | Get field list by providing an index patttern (or spec) |
| [getFieldsForWildcard](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforwildcard.md) | | <code>(options: GetFieldsOptions) =&gt; Promise&lt;any&gt;</code> | Get field list by providing { pattern } |
| [getIds](./kibana-plugin-plugins-data-server.indexpatternsservice.getids.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;string[]&gt;</code> | Get list of index pattern ids |
| [getIdsWithTitle](./kibana-plugin-plugins-data-server.indexpatternsservice.getidswithtitle.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;Array&lt;{</code><br/><code> id: string;</code><br/><code> title: string;</code><br/><code> }&gt;&gt;</code> | Get list of index pattern ids with titles |
| [getTitles](./kibana-plugin-plugins-data-server.indexpatternsservice.gettitles.md) | | <code>(refresh?: boolean) =&gt; Promise&lt;string[]&gt;</code> | Get list of index pattern titles |
| [refreshFields](./kibana-plugin-plugins-data-server.indexpatternsservice.refreshfields.md) | | <code>(indexPattern: IndexPattern) =&gt; Promise&lt;void&gt;</code> | Refresh field list for a given index pattern |
| [savedObjectToSpec](./kibana-plugin-plugins-data-server.indexpatternsservice.savedobjecttospec.md) | | <code>(savedObject: SavedObject&lt;IndexPatternAttributes&gt;) =&gt; IndexPatternSpec</code> | Converts index pattern saved object to index pattern spec |
| [setDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.setdefault.md) | | <code>(id: string, force?: boolean) =&gt; Promise&lt;void&gt;</code> | Optionally set default index pattern, unless force = true |
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [setup(core, { expressions })](./kibana-plugin-plugins-data-server.indexpatternsservice.setup.md) | | |
| [start(core, { fieldFormats, logger })](./kibana-plugin-plugins-data-server.indexpatternsservice.start.md) | | |
| [create(spec, skipFetchFields)](./kibana-plugin-plugins-data-server.indexpatternsservice.create.md) | | Create a new index pattern instance |
| [createAndSave(spec, override, skipFetchFields)](./kibana-plugin-plugins-data-server.indexpatternsservice.createandsave.md) | | Create a new index pattern and save it right away |
| [createSavedObject(indexPattern, override)](./kibana-plugin-plugins-data-server.indexpatternsservice.createsavedobject.md) | | Save a new index pattern |
| [delete(indexPatternId)](./kibana-plugin-plugins-data-server.indexpatternsservice.delete.md) | | Deletes an index pattern from .kibana index |
| [updateSavedObject(indexPattern, saveAttempts, ignoreErrors)](./kibana-plugin-plugins-data-server.indexpatternsservice.updatesavedobject.md) | | Save existing index pattern. Will attempt to merge differences if there are conflicts |

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [refreshFields](./kibana-plugin-plugins-data-server.indexpatternsservice.refreshfields.md)
## IndexPatternsService.refreshFields property
Refresh field list for a given index pattern
<b>Signature:</b>
```typescript
refreshFields: (indexPattern: IndexPattern) => Promise<void>;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [savedObjectToSpec](./kibana-plugin-plugins-data-server.indexpatternsservice.savedobjecttospec.md)
## IndexPatternsService.savedObjectToSpec property
Converts index pattern saved object to index pattern spec
<b>Signature:</b>
```typescript
savedObjectToSpec: (savedObject: SavedObject<IndexPatternAttributes>) => IndexPatternSpec;
```

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [setDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.setdefault.md)
## IndexPatternsService.setDefault property
Optionally set default index pattern, unless force = true
<b>Signature:</b>
```typescript
setDefault: (id: string, force?: boolean) => Promise<void>;
```

View file

@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [updateSavedObject](./kibana-plugin-plugins-data-server.indexpatternsservice.updatesavedobject.md)
## IndexPatternsService.updateSavedObject() method
Save existing index pattern. Will attempt to merge differences if there are conflicts
<b>Signature:</b>
```typescript
updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| indexPattern | <code>IndexPattern</code> | |
| saveAttempts | <code>number</code> | |
| ignoreErrors | <code>boolean</code> | |
<b>Returns:</b>
`Promise<void | Error>`

View file

@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsServiceProvider](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.md)
## IndexPatternsServiceProvider class
<b>Signature:</b>
```typescript
export declare class IndexPatternsServiceProvider implements Plugin<void, IndexPatternsServiceStart>
```
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [setup(core, { expressions })](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.setup.md) | | |
| [start(core, { fieldFormats, logger })](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.start.md) | | |

View file

@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [setup](./kibana-plugin-plugins-data-server.indexpatternsservice.setup.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsServiceProvider](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.md) &gt; [setup](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.setup.md)
## IndexPatternsService.setup() method
## IndexPatternsServiceProvider.setup() method
<b>Signature:</b>

View file

@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) &gt; [start](./kibana-plugin-plugins-data-server.indexpatternsservice.start.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [IndexPatternsServiceProvider](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.md) &gt; [start](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.start.md)
## IndexPatternsService.start() method
## IndexPatternsServiceProvider.start() method
<b>Signature:</b>

View file

@ -12,6 +12,7 @@
| [IndexPattern](./kibana-plugin-plugins-data-server.indexpattern.md) | |
| [IndexPatternsFetcher](./kibana-plugin-plugins-data-server.indexpatternsfetcher.md) | |
| [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) | |
| [IndexPatternsServiceProvider](./kibana-plugin-plugins-data-server.indexpatternsserviceprovider.md) | |
| [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) | |
| [Plugin](./kibana-plugin-plugins-data-server.plugin.md) | |

View file

@ -12,7 +12,7 @@ start(core: CoreStart): {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
indexPatterns: {
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import("../public").IndexPatternsService>;
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import(".").IndexPatternsService>;
};
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
};
@ -31,7 +31,7 @@ start(core: CoreStart): {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
indexPatterns: {
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import("../public").IndexPatternsService>;
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import(".").IndexPatternsService>;
};
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
}`

View file

@ -146,6 +146,8 @@ export {
UI_SETTINGS,
IndexPattern,
IndexPatternLoadExpressionFunctionDefinition,
IndexPatternsService,
IndexPatternsService as IndexPatternsCommonService,
} from '../common';
/**
@ -306,4 +308,4 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
schema: configSchema,
};
export type { IndexPatternsServiceProvider as IndexPatternsService } from './index_patterns';
export type { IndexPatternsServiceProvider } from './index_patterns';

View file

@ -19,7 +19,7 @@ import { DataPluginStartDependencies, DataPluginStart } from '../plugin';
import { registerRoutes } from './routes';
import { indexPatternSavedObjectType } from '../saved_objects';
import { capabilitiesProvider } from './capabilities_provider';
import { IndexPatternsService as IndexPatternsCommonService } from '../../common/index_patterns';
import { IndexPatternsCommonService } from '../';
import { FieldFormatsStart } from '../field_formats';
import { getIndexPatternLoad } from './expressions';
import { UiSettingsServerToCommon } from './ui_settings_wrapper';

View file

@ -889,11 +889,54 @@ export class IndexPatternsFetcher {
validatePatternListActive(patternList: string[]): Promise<string[]>;
}
// Warning: (ae-missing-release-tag) "IndexPatternsService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
class IndexPatternsService {
// Warning: (ae-forgotten-export) The symbol "IndexPatternsServiceDeps" needs to be exported by the entry point index.d.ts
constructor({ uiSettings, savedObjectsClient, apiClient, fieldFormats, onNotification, onError, onRedirectNoIndexPattern, }: IndexPatternsServiceDeps);
clearCache: (id?: string | undefined) => void;
create(spec: IndexPatternSpec, skipFetchFields?: boolean): Promise<IndexPattern>;
createAndSave(spec: IndexPatternSpec, override?: boolean, skipFetchFields?: boolean): Promise<IndexPattern>;
createSavedObject(indexPattern: IndexPattern, override?: boolean): Promise<IndexPattern>;
delete(indexPatternId: string): Promise<{}>;
// Warning: (ae-forgotten-export) The symbol "EnsureDefaultIndexPattern" needs to be exported by the entry point index.d.ts
//
// (undocumented)
ensureDefaultIndexPattern: EnsureDefaultIndexPattern;
// Warning: (ae-forgotten-export) The symbol "FieldAttrs" needs to be exported by the entry point index.d.ts
fieldArrayToMap: (fields: FieldSpec[], fieldAttrs?: FieldAttrs | undefined) => Record<string, FieldSpec>;
find: (search: string, size?: number) => Promise<IndexPattern[]>;
get: (id: string) => Promise<IndexPattern>;
// Warning: (ae-forgotten-export) The symbol "IndexPatternSavedObjectAttrs" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCache: () => Promise<SavedObject_2<IndexPatternSavedObjectAttrs>[] | null | undefined>;
getDefault: () => Promise<IndexPattern | null>;
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>;
// Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
getIds: (refresh?: boolean) => Promise<string[]>;
getIdsWithTitle: (refresh?: boolean) => Promise<Array<{
id: string;
title: string;
}>>;
getTitles: (refresh?: boolean) => Promise<string[]>;
refreshFields: (indexPattern: IndexPattern) => Promise<void>;
savedObjectToSpec: (savedObject: SavedObject_2<IndexPatternAttributes>) => IndexPatternSpec;
setDefault: (id: string, force?: boolean) => Promise<void>;
updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>;
}
export { IndexPatternsService as IndexPatternsCommonService }
export { IndexPatternsService }
// Warning: (ae-forgotten-export) The symbol "IndexPatternsServiceStart" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "IndexPatternsServiceProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class IndexPatternsService implements Plugin_3<void, IndexPatternsServiceStart> {
export class IndexPatternsServiceProvider implements Plugin_3<void, IndexPatternsServiceStart> {
// Warning: (ae-forgotten-export) The symbol "DataPluginStartDependencies" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "IndexPatternsServiceSetupDeps" needs to be exported by the entry point index.d.ts
//
@ -903,7 +946,7 @@ export class IndexPatternsService implements Plugin_3<void, IndexPatternsService
//
// (undocumented)
start(core: CoreStart, { fieldFormats, logger }: IndexPatternsServiceStartDeps): {
indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract_2, elasticsearchClient: ElasticsearchClient_2) => Promise<IndexPatternsService_2>;
indexPatternsServiceFactory: (savedObjectsClient: SavedObjectsClientContract_2, elasticsearchClient: ElasticsearchClient_2) => Promise<IndexPatternsService>;
};
}
@ -1139,7 +1182,7 @@ export class Plugin implements Plugin_2<PluginSetup, PluginStart, DataPluginSetu
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
indexPatterns: {
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import("../public").IndexPatternsService>;
indexPatternsServiceFactory: (savedObjectsClient: Pick<import("../../../core/server").SavedObjectsClient, "get" | "delete" | "closePointInTime" | "create" | "update" | "bulkCreate" | "checkConflicts" | "find" | "bulkGet" | "resolve" | "addToNamespaces" | "deleteFromNamespaces" | "bulkUpdate" | "removeReferencesTo" | "openPointInTimeForType" | "errors">, elasticsearchClient: import("../../../core/server").ElasticsearchClient) => Promise<import(".").IndexPatternsService>;
};
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
};
@ -1418,21 +1461,20 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
// src/plugins/data/server/index.ts:100:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:126:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:126:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:239:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:239:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:239:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:239:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:242:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:251:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:252:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:253:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:257:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:258:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:262:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:265:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:266:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index_patterns/index_patterns_service.ts:59:14 - (ae-forgotten-export) The symbol "IndexPatternsService" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:243:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:244:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:253:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:254:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:255:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:259:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:260:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:264:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:267:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:268:1 - (ae-forgotten-export) The symbol "calcAutoIntervalLessThan" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/plugin.ts:79:74 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/search/types.ts:114:5 - (ae-forgotten-export) The symbol "ISearchStartSearchSource" needs to be exported by the entry point index.d.ts

View file

@ -5,7 +5,11 @@
* 2.0.
*/
import { ISavedObjectsRepository } from 'kibana/server';
import { ElasticsearchClient, ISavedObjectsRepository } from 'kibana/server';
import { SavedObjectsClient } from '../../../../src/core/server';
import { IndexPatternsCommonService } from '../../../../src/plugins/data/server';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { IndexPatternsServiceStart } from '../../../../src/plugins/data/server/index_patterns';
let internalRepository: ISavedObjectsRepository;
export const setInternalRepository = (
@ -14,3 +18,15 @@ export const setInternalRepository = (
internalRepository = createInternalRepository();
};
export const getInternalRepository = () => internalRepository;
let indexPatternsService: IndexPatternsCommonService;
export const setIndexPatternsService = async (
indexPatternsServiceFactory: IndexPatternsServiceStart['indexPatternsServiceFactory'],
elasticsearchClient: ElasticsearchClient
) => {
indexPatternsService = await indexPatternsServiceFactory(
new SavedObjectsClient(getInternalRepository()),
elasticsearchClient
);
};
export const getIndexPatternsService = () => indexPatternsService;

View file

@ -6,13 +6,70 @@
*/
import mapSavedObjects from './test_resources/sample_map_saved_objects.json';
import indexPatternSavedObjects from './test_resources/sample_index_pattern_saved_objects';
import {
buildMapsIndexPatternsTelemetry,
buildMapsSavedObjectsTelemetry,
getLayerLists,
} from './maps_telemetry';
jest.mock('../kibana_server_services', () => {
// Mocked for geo shape agg detection
const testAggIndexPatternId = '4a7f6010-0aed-11ea-9dd2-95afd7ad44d4';
const testAggIndexPattern = {
id: testAggIndexPatternId,
fields: [
{
name: 'geometry',
esTypes: ['geo_shape'],
},
],
};
const testIndexPatterns = {
1: {
id: '1',
fields: [
{
name: 'one',
esTypes: ['geo_point'],
},
],
},
2: {
id: '2',
fields: [
{
name: 'two',
esTypes: ['geo_point'],
},
],
},
3: {
id: '3',
fields: [
{
name: 'three',
esTypes: ['geo_shape'],
},
],
},
};
return {
getIndexPatternsService() {
return {
async get(x) {
return x === testAggIndexPatternId ? testAggIndexPattern : testIndexPatterns[x];
},
async getIds() {
return Object.values(testIndexPatterns).map((x) => x.id);
},
async getFieldsForIndexPattern(x) {
return x.fields;
},
};
},
};
});
describe('buildMapsSavedObjectsTelemetry', () => {
test('returns zeroed telemetry data when there are no saved objects', async () => {
const result = buildMapsSavedObjectsTelemetry([]);
@ -88,7 +145,7 @@ describe('buildMapsSavedObjectsTelemetry', () => {
test('returns expected telemetry data from index patterns', async () => {
const layerLists = getLayerLists(mapSavedObjects);
const result = buildMapsIndexPatternsTelemetry(indexPatternSavedObjects, layerLists);
const result = await buildMapsIndexPatternsTelemetry(layerLists);
expect(result).toMatchObject({
indexPatternsWithGeoFieldCount: 3,

View file

@ -7,7 +7,7 @@
import _ from 'lodash';
import { SavedObject } from 'kibana/server';
import { IFieldType, IndexPatternAttributes } from 'src/plugins/data/public';
import { IFieldType } from 'src/plugins/data/public';
import {
ES_GEO_FIELD_TYPE,
LAYER_TYPE,
@ -22,7 +22,7 @@ import {
LayerDescriptor,
} from '../../common/descriptor_types';
import { MapSavedObject, MapSavedObjectAttributes } from '../../common/map_saved_object_type';
import { getInternalRepository } from '../kibana_server_services';
import { getIndexPatternsService, getInternalRepository } from '../kibana_server_services';
import { MapsConfigType } from '../../config';
interface Settings {
@ -94,37 +94,6 @@ function getUniqueLayerCounts(layerCountsList: ILayerTypeCount[], mapsCount: num
}, {});
}
function getIndexPatternsWithGeoFieldCount(
indexPatterns: Array<SavedObject<IndexPatternAttributes>>
) {
const fieldLists = indexPatterns.map((indexPattern) =>
indexPattern.attributes && indexPattern.attributes.fields
? 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
)
);
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,
};
}
function getEMSLayerCount(layerLists: LayerDescriptor[][]): ILayerTypeCount[] {
return layerLists.map((layerList: LayerDescriptor[]) => {
const emsLayers = layerList.filter((layer: LayerDescriptor) => {
@ -143,41 +112,25 @@ function getEMSLayerCount(layerLists: LayerDescriptor[][]): ILayerTypeCount[] {
}) as ILayerTypeCount[];
}
function isFieldGeoShape(
indexPatterns: Array<SavedObject<IndexPatternAttributes>>,
async function isFieldGeoShape(
indexPatternId: string,
geoField: string | undefined
): boolean {
if (!geoField) {
): Promise<boolean> {
if (!geoField || !indexPatternId) {
return false;
}
const matchIndexPattern = indexPatterns.find(
(indexPattern: SavedObject<IndexPatternAttributes>) => {
return indexPattern.id === indexPatternId;
}
const indexPatternsService = await getIndexPatternsService();
const indexPattern = await indexPatternsService.get(indexPatternId);
if (!indexPattern) {
return false;
}
const fieldsForIndexPattern = await indexPatternsService.getFieldsForIndexPattern(indexPattern);
return fieldsForIndexPattern.some(
(fieldDescriptor: IFieldType) => fieldDescriptor.name && fieldDescriptor.name === geoField!
);
if (!matchIndexPattern) {
return false;
}
const fieldList: IFieldType[] =
matchIndexPattern.attributes && matchIndexPattern.attributes.fields
? JSON.parse(matchIndexPattern.attributes.fields)
: [];
const matchField = fieldList.find((field: IFieldType) => {
return field.name === geoField;
});
return !!matchField && matchField.type === ES_GEO_FIELD_TYPE.GEO_SHAPE;
}
function isGeoShapeAggLayer(
indexPatterns: Array<SavedObject<IndexPatternAttributes>>,
layer: LayerDescriptor
): boolean {
async function isGeoShapeAggLayer(layer: LayerDescriptor): Promise<boolean> {
if (layer.sourceDescriptor === null) {
return false;
}
@ -192,8 +145,7 @@ function isGeoShapeAggLayer(
const sourceDescriptor = layer.sourceDescriptor;
if (sourceDescriptor.type === SOURCE_TYPES.ES_GEO_GRID) {
return isFieldGeoShape(
indexPatterns,
return await isFieldGeoShape(
(sourceDescriptor as ESGeoGridSourceDescriptor).indexPatternId,
(sourceDescriptor as ESGeoGridSourceDescriptor).geoField
);
@ -201,8 +153,7 @@ function isGeoShapeAggLayer(
sourceDescriptor.type === SOURCE_TYPES.ES_SEARCH &&
(sourceDescriptor as ESSearchSourceDescriptor).scalingType === SCALING_TYPES.CLUSTERS
) {
return isFieldGeoShape(
indexPatterns,
return await isFieldGeoShape(
(sourceDescriptor as ESSearchSourceDescriptor).indexPatternId,
(sourceDescriptor as ESSearchSourceDescriptor).geoField
);
@ -211,17 +162,15 @@ function isGeoShapeAggLayer(
}
}
function getGeoShapeAggCount(
layerLists: LayerDescriptor[][],
indexPatterns: Array<SavedObject<IndexPatternAttributes>>
): number {
const countsPerMap: number[] = layerLists.map((layerList: LayerDescriptor[]) => {
const geoShapeAggLayers = layerList.filter((layerDescriptor) => {
return isGeoShapeAggLayer(indexPatterns, layerDescriptor);
});
return geoShapeAggLayers.length;
});
async function getGeoShapeAggCount(layerLists: LayerDescriptor[][]): Promise<number> {
const countsPerMap: number[] = await Promise.all(
layerLists.map(async (layerList: LayerDescriptor[]) => {
const boolIsAggLayerArr = await Promise.all(
layerList.map(async (layerDescriptor) => await isGeoShapeAggLayer(layerDescriptor))
);
return boolIsAggLayerArr.filter((x) => x).length;
})
);
return _.sum(countsPerMap);
}
@ -235,30 +184,56 @@ export function getLayerLists(mapSavedObjects: MapSavedObject[]): LayerDescripto
});
}
export function buildMapsIndexPatternsTelemetry(
indexPatternSavedObjects: Array<SavedObject<IndexPatternAttributes>>,
layerLists: LayerDescriptor[][]
): GeoIndexPatternsUsage {
const {
indexPatternsWithGeoFieldCount,
indexPatternsWithGeoPointFieldCount,
indexPatternsWithGeoShapeFieldCount,
} = getIndexPatternsWithGeoFieldCount(indexPatternSavedObjects);
async function filterIndexPatternsByField(fields: string[]) {
const indexPatternsService = await getIndexPatternsService();
const indexPatternIds = await indexPatternsService.getIds(true);
let numIndexPatternsContainingField = 0;
await Promise.all(
indexPatternIds.map(async (indexPatternId: string) => {
const indexPattern = await indexPatternsService.get(indexPatternId);
const fieldsForIndexPattern = await indexPatternsService.getFieldsForIndexPattern(
indexPattern
);
const containsField = fields.some((field: string) =>
fieldsForIndexPattern.some(
(fieldDescriptor: IFieldType) =>
fieldDescriptor.esTypes && fieldDescriptor.esTypes.includes(field)
)
);
if (containsField) {
numIndexPatternsContainingField++;
}
})
);
return numIndexPatternsContainingField;
}
export async function buildMapsIndexPatternsTelemetry(
layerLists: LayerDescriptor[][]
): Promise<GeoIndexPatternsUsage> {
const indexPatternsWithGeoField = await filterIndexPatternsByField([
ES_GEO_FIELD_TYPE.GEO_POINT,
ES_GEO_FIELD_TYPE.GEO_SHAPE,
]);
const indexPatternsWithGeoPointField = await filterIndexPatternsByField([
ES_GEO_FIELD_TYPE.GEO_POINT,
]);
const indexPatternsWithGeoShapeField = await filterIndexPatternsByField([
ES_GEO_FIELD_TYPE.GEO_SHAPE,
]);
// Tracks whether user uses Gold+ only functionality
const geoShapeAggLayersCount = getGeoShapeAggCount(layerLists, indexPatternSavedObjects);
const geoShapeAggLayersCount = await getGeoShapeAggCount(layerLists);
return {
indexPatternsWithGeoFieldCount,
indexPatternsWithGeoPointFieldCount,
indexPatternsWithGeoShapeFieldCount,
indexPatternsWithGeoFieldCount: indexPatternsWithGeoField,
indexPatternsWithGeoPointFieldCount: indexPatternsWithGeoPointField,
indexPatternsWithGeoShapeFieldCount: indexPatternsWithGeoShapeField,
geoShapeAggLayersCount,
};
}
export function buildMapsSavedObjectsTelemetry(layerLists: LayerDescriptor[][]): LayersStatsUsage {
const mapsCount = layerLists.length;
const dataSourcesCount = layerLists.map((layerList: LayerDescriptor[]) => {
// todo: not every source-descriptor has an id
// @ts-ignore
@ -340,16 +315,7 @@ export async function getMapsTelemetry(config: MapsConfigType): Promise<MapsUsag
const savedObjectsTelemetry = buildMapsSavedObjectsTelemetry(layerLists);
// Incrementally harvest index pattern saved objects telemetry
const indexPatternsTelemetry = {};
await execTransformOverMultipleSavedObjectPages<IndexPatternAttributes>(
'index-pattern',
(savedObjects) =>
_.mergeWith(
indexPatternsTelemetry,
buildMapsIndexPatternsTelemetry(savedObjects, layerLists),
(prevVal, currVal) => prevVal || 0 + currVal || 0 // Additive merge
)
);
const indexPatternsTelemetry = await buildMapsIndexPatternsTelemetry(layerLists);
return {
settings: {

View file

@ -1,59 +0,0 @@
[
{
"attributes": {
"fields": "[{\"name\":\"geometry\",\"type\":\"geo_shape\",\"esTypes\":[\"geo_shape\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false}]",
"timeFieldName": "ORIG_DATE",
"title": "indexpattern-with-geoshape"
},
"id": "4a7f6010-0aed-11ea-9dd2-95afd7ad44d4",
"migrationVersion": {
"index-pattern": "7.6.0"
},
"references": [],
"type": "index-pattern",
"updated_at": "2019-11-19T16:54:46.405Z",
"version": "Wzg0LDFd"
},
{
"attributes": {
"fields": "[{\"name\":\"geometry\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",
"title": "indexpattern-with-geopoint"
},
"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\":\"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}]",
"title": "indexpattern-without-geo"
},
"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=="
}
]

View file

@ -20,7 +20,7 @@ import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getExistingMapPath } from '../
import { mapSavedObjects, mapsTelemetrySavedObjects } from './saved_objects';
import { MapsXPackConfig } from '../config';
// @ts-ignore
import { setInternalRepository } from './kibana_server_services';
import { setIndexPatternsService, setInternalRepository } from './kibana_server_services';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
import { emsBoundariesSpecProvider } from './tutorials/ems';
// @ts-ignore
@ -30,6 +30,7 @@ import { LicensingPluginSetup } from '../../licensing/server';
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
import { MapsLegacyPluginSetup } from '../../../../src/plugins/maps_legacy/server';
import { EMSSettings } from '../common/ems_settings';
import { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server';
interface SetupDeps {
features: FeaturesPluginSetupContract;
@ -39,6 +40,10 @@ interface SetupDeps {
mapsLegacy: MapsLegacyPluginSetup;
}
export interface StartDeps {
data: DataPluginStart;
}
export class MapsPlugin implements Plugin {
readonly _initializerContext: PluginInitializerContext<MapsXPackConfig>;
private readonly _logger: Logger;
@ -208,7 +213,11 @@ export class MapsPlugin implements Plugin {
}
// @ts-ignore
start(core: CoreStart) {
start(core: CoreStart, plugins: StartDeps) {
setInternalRepository(core.savedObjects.createInternalRepository);
setIndexPatternsService(
plugins.data.indexPatterns.indexPatternsServiceFactory,
core.elasticsearch.client.asInternalUser
);
}
}