Skip to content

Commit

Permalink
Add new config for filebeat index name (#56920)
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipb committed Feb 7, 2020
1 parent f02608c commit 4358a01
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 23 deletions.
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-';

Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/monitoring/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/*
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand Down

0 comments on commit 4358a01

Please sign in to comment.