33 * or more contributor license agreements. Licensed under the Elastic License;
44 * you may not use this file except in compliance with the Elastic License.
55 */
6+
7+ import { i18n } from '@kbn/i18n' ;
68import { Legacy } from 'kibana' ;
79import crypto from 'crypto' ;
810import { get } from 'lodash' ;
@@ -24,11 +26,25 @@ const buildLegacyDependencies = (
2426 } ,
2527} ) ;
2628
27- const addConfigDefaults = ( core : CoreSetup , baseConfig : ReportingConfigType ) => {
29+ const addConfigDefaults = (
30+ server : Legacy . Server ,
31+ core : CoreSetup ,
32+ baseConfig : ReportingConfigType
33+ ) => {
2834 // encryption key
2935 let encryptionKey = baseConfig . encryptionKey ;
3036 if ( encryptionKey === undefined ) {
31- // FIXME log warning
37+ server . log (
38+ [ 'reporting' , 'config' , 'warning' ] ,
39+ i18n . translate ( 'xpack.reporting.selfCheckEncryptionKey.warning' , {
40+ defaultMessage :
41+ `Generating a random key for {setting}. To prevent pending reports ` +
42+ `from failing on restart, please set {setting} in kibana.yml` ,
43+ values : {
44+ setting : 'xpack.reporting.encryptionKey' ,
45+ } ,
46+ } )
47+ ) ;
3248 encryptionKey = crypto . randomBytes ( 16 ) . toString ( 'hex' ) ;
3349 }
3450
@@ -38,7 +54,18 @@ const addConfigDefaults = (core: CoreSetup, baseConfig: ReportingConfigType) =>
3854 // kibanaServer.hostname, default to server.host, don't allow "0"
3955 let kibanaServerHostname = reportingServer . hostname ? reportingServer . hostname : serverInfo . host ;
4056 if ( kibanaServerHostname === '0' ) {
41- // FIXME log warning
57+ server . log (
58+ [ 'reporting' , 'config' , 'warning' ] ,
59+ i18n . translate ( 'xpack.reporting.selfCheckHostname.warning' , {
60+ defaultMessage :
61+ `Found 'server.host: "0"' in settings. This is incompatible with Reporting. ` +
62+ `To enable Reporting to work, '{setting}: 0.0.0.0' is being automatically to the configuration. ` +
63+ `You can change to 'server.host: 0.0.0.0' or add '{setting}: 0.0.0.0' in kibana.yml to prevent this message.` ,
64+ values : {
65+ setting : 'xpack.reporting.kibanaServer.hostname' ,
66+ } ,
67+ } )
68+ ) ;
4269 kibanaServerHostname = '0.0.0.0' ;
4370 }
4471
@@ -87,7 +114,7 @@ const buildConfig = (
87114 } ;
88115
89116 // spreading arguments as an array allows the return type to be known by the compiler
90- reportingConfig = addConfigDefaults ( core , reportingConfig ) ;
117+ reportingConfig = addConfigDefaults ( server , core , reportingConfig ) ;
91118 return {
92119 get : ( ...keys : string [ ] ) => get ( reportingConfig , keys . join ( '.' ) , null ) ,
93120 kbnConfig : {
0 commit comments