diff --git a/x-pack/legacy/plugins/monitoring/common/constants.ts b/x-pack/legacy/plugins/monitoring/common/constants.ts index 53764f592dc15..1fc322a0de395 100644 --- a/x-pack/legacy/plugins/monitoring/common/constants.ts +++ b/x-pack/legacy/plugins/monitoring/common/constants.ts @@ -159,8 +159,6 @@ export const INDEX_ALERTS = '.monitoring-alerts-6,.monitoring-alerts-7' + INDEX_ export const INDEX_PATTERN_ELASTICSEARCH = '.monitoring-es-6-*,.monitoring-es-7-*' + INDEX_PATTERN_ELASTICSEARCH_NEW; -export const INDEX_PATTERN_FILEBEAT = 'filebeat-*'; - // This is the unique token that exists in monitoring indices collected by metricbeat export const METRICBEAT_INDEX_NAME_UNIQUE_TOKEN = '-mb-'; diff --git a/x-pack/legacy/plugins/monitoring/config.js b/x-pack/legacy/plugins/monitoring/config.js index 778b656c056f2..ec4c00ccbea11 100644 --- a/x-pack/legacy/plugins/monitoring/config.js +++ b/x-pack/legacy/plugins/monitoring/config.js @@ -18,6 +18,9 @@ export const config = Joi => { enabled: Joi.boolean().default(true), ui: Joi.object({ enabled: Joi.boolean().default(true), + logs: Joi.object({ + index: Joi.string().default('filebeat-*'), + }).default(), ccs: Joi.object({ enabled: Joi.boolean().default(true), }).default(), diff --git a/x-pack/legacy/plugins/monitoring/index.js b/x-pack/legacy/plugins/monitoring/index.js index ade172f527dab..25b88958c116f 100644 --- a/x-pack/legacy/plugins/monitoring/index.js +++ b/x-pack/legacy/plugins/monitoring/index.js @@ -50,6 +50,7 @@ export const monitoring = kibana => 'monitoring.cluster_alerts.email_notifications.email_address', 'monitoring.ui.ccs.enabled', 'monitoring.ui.elasticsearch.logFetchCount', + 'monitoring.ui.logs.index', ]; const serverConfig = server.config(); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/init_infra_source.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/init_infra_source.js index f2b179fe014b3..7ca36e8b29553 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logs/init_infra_source.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/init_infra_source.js @@ -5,11 +5,15 @@ */ import { prefixIndexPattern } from '../ccs_utils'; -import { INDEX_PATTERN_FILEBEAT, INFRA_SOURCE_ID } from '../../../common/constants'; +import { INFRA_SOURCE_ID } from '../../../common/constants'; export const initInfraSource = (config, infraPlugin) => { if (infraPlugin) { - const filebeatIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_FILEBEAT, '*'); + const filebeatIndexPattern = prefixIndexPattern( + config, + config.get('monitoring.ui.logs.index'), + '*' + ); infraPlugin.defineInternalSourceConfiguration(INFRA_SOURCE_ID, { name: 'Elastic Stack Logs', logAlias: filebeatIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/cluster.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/cluster.js index 5c85a10edbc29..b2c2db7ea793e 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/cluster.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/cluster.js @@ -9,7 +9,6 @@ import { getClustersFromRequest } from '../../../../lib/cluster/get_clusters_fro import { handleError } from '../../../../lib/errors'; import { getIndexPatterns } from '../../../../lib/cluster/get_index_patterns'; import { verifyCcsAvailability } from '../../../../lib/elasticsearch/verify_ccs_availability'; -import { INDEX_PATTERN_FILEBEAT } from '../../../../../common/constants'; export function clusterRoute(server) { /* @@ -37,9 +36,10 @@ export function clusterRoute(server) { }, handler: async req => { await verifyCcsAvailability(req); + const config = server.config(); const indexPatterns = getIndexPatterns(server, { - filebeatIndexPattern: INDEX_PATTERN_FILEBEAT, + filebeatIndexPattern: config.get('monitoring.ui.logs.index'), }); const options = { clusterUuid: req.params.clusterUuid, diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/clusters.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/clusters.js index 6342a9436f6c7..92f0367097228 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/cluster/clusters.js @@ -9,7 +9,6 @@ import { getClustersFromRequest } from '../../../../lib/cluster/get_clusters_fro import { verifyMonitoringAuth } from '../../../../lib/elasticsearch/verify_monitoring_auth'; import { verifyCcsAvailability } from '../../../../lib/elasticsearch/verify_ccs_availability'; import { handleError } from '../../../../lib/errors'; -import { INDEX_PATTERN_FILEBEAT } from '../../../../../common/constants'; import { getIndexPatterns } from '../../../../lib/cluster/get_index_patterns'; export function clustersRoute(server) { @@ -34,6 +33,7 @@ export function clustersRoute(server) { }, }, handler: async req => { + const config = server.config(); let clusters = []; // NOTE using try/catch because checkMonitoringAuth is expected to throw @@ -43,7 +43,7 @@ export function clustersRoute(server) { await verifyMonitoringAuth(req); await verifyCcsAvailability(req); const indexPatterns = getIndexPatterns(server, { - filebeatIndexPattern: INDEX_PATTERN_FILEBEAT, + filebeatIndexPattern: config.get('monitoring.ui.logs.index'), }); clusters = await getClustersFromRequest(req, indexPatterns, { codePaths: req.payload.codePaths, diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/index_detail.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/index_detail.js index c32e25d9f20d1..6f03459acf285 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/index_detail.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/index_detail.js @@ -13,10 +13,7 @@ import { getShardAllocation, getShardStats } from '../../../../lib/elasticsearch import { handleError } from '../../../../lib/errors/handle_error'; import { prefixIndexPattern } from '../../../../lib/ccs_utils'; import { metricSet } from './metric_set_index_detail'; -import { - INDEX_PATTERN_ELASTICSEARCH, - INDEX_PATTERN_FILEBEAT, -} from '../../../../../common/constants'; +import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants'; import { getLogs } from '../../../../lib/logs/get_logs'; const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSet; @@ -50,7 +47,11 @@ export function esIndexRoute(server) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs); - const filebeatIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_FILEBEAT, ccs); + const filebeatIndexPattern = prefixIndexPattern( + config, + config.get('monitoring.ui.logs.index'), + ccs + ); const isAdvanced = req.payload.is_advanced; const metricSet = isAdvanced ? metricSetAdvanced : metricSetOverview; diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js index 25ead723e3ddb..364214d45c2da 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/node_detail.js @@ -13,10 +13,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics'; import { handleError } from '../../../../lib/errors/handle_error'; import { prefixIndexPattern } from '../../../../lib/ccs_utils'; import { metricSets } from './metric_set_node_detail'; -import { - INDEX_PATTERN_ELASTICSEARCH, - INDEX_PATTERN_FILEBEAT, -} from '../../../../../common/constants'; +import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants'; import { getLogs } from '../../../../lib/logs/get_logs'; const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSets; @@ -51,7 +48,11 @@ export function esNodeRoute(server) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs); - const filebeatIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_FILEBEAT, '*'); + const filebeatIndexPattern = prefixIndexPattern( + config, + config.get('monitoring.ui.logs.index'), + '*' + ); const isAdvanced = req.payload.is_advanced; let metricSet; diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/overview.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/overview.js index b0045502fa228..df1e847c16606 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/overview.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/overview.js @@ -12,10 +12,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics'; import { handleError } from '../../../../lib/errors/handle_error'; import { prefixIndexPattern } from '../../../../lib/ccs_utils'; import { metricSet } from './metric_set_overview'; -import { - INDEX_PATTERN_ELASTICSEARCH, - INDEX_PATTERN_FILEBEAT, -} from '../../../../../common/constants'; +import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants'; import { getLogs } from '../../../../lib/logs'; import { getIndicesUnassignedShardStats } from '../../../../lib/elasticsearch/shards/get_indices_unassigned_shard_stats'; @@ -42,7 +39,11 @@ export function esOverviewRoute(server) { const ccs = req.payload.ccs; const clusterUuid = req.params.clusterUuid; const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs); - const filebeatIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_FILEBEAT, '*'); + const filebeatIndexPattern = prefixIndexPattern( + config, + config.get('monitoring.ui.logs.index'), + '*' + ); const start = req.payload.timeRange.min; const end = req.payload.timeRange.max;