Skip to content

Commit

Permalink
Revert "[Monitoring] Change all configs to monitoring.*" (#56214)
Browse files Browse the repository at this point in the history
This reverts commit 04ad88c.
  • Loading branch information
chrisronline authored and brianseeders committed Jan 28, 2020
1 parent 06acf2f commit bd08eb7
Show file tree
Hide file tree
Showing 53 changed files with 144 additions and 186 deletions.
50 changes: 0 additions & 50 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,56 +119,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
renameFromRoot('xpack.telemetry.config', 'telemetry.config'),
renameFromRoot('xpack.telemetry.banner', 'telemetry.banner'),
renameFromRoot('xpack.telemetry.url', 'telemetry.url'),
// Monitoring renames
// TODO: Remove these from here once the monitoring plugin is migrated to NP
renameFromRoot('xpack.monitoring.enabled', 'monitoring.enabled'),
renameFromRoot('xpack.monitoring.ui.enabled', 'monitoring.ui.enabled'),
renameFromRoot(
'xpack.monitoring.kibana.collection.enabled',
'monitoring.kibana.collection.enabled'
),
renameFromRoot('xpack.monitoring.max_bucket_size', 'monitoring.ui.max_bucket_size'),
renameFromRoot('xpack.monitoring.min_interval_seconds', 'monitoring.ui.min_interval_seconds'),
renameFromRoot(
'xpack.monitoring.show_license_expiration',
'monitoring.ui.show_license_expiration'
),
renameFromRoot(
'xpack.monitoring.ui.container.elasticsearch.enabled',
'monitoring.ui.container.elasticsearch.enabled'
),
renameFromRoot(
'xpack.monitoring.ui.container.logstash.enabled',
'monitoring.ui.container.logstash.enabled'
),
renameFromRoot(
'xpack.monitoring.tests.cloud_detector.enabled',
'monitoring.tests.cloud_detector.enabled'
),
renameFromRoot(
'xpack.monitoring.kibana.collection.interval',
'monitoring.kibana.collection.interval'
),
renameFromRoot('xpack.monitoring.elasticsearch.hosts', 'monitoring.ui.elasticsearch.hosts'),
renameFromRoot('xpack.monitoring.elasticsearch.username', 'monitoring.ui.elasticsearch.username'),
renameFromRoot('xpack.monitoring.elasticsearch.password', 'monitoring.ui.elasticsearch.password'),
renameFromRoot(
'xpack.monitoring.xpack_api_polling_frequency_millis',
'monitoring.xpack_api_polling_frequency_millis'
),
renameFromRoot(
'xpack.monitoring.cluster_alerts.email_notifications.enabled',
'monitoring.cluster_alerts.email_notifications.enabled'
),
renameFromRoot(
'xpack.monitoring.cluster_alerts.email_notifications.email_address',
'monitoring.cluster_alerts.email_notifications.email_address'
),
renameFromRoot('xpack.monitoring.ccs.enabled', 'monitoring.ui.ccs.enabled'),
renameFromRoot(
'xpack.monitoring.elasticsearch.logFetchCount',
'monitoring.ui.elasticsearch.logFetchCount'
),
configPathDeprecation,
dataPathDeprecation,
rewriteBasePathDeprecation,
Expand Down
96 changes: 48 additions & 48 deletions x-pack/legacy/plugins/monitoring/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export const config = Joi => {
const DEFAULT_REQUEST_HEADERS = ['authorization'];

return Joi.object({
ccs: Joi.object({
enabled: Joi.boolean().default(true),
}).default(),
enabled: Joi.boolean().default(true),
ui: Joi.object({
enabled: Joi.boolean().default(true),
ccs: Joi.object({
enabled: Joi.boolean().default(true),
}).default(),
container: Joi.object({
elasticsearch: Joi.object({
enabled: Joi.boolean().default(false),
Expand All @@ -29,51 +29,6 @@ export const config = Joi => {
enabled: Joi.boolean().default(false),
}).default(),
}).default(),
max_bucket_size: Joi.number().default(10000),
min_interval_seconds: Joi.number().default(10),
show_license_expiration: Joi.boolean().default(true),
elasticsearch: Joi.object({
customHeaders: Joi.object().default({}),
logQueries: Joi.boolean().default(false),
requestHeadersWhitelist: Joi.array()
.items()
.single()
.default(DEFAULT_REQUEST_HEADERS),
sniffOnStart: Joi.boolean().default(false),
sniffInterval: Joi.number()
.allow(false)
.default(false),
sniffOnConnectionFault: Joi.boolean().default(false),
hosts: Joi.array()
.items(Joi.string().uri({ scheme: ['http', 'https'] }))
.single(), // if empty, use Kibana's connection config
username: Joi.string(),
password: Joi.string(),
requestTimeout: Joi.number().default(30000),
pingTimeout: Joi.number().default(30000),
ssl: Joi.object({
verificationMode: Joi.string()
.valid('none', 'certificate', 'full')
.default('full'),
certificateAuthorities: Joi.array()
.single()
.items(Joi.string()),
certificate: Joi.string(),
key: Joi.string(),
keyPassphrase: Joi.string(),
keystore: Joi.object({
path: Joi.string(),
password: Joi.string(),
}).default(),
truststore: Joi.object({
path: Joi.string(),
password: Joi.string(),
}).default(),
alwaysPresentCertificate: Joi.boolean().default(false),
}).default(),
apiVersion: Joi.string().default('master'),
logFetchCount: Joi.number().default(10),
}).default(),
}).default(),
kibana: Joi.object({
collection: Joi.object({
Expand All @@ -91,11 +46,56 @@ export const config = Joi => {
xpack_api_polling_frequency_millis: Joi.number().default(
XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS
),
max_bucket_size: Joi.number().default(10000),
min_interval_seconds: Joi.number().default(10),
show_license_expiration: Joi.boolean().default(true),
agent: Joi.object({
interval: Joi.string()
.regex(/[\d\.]+[yMwdhms]/)
.default('10s'),
}).default(),
elasticsearch: Joi.object({
customHeaders: Joi.object().default({}),
logQueries: Joi.boolean().default(false),
requestHeadersWhitelist: Joi.array()
.items()
.single()
.default(DEFAULT_REQUEST_HEADERS),
sniffOnStart: Joi.boolean().default(false),
sniffInterval: Joi.number()
.allow(false)
.default(false),
sniffOnConnectionFault: Joi.boolean().default(false),
hosts: Joi.array()
.items(Joi.string().uri({ scheme: ['http', 'https'] }))
.single(), // if empty, use Kibana's connection config
username: Joi.string(),
password: Joi.string(),
requestTimeout: Joi.number().default(30000),
pingTimeout: Joi.number().default(30000),
ssl: Joi.object({
verificationMode: Joi.string()
.valid('none', 'certificate', 'full')
.default('full'),
certificateAuthorities: Joi.array()
.single()
.items(Joi.string()),
certificate: Joi.string(),
key: Joi.string(),
keyPassphrase: Joi.string(),
keystore: Joi.object({
path: Joi.string(),
password: Joi.string(),
}).default(),
truststore: Joi.object({
path: Joi.string(),
password: Joi.string(),
}).default(),
alwaysPresentCertificate: Joi.boolean().default(false),
}).default(),
apiVersion: Joi.string().default('master'),
logFetchCount: Joi.number().default(10),
}).default(),
tests: Joi.object({
cloud_detector: Joi.object({
enabled: Joi.boolean().default(true),
Expand Down
34 changes: 17 additions & 17 deletions x-pack/legacy/plugins/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ export const monitoring = kibana =>
new kibana.Plugin({
require: ['kibana', 'elasticsearch', 'xpack_main'],
id: 'monitoring',
configPrefix: 'monitoring',
configPrefix: 'xpack.monitoring',
publicDir: resolve(__dirname, 'public'),
init(server) {
const configs = [
'monitoring.ui.enabled',
'monitoring.kibana.collection.enabled',
'monitoring.ui.max_bucket_size',
'monitoring.ui.min_interval_seconds',
'xpack.monitoring.ui.enabled',
'xpack.monitoring.kibana.collection.enabled',
'xpack.monitoring.max_bucket_size',
'xpack.monitoring.min_interval_seconds',
'kibana.index',
'monitoring.ui.show_license_expiration',
'monitoring.ui.container.elasticsearch.enabled',
'monitoring.ui.container.logstash.enabled',
'monitoring.tests.cloud_detector.enabled',
'monitoring.kibana.collection.interval',
'monitoring.ui.elasticsearch.hosts',
'monitoring.ui.elasticsearch',
'monitoring.xpack_api_polling_frequency_millis',
'xpack.monitoring.show_license_expiration',
'xpack.monitoring.ui.container.elasticsearch.enabled',
'xpack.monitoring.ui.container.logstash.enabled',
'xpack.monitoring.tests.cloud_detector.enabled',
'xpack.monitoring.kibana.collection.interval',
'xpack.monitoring.elasticsearch.hosts',
'xpack.monitoring.elasticsearch',
'xpack.monitoring.xpack_api_polling_frequency_millis',
'server.uuid',
'server.name',
'server.host',
'server.port',
'monitoring.cluster_alerts.email_notifications.enabled',
'monitoring.cluster_alerts.email_notifications.email_address',
'monitoring.ui.ccs.enabled',
'monitoring.ui.elasticsearch.logFetchCount',
'xpack.monitoring.cluster_alerts.email_notifications.enabled',
'xpack.monitoring.cluster_alerts.email_notifications.email_address',
'xpack.monitoring.ccs.enabled',
'xpack.monitoring.elasticsearch.logFetchCount',
];

const serverConfig = server.config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function alertsClusterSearch(req, alertsIndex, cluster, checkLicense, opt

if (prodLicenseInfo.clusterAlerts.enabled) {
const config = req.server.config();
const size = options.size || config.get('monitoring.ui.max_bucket_size');
const size = options.size || config.get('xpack.monitoring.max_bucket_size');

const params = {
index: alertsIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function verifyMonitoringLicense(server) {
const config = server.config();

// if cluster alerts are enabled, then ensure that we can use it according to the license
if (config.get('monitoring.cluster_alerts.enabled')) {
if (config.get('xpack.monitoring.cluster_alerts.enabled')) {
const xpackInfo = get(server.plugins.monitoring, 'info');
if (xpackInfo) {
const monitoringCluster = xpackInfo.feature('monitoring').getLicenseCheckResults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { exposeClient, hasMonitoringCluster } from '../instantiate_client';

function getMockServerFromConnectionUrl(monitoringClusterUrl) {
const server = {
monitoring: {
ui: {
xpack: {
monitoring: {
elasticsearch: {
hosts: monitoringClusterUrl ? [monitoringClusterUrl] : [],
username: 'monitoring-user-internal-test',
Expand All @@ -27,7 +27,7 @@ function getMockServerFromConnectionUrl(monitoringClusterUrl) {
};

return {
elasticsearchConfig: server.monitoring.ui.elasticsearch,
elasticsearchConfig: server.xpack.monitoring.elasticsearch,
elasticsearchPlugin: {
getCluster: sinon
.stub()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ describe('throws when config is invalid', () => {
it('throws if key and keystore.path are both specified', () => {
const value = { ssl: { key: 'foo', keystore: { path: 'bar' } } };
expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot(
`"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"`
`"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"`
);
});

it('throws if certificate and keystore.path are both specified', () => {
const value = { ssl: { certificate: 'foo', keystore: { path: 'bar' } } };
expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot(
`"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"`
`"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { readFileSync } from 'fs';
import { readPkcs12Truststore, readPkcs12Keystore } from '../../../../../../src/core/utils';

const KEY = 'monitoring.ui.elasticsearch';
const KEY = 'xpack.monitoring.elasticsearch';

/*
* Parse a config object's Elasticsearch configuration, reading any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const initMonitoringXpackInfo = async ({ config, xpackMainPlugin, expose,
const xpackInfo = hasMonitoringCluster(config)
? xpackMainPlugin.createXPackInfo({
clusterSource: 'monitoring',
pollFrequencyInMillis: config.get('monitoring.xpack_api_polling_frequency_millis'),
pollFrequencyInMillis: config.get('xpack.monitoring.xpack_api_polling_frequency_millis'),
})
: xpackMainPlugin.info;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => {
function setup({ enabled = true, adminEmail = null } = {}) {
const config = { get: sinon.stub() };

config.get.withArgs('monitoring.cluster_alerts.email_notifications.enabled').returns(enabled);
config.get
.withArgs('xpack.monitoring.cluster_alerts.email_notifications.enabled')
.returns(enabled);

if (adminEmail) {
config.get.withArgs(`monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`).returns(adminEmail);
config.get
.withArgs(`xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`)
.returns(adminEmail);
}

config.get.withArgs('kibana.index').returns('.kibana');
Expand All @@ -27,7 +31,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => {
return config;
}

describe('monitoring.cluster_alerts.email_notifications.enabled = false', () => {
describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = false', () => {
it('returns null when email is defined', async () => {
const config = setup({ enabled: false });
expect(await getDefaultAdminEmail(config)).to.be(null);
Expand All @@ -39,7 +43,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => {
});
});

describe('monitoring.cluster_alerts.email_notifications.enabled = true', () => {
describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = true', () => {
it('returns value when email is defined', async () => {
const config = setup({ adminEmail: 'hello@world' });
expect(await getDefaultAdminEmail(config)).to.be('hello@world');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY, KIBANA_SETTINGS_TYPE } from '../../.
* If so, get email from kibana.yml
*/
export async function getDefaultAdminEmail(config) {
if (!config.get('monitoring.cluster_alerts.email_notifications.enabled')) {
if (!config.get('xpack.monitoring.cluster_alerts.email_notifications.enabled')) {
return null;
}

const emailAddressConfigKey = `monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`;
const emailAddressConfigKey = `xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`;
const configuredEmailAddress = config.get(emailAddressConfigKey);

return configuredEmailAddress || null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function opsBuffer({ config, log, getOSInfo }) {
// determine the cloud service in the background
const cloudDetector = new CloudDetector();

if (config.get('monitoring.tests.cloud_detector.enabled')) {
if (config.get('xpack.monitoring.tests.cloud_detector.enabled')) {
cloudDetector.detectCloudService();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BulkUploader } from './bulk_uploader';
* @param {Object} server HapiJS server instance
*/
export function initBulkUploader({ config, ...params }) {
const interval = config.get('monitoring.kibana.collection.interval');
const interval = config.get('xpack.monitoring.kibana.collection.interval');
return new BulkUploader({
interval,
config,
Expand Down
Loading

0 comments on commit bd08eb7

Please sign in to comment.