@@ -11,7 +11,6 @@ import { ReportingCore } from '../../';
1111import { indexTimestamp } from './index_timestamp' ;
1212import { mapping } from './mapping' ;
1313import { Report } from './report' ;
14- import { reportingIlmPolicy } from './report_ilm_policy' ;
1514
1615const checkReportIsEditable = ( report : Report ) => {
1716 if ( ! report . _id || ! report . _index ) {
@@ -53,22 +52,19 @@ export class ReportingStore {
5352 return exists ;
5453 }
5554
55+ const indexSettings = {
56+ number_of_shards : 1 ,
57+ auto_expand_replicas : '0-1' ,
58+ } ;
59+ const body = {
60+ settings : indexSettings ,
61+ mappings : {
62+ properties : mapping ,
63+ } ,
64+ } ;
65+
5666 try {
57- await client . indices . create ( {
58- index : indexName ,
59- body : {
60- settings : {
61- number_of_shards : 1 ,
62- auto_expand_replicas : '0-1' ,
63- lifecycle : {
64- name : this . ilmPolicyName ,
65- } ,
66- } ,
67- mappings : {
68- properties : mapping ,
69- } ,
70- } ,
71- } ) ;
67+ await client . indices . create ( { index : indexName , body } ) ;
7268
7369 return true ;
7470 } catch ( error ) {
@@ -115,44 +111,6 @@ export class ReportingStore {
115111 return client . indices . refresh ( { index } ) ;
116112 }
117113
118- private readonly ilmPolicyName = 'kibana-reporting' ;
119-
120- private async doesIlmPolicyExist ( ) : Promise < boolean > {
121- const client = await this . getClient ( ) ;
122- try {
123- await client . ilm . getLifecycle ( { policy : this . ilmPolicyName } ) ;
124- return true ;
125- } catch ( e ) {
126- if ( e . statusCode === 404 ) {
127- return false ;
128- }
129- throw e ;
130- }
131- }
132-
133- /**
134- * Function to be called during plugin start phase. This ensures the environment is correctly
135- * configured for storage of reports.
136- */
137- public async start ( ) {
138- const client = await this . getClient ( ) ;
139- try {
140- if ( await this . doesIlmPolicyExist ( ) ) {
141- this . logger . debug ( `Found ILM policy ${ this . ilmPolicyName } ; skipping creation.` ) ;
142- return ;
143- }
144- this . logger . info ( `Creating ILM policy for managing reporting indices: ${ this . ilmPolicyName } ` ) ;
145- await client . ilm . putLifecycle ( {
146- policy : this . ilmPolicyName ,
147- body : reportingIlmPolicy ,
148- } ) ;
149- } catch ( e ) {
150- this . logger . error ( 'Error in start phase' ) ;
151- this . logger . error ( e . body . error ) ;
152- throw e ;
153- }
154- }
155-
156114 public async addReport ( report : Report ) : Promise < Report > {
157115 let index = report . _index ;
158116 if ( ! index ) {
0 commit comments