Skip to content

Commit

Permalink
[Stack monitoring] remove support for monitoring.cluster_alerts.allow…
Browse files Browse the repository at this point in the history
…edSpaces (elastic#123229)

* remove allowed space setting

* set allowedSpaces as unused setting

* mock unused function in deprecation tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 24f0425)

# Conflicts:
#	api_docs/monitoring.json
  • Loading branch information
klacabane committed Jan 25, 2022
1 parent b624f12 commit a3c6fac
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions api_docs/monitoring.json
Expand Up @@ -149,7 +149,7 @@
"signature": [
"{ ui: { elasticsearch: ",
"MonitoringElasticsearchConfig",
"; enabled: boolean; container: Readonly<{} & { logstash: Readonly<{} & { enabled: boolean; }>; apm: Readonly<{} & { enabled: boolean; }>; elasticsearch: Readonly<{} & { enabled: boolean; }>; }>; logs: Readonly<{} & { index: string; }>; metricbeat: Readonly<{} & { index: string; }>; debug_mode: boolean; debug_log_path: string; ccs: Readonly<{} & { enabled: boolean; }>; max_bucket_size: number; min_interval_seconds: number; show_license_expiration: boolean; render_react_app: boolean; }; tests: Readonly<{} & { cloud_detector: Readonly<{} & { enabled: boolean; }>; }>; enabled: boolean; kibana: Readonly<{} & { collection: Readonly<{} & { interval: number; enabled: boolean; }>; }>; licensing: Readonly<{} & { api_polling_frequency: moment.Duration; }>; agent: Readonly<{} & { interval: string; }>; cluster_alerts: Readonly<{} & { enabled: boolean; allowedSpaces: string[]; email_notifications: Readonly<{} & { enabled: boolean; email_address: string; }>; }>; }"
"; enabled: boolean; container: Readonly<{} & { logstash: Readonly<{} & { enabled: boolean; }>; apm: Readonly<{} & { enabled: boolean; }>; elasticsearch: Readonly<{} & { enabled: boolean; }>; }>; logs: Readonly<{} & { index: string; }>; metricbeat: Readonly<{} & { index: string; }>; debug_mode: boolean; debug_log_path: string; ccs: Readonly<{} & { enabled: boolean; }>; max_bucket_size: number; min_interval_seconds: number; show_license_expiration: boolean; }; tests: Readonly<{} & { cloud_detector: Readonly<{} & { enabled: boolean; }>; }>; kibana: Readonly<{} & { collection: Readonly<{} & { interval: number; enabled: boolean; }>; }>; agent: Readonly<{} & { interval: string; }>; licensing: Readonly<{} & { api_polling_frequency: moment.Duration; }>; cluster_alerts: Readonly<{} & { enabled: boolean; email_notifications: Readonly<{} & { enabled: boolean; email_address: string; }>; }>; }"
],
"path": "x-pack/plugins/monitoring/server/config.ts",
"deprecated": false,
Expand Down Expand Up @@ -195,4 +195,4 @@
"misc": [],
"objects": []
}
}
}
3 changes: 0 additions & 3 deletions docs/settings/monitoring-settings.asciidoc
Expand Up @@ -72,9 +72,6 @@ For more information, see
| `monitoring.ui.elasticsearch.ssl`
| Shares the same configuration as <<elasticsearch-ssl-cert-key, `elasticsearch.ssl`>>. These settings configure encrypted communication between {kib} and the monitoring cluster.

| `monitoring.cluster_alerts.allowedSpaces` {ess-icon}
| Specifies the spaces where cluster Stack Monitoring alerts can be created. You must specify all spaces where you want to generate alerts, including the default space. Defaults to `[ "default" ]`.

|===

[float]
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/monitoring/server/config.test.ts
Expand Up @@ -31,9 +31,6 @@ describe('config schema', () => {
"interval": "10s",
},
"cluster_alerts": Object {
"allowedSpaces": Array [
"default",
],
"email_notifications": Object {
"email_address": "",
"enabled": true,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/monitoring/server/config.ts
Expand Up @@ -58,7 +58,6 @@ export const configSchema = schema.object({
}),
}),
cluster_alerts: schema.object({
allowedSpaces: schema.arrayOf(schema.string(), { defaultValue: ['default'] }),
enabled: schema.boolean({ defaultValue: true }),
email_notifications: schema.object({
enabled: schema.boolean({ defaultValue: true }),
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/monitoring/server/deprecations.test.js
Expand Up @@ -13,10 +13,11 @@ describe('monitoring plugin deprecations', function () {
const deprecate = jest.fn(() => jest.fn());
const rename = jest.fn(() => jest.fn());
const renameFromRoot = jest.fn(() => jest.fn());
const unused = jest.fn(() => jest.fn());
const fromPath = 'monitoring';

beforeAll(function () {
const deprecations = deprecationsModule({ deprecate, rename, renameFromRoot });
const deprecations = deprecationsModule({ deprecate, rename, renameFromRoot, unused });
transformDeprecations = (settings, fromPath, addDeprecation = noop) => {
deprecations.forEach((deprecation) => deprecation(settings, fromPath, addDeprecation));
};
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/monitoring/server/deprecations.ts
Expand Up @@ -20,6 +20,7 @@ import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY } from '../common/constants';
export const deprecations = ({
rename,
renameFromRoot,
unused,
}: ConfigDeprecationFactory): ConfigDeprecation[] => {
return [
// This order matters. The "blanket rename" needs to happen at the end
Expand Down Expand Up @@ -76,6 +77,8 @@ export const deprecations = ({
level: 'warning',
}),

unused('cluster_alerts.allowedSpaces', { level: 'warning' }),

// TODO: Add deprecations for "monitoring.ui.elasticsearch.username: elastic" and "monitoring.ui.elasticsearch.username: kibana".
// TODO: Add deprecations for using "monitoring.ui.elasticsearch.ssl.certificate" without "monitoring.ui.elasticsearch.ssl.key", and
// vice versa.
Expand Down
11 changes: 0 additions & 11 deletions x-pack/plugins/monitoring/server/routes/api/v1/alerts/enable.ts
Expand Up @@ -24,17 +24,6 @@ export function enableAlertsRoute(server: LegacyServer, npRoute: RouteDependenci
},
async (context, request, response) => {
try {
// Check to ensure the space is listed in monitoring.cluster_alerts.allowedSpaces
const config = server.config();
const allowedSpaces =
config.get('monitoring.cluster_alerts.allowedSpaces') || ([] as string[]);
if (!allowedSpaces.includes(context.infra.spaceId)) {
server.log.info(
`Skipping alert creation for "${context.infra.spaceId}" space; add space ID to 'monitoring.cluster_alerts.allowedSpaces' in your kibana.yml`
);
return response.ok({ body: undefined });
}

const alerts = AlertsFactory.getAll();
if (alerts.length) {
const { isSufficientlySecure, hasPermanentEncryptionKey } = npRoute.alerting
Expand Down

0 comments on commit a3c6fac

Please sign in to comment.