From 6084acc8b6f0c427171f5074389654eb97a95149 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Wed, 24 Oct 2018 08:03:54 -0700 Subject: [PATCH] [Reporting] queue.pollEnabled setting adds ability to disable polling for idle jobs (#24295) * [Reporting] New queue.pollEnabled setting adds ability to disable polling for idle jobs * add an info log line * note in docs --- docs/settings/reporting-settings.asciidoc | 16 +++++++++++++++- x-pack/plugins/reporting/index.js | 1 + .../plugins/reporting/server/lib/create_queue.js | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/settings/reporting-settings.asciidoc b/docs/settings/reporting-settings.asciidoc index c6463a5bf257..6aafeedf9cba 100644 --- a/docs/settings/reporting-settings.asciidoc +++ b/docs/settings/reporting-settings.asciidoc @@ -51,8 +51,22 @@ reports, you might need to change the following settings. How often the index that stores reporting jobs rolls over to a new index. Valid values are `year`, `month`, `week`, `day`, and `hour`. Defaults to `week`. +`xpack.reporting.queue.pollEnabled`:: +Set to `true` (default) to enable the Kibana instance to to poll the index for +pending jobs and claim them for execution. Setting this to `false` allows the +Kibana instance to only add new jobs to the reporting queue, list jobs, and +provide the downloads to completed report through the UI. + +[NOTE] +============ +Running multiple instances of Kibana in a cluster for load balancing of +reporting requires identical values for `xpack.reporting.encryptionKey` and, if +security is enabled, `xpack.security.encryptionKey`. +============ + `xpack.reporting.queue.pollInterval`:: -How often idle workers poll the index for pending jobs. Defaults to `3000` (3 seconds). +Specifies the number of milliseconds that idle workers wait between polling the +index for pending jobs. Defaults to `3000` (3 seconds). [[xpack-reporting-q-timeout]]`xpack.reporting.queue.timeout`:: How long each worker has to produce a report. If your machine is slow or under diff --git a/x-pack/plugins/reporting/index.js b/x-pack/plugins/reporting/index.js index ee1514e9bf92..50c4371e92f2 100644 --- a/x-pack/plugins/reporting/index.js +++ b/x-pack/plugins/reporting/index.js @@ -71,6 +71,7 @@ export const reporting = (kibana) => { }).default(), queue: Joi.object({ indexInterval: Joi.string().default('week'), + pollEnabled: Joi.boolean().default(true), pollInterval: Joi.number().integer().default(3000), pollIntervalErrorMultiplier: Joi.number().integer().default(10), timeout: Joi.number().integer().default(120000), diff --git a/x-pack/plugins/reporting/server/lib/create_queue.js b/x-pack/plugins/reporting/server/lib/create_queue.js index 7d221149b9b5..c09220a52c23 100644 --- a/x-pack/plugins/reporting/server/lib/create_queue.js +++ b/x-pack/plugins/reporting/server/lib/create_queue.js @@ -18,18 +18,30 @@ function createQueueFn(server) { const createWorkers = createWorkersFactory(server); const { getClient } = server.plugins.elasticsearch.getCluster('admin'); + const logger = createTaggedLogger(server, ['reporting', 'esqueue']); const queueOptions = { doctype: QUEUE_DOCTYPE, interval: queueConfig.indexInterval, timeout: queueConfig.timeout, dateSeparator: dateSeparator, client: getClient(), - logger: createTaggedLogger(server, ['reporting', 'esqueue']) + logger, }; const queue = new Esqueue(index, queueOptions); - createWorkers(queue); + if (queueConfig.pollEnabled) { + // create workers to poll the index for idle jobs waiting to be claimed and executed + createWorkers(queue); + } else { + logger( + 'xpack.reporting.queue.pollEnabled is set to false. This Kibana instance ' + + 'will not poll for idle jobs to claim and execute. Make sure another ' + + 'Kibana instance with polling enabled is running in this cluster so ' + + 'reporting jobs can complete.', + ['info'] + ); + } return queue; }