From 20eb83b1f718ea81451366e4b7d09d2ea057eced Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 4 Oct 2021 09:44:38 -0700 Subject: [PATCH] [Reporting] Breaking: Remove setting for Reporting index --- docs/settings/reporting-settings.asciidoc | 28 ----------- docs/setup/configuring-reporting.asciidoc | 50 ------------------- .../resources/base/bin/kibana-docker | 1 - x-pack/plugins/reporting/common/constants.ts | 2 + .../reporting/server/config/schema.test.ts | 2 - .../plugins/reporting/server/config/schema.ts | 3 -- .../export_types/csv/execute_job.test.ts | 1 - .../reporting/server/lib/store/store.ts | 4 +- .../reporting/server/routes/lib/jobs_query.ts | 5 +- .../server/usage/get_reporting_usage.ts | 3 +- 10 files changed, 8 insertions(+), 91 deletions(-) diff --git a/docs/settings/reporting-settings.asciidoc b/docs/settings/reporting-settings.asciidoc index 694f8c53f6745..560f2d850c6d5 100644 --- a/docs/settings/reporting-settings.asciidoc +++ b/docs/settings/reporting-settings.asciidoc @@ -11,7 +11,6 @@ You can configure `xpack.reporting` settings in your `kibana.yml` to: * <> * <> -* <> * <> * <> * <> @@ -47,33 +46,6 @@ The static encryption key for reporting. Use an alphanumeric text string that is xpack.reporting.encryptionKey: "something_secret" -------------------------------------------------------------------------------- -[float] -[[report-indices]] -==== Reporting index setting - - - -`xpack.reporting.index`:: -deprecated:[7.11.0,This setting will be removed in 8.0.0.] Multitenancy by changing `kibana.index` is unsupported starting in 8.0.0. For more details, refer to https://ela.st/kbn-remove-legacy-multitenancy[8.0 Breaking Changes]. When you divide workspaces in an Elastic cluster using multiple {kib} instances with a different `kibana.index` setting per instance, you must set a unique `xpack.reporting.index` setting per `kibana.index`. Otherwise, report generation periodically fails if a report is queued through an instance with one `kibana.index` setting, and an instance with a different `kibana.index` attempts to claim the job. Reporting uses a weekly index in {es} to store the reporting job and the report content. The index is automatically created if it does not already exist. Configure a unique value for `xpack.reporting.index`, beginning with `.reporting-`, for every {kib} instance that has a unique <> setting. Defaults to `.reporting`. - -{kib} instance A: -[source,yaml] --------------------------------------------------------------------------------- -kibana.index: ".kibana-a" -xpack.reporting.index: ".reporting-a" -xpack.reporting.encryptionKey: "something_secret" --------------------------------------------------------------------------------- - -{kib} instance B: -[source,yaml] --------------------------------------------------------------------------------- -kibana.index: ".kibana-b" -xpack.reporting.index: ".reporting-b" -xpack.reporting.encryptionKey: "something_secret" --------------------------------------------------------------------------------- - -NOTE: If security is enabled, the `xpack.reporting.index` setting should begin with `.reporting-` for the `kibana_system` role to have the necessary privileges over the index. - [float] [[reporting-kibana-server-settings]] ==== {kib} server settings diff --git a/docs/setup/configuring-reporting.asciidoc b/docs/setup/configuring-reporting.asciidoc index 6d209092d3338..38bf2955fb56e 100644 --- a/docs/setup/configuring-reporting.asciidoc +++ b/docs/setup/configuring-reporting.asciidoc @@ -148,56 +148,6 @@ reporting_user: - "cn=Bill Murray,dc=example,dc=com" -------------------------------------------------------------------------------- -[float] -==== Grant access with a custom index - -If you are using a custom index, the `xpack.reporting.index` setting must begin with `.reporting-*`. The default {kib} system user has `all` privileges against the `.reporting-*` pattern of indices. - -If you use a different pattern for the `xpack.reporting.index` setting, you must create a custom `kibana_system` user with appropriate access to the index. - -NOTE: In the next major version of Kibana, granting access with a custom index is unsupported. - -. Create the reporting role. - -.. Open the main menu, then click *Stack Management*. - -.. Click *Roles > Create role*. - -. Specify the role settings. - -.. Enter the *Role name*. For example, `custom-reporting-user`. - -.. From the *Indices* dropdown, select the custom index. - -.. From the *Privileges* dropdown, select *all*. - -.. Click *Add Kibana privilege*. - -.. Select one or more *Spaces* that you want to grant reporting privileges to. - -.. Click *Customize*, then click *Analytics*. - -.. Next to each application you want to grant reporting privileges to, click *All*. - -.. Click *Add {kib} privilege*, then click *Create role*. - -. Assign the reporting role to a user. - -.. Open the main menu, then click *Stack Management*. - -.. Click *Users*, then click the user you want to assign the reporting role to. - -.. From the *Roles* dropdown, select *kibana_system* and *custom-reporting-user*. - -.. Click *Update user*. - -. Configure {kib} to use the new account. -+ -[source,js] --------------------------------------------------------------------------------- -elasticsearch.username: 'custom_kibana_system' --------------------------------------------------------------------------------- - [float] [[securing-reporting]] === Secure the reporting endpoints diff --git a/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker b/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker index cee43fd85c90f..43bdd9ab143ea 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker +++ b/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker @@ -329,7 +329,6 @@ kibana_vars=( xpack.reporting.csv.useByteOrderMarkEncoding xpack.reporting.enabled xpack.reporting.encryptionKey - xpack.reporting.index xpack.reporting.kibanaApp xpack.reporting.kibanaServer.hostname xpack.reporting.kibanaServer.port diff --git a/x-pack/plugins/reporting/common/constants.ts b/x-pack/plugins/reporting/common/constants.ts index 9224a23fcb33f..3fb02677dd981 100644 --- a/x-pack/plugins/reporting/common/constants.ts +++ b/x-pack/plugins/reporting/common/constants.ts @@ -7,6 +7,8 @@ export const PLUGIN_ID = 'reporting'; +export const REPORTING_SYSTEM_INDEX = '.reporting'; + export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY = 'xpack.reporting.jobCompletionNotifications'; diff --git a/x-pack/plugins/reporting/server/config/schema.test.ts b/x-pack/plugins/reporting/server/config/schema.test.ts index 0998a80103131..0b2e2cac6ff7c 100644 --- a/x-pack/plugins/reporting/server/config/schema.test.ts +++ b/x-pack/plugins/reporting/server/config/schema.test.ts @@ -84,7 +84,6 @@ describe('Reporting Config Schema', () => { }, "enabled": true, "encryptionKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "index": ".reporting", "kibanaServer": Object {}, "poll": Object { "jobCompletionNotifier": Object { @@ -189,7 +188,6 @@ describe('Reporting Config Schema', () => { "useByteOrderMarkEncoding": false, }, "enabled": true, - "index": ".reporting", "kibanaServer": Object {}, "poll": Object { "jobCompletionNotifier": Object { diff --git a/x-pack/plugins/reporting/server/config/schema.ts b/x-pack/plugins/reporting/server/config/schema.ts index d616a18289df0..affd8b7bee7ff 100644 --- a/x-pack/plugins/reporting/server/config/schema.ts +++ b/x-pack/plugins/reporting/server/config/schema.ts @@ -155,8 +155,6 @@ const RolesSchema = schema.object({ allow: schema.arrayOf(schema.string(), { defaultValue: ['reporting_user'] }), }); -const IndexSchema = schema.string({ defaultValue: '.reporting' }); - // Browser side polling: job completion notifier, management table auto-refresh // NOTE: can not use schema.duration, a bug prevents it being passed to the browser correctly const PollSchema = schema.object({ @@ -178,7 +176,6 @@ export const ConfigSchema = schema.object({ csv: CsvSchema, encryptionKey: EncryptionKeySchema, roles: RolesSchema, - index: IndexSchema, poll: PollSchema, }); diff --git a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts index 5032eaab46e84..e5d0ed2613719 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts @@ -77,7 +77,6 @@ describe('CSV Execute Job', function () { stream = { write: jest.fn((chunk) => (content += chunk)) } as unknown as typeof stream; configGetStub = sinon.stub(); configGetStub.withArgs('queue', 'timeout').returns(moment.duration('2m')); - configGetStub.withArgs('index').returns('.reporting-foo-test'); configGetStub.withArgs('encryptionKey').returns(encryptionKey); configGetStub.withArgs('csv', 'maxSizeBytes').returns(1024 * 1000); // 1mB configGetStub.withArgs('csv', 'scroll').returns({}); diff --git a/x-pack/plugins/reporting/server/lib/store/store.ts b/x-pack/plugins/reporting/server/lib/store/store.ts index d49337391ca40..01a6f7a3cd06d 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.ts @@ -9,7 +9,7 @@ import { IndexResponse, UpdateResponse } from '@elastic/elasticsearch/api/types' import { ElasticsearchClient } from 'src/core/server'; import { LevelLogger, statuses } from '../'; import { ReportingCore } from '../../'; -import { ILM_POLICY_NAME } from '../../../common/constants'; +import { ILM_POLICY_NAME, REPORTING_SYSTEM_INDEX } from '../../../common/constants'; import { JobStatus, ReportOutput, ReportSource } from '../../../common/types'; import { ReportTaskParams } from '../tasks'; import { Report, ReportDocument, SavedReport } from './'; @@ -87,7 +87,7 @@ export class ReportingStore { constructor(private reportingCore: ReportingCore, private logger: LevelLogger) { const config = reportingCore.getConfig(); - this.indexPrefix = config.get('index'); + this.indexPrefix = REPORTING_SYSTEM_INDEX; this.indexInterval = config.get('queue', 'indexInterval'); this.logger = logger.clone(['store']); } diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index afa83ed331672..54efe0636536a 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -13,6 +13,7 @@ import { UnwrapPromise } from '@kbn/utility-types'; import { ElasticsearchClient } from 'src/core/server'; import { PromiseType } from 'utility-types'; import { ReportingCore } from '../../'; +import { REPORTING_SYSTEM_INDEX } from '../../../common/constants'; import { ReportApiJSON, ReportSource } from '../../../common/types'; import { statuses } from '../../lib/statuses'; import { Report } from '../../lib/store'; @@ -54,9 +55,7 @@ interface JobsQueryFactory { export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory { function getIndex() { - const config = reportingCore.getConfig(); - - return `${config.get('index')}-*`; + return `${REPORTING_SYSTEM_INDEX}-*`; } async function execQuery< diff --git a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts index 9a452943ff699..69213d8f8cacc 100644 --- a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts +++ b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts @@ -8,6 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import type { ElasticsearchClient } from 'kibana/server'; import { get } from 'lodash'; import type { ReportingConfig } from '../'; +import { REPORTING_SYSTEM_INDEX } from '../../common/constants'; import type { ExportTypesRegistry } from '../lib/export_types_registry'; import type { GetLicense } from './'; import { getExportStats } from './get_export_stats'; @@ -144,7 +145,7 @@ export async function getReportingUsage( esClient: ElasticsearchClient, exportTypesRegistry: ExportTypesRegistry ): Promise { - const reportingIndex = config.get('index'); + const reportingIndex = REPORTING_SYSTEM_INDEX; const params = { index: `${reportingIndex}-*`, filterPath: 'aggregations.*.buckets',