[Monitoring] Refactor index patterns from configurable to constants (#29528)
* Move away from index patterns as configs and move them into constants * Refactor more usages of the index patterns * Remove debug * Update comment * Fix mocha tests * PR feedback
This commit is contained in:
parent
cc0e2d0d7d
commit
c443fee919
|
@ -152,3 +152,10 @@ export const DEBOUNCE_FAST_MS = 10; // roughly how long it takes to render a fra
|
|||
export const CLUSTER_ALERTS_ADDRESS_CONFIG_KEY = 'cluster_alerts.email_notifications.email_address';
|
||||
|
||||
export const STANDALONE_CLUSTER_CLUSTER_UUID = '__standalone_cluster__';
|
||||
|
||||
export const INDEX_PATTERN = '.monitoring-*-6-*';
|
||||
export const INDEX_PATTERN_KIBANA = '.monitoring-kibana-6-*';
|
||||
export const INDEX_PATTERN_LOGSTASH = '.monitoring-logstash-6-*';
|
||||
export const INDEX_PATTERN_BEATS = '.monitoring-beats-6-*';
|
||||
export const INDEX_ALERTS = '.monitoring-alerts-6';
|
||||
export const INDEX_PATTERN_ELASTICSEARCH = '.monitoring-es-6-*';
|
||||
|
|
|
@ -30,23 +30,14 @@ export const config = (Joi) => {
|
|||
}).default()
|
||||
}).default()
|
||||
}).default(),
|
||||
index_pattern: Joi.string().default('.monitoring-*-6-*'),
|
||||
kibana: Joi.object({
|
||||
index_pattern: Joi.string().default('.monitoring-kibana-6-*'),
|
||||
collection: Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
interval: Joi.number().default(10000) // op status metrics get buffered at `ops.interval` and flushed to the bulk endpoint at this interval
|
||||
}).default()
|
||||
}).default(),
|
||||
logstash: Joi.object({
|
||||
index_pattern: Joi.string().default('.monitoring-logstash-6-*')
|
||||
}).default(),
|
||||
beats: Joi.object({
|
||||
index_pattern: Joi.string().default('.monitoring-beats-6-*')
|
||||
}).default(),
|
||||
cluster_alerts: Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
index: Joi.string().default('.monitoring-alerts-6'),
|
||||
email_notifications: Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
email_address: Joi.string().email(),
|
||||
|
@ -62,7 +53,6 @@ export const config = (Joi) => {
|
|||
}).default(),
|
||||
elasticsearch: Joi.object({
|
||||
customHeaders: Joi.object().default({}),
|
||||
index_pattern: Joi.string().default('.monitoring-es-6-*'),
|
||||
logQueries: Joi.boolean().default(false),
|
||||
requestHeadersWhitelist: Joi.array().items().single().default(DEFAULT_REQUEST_HEADERS),
|
||||
sniffOnStart: Joi.boolean().default(false),
|
||||
|
|
|
@ -10,76 +10,65 @@ import { parseCrossClusterPrefix, prefixIndexPattern } from '../ccs_utils';
|
|||
|
||||
describe('ccs_utils', () => {
|
||||
describe('prefixIndexPattern', () => {
|
||||
const indexPatternName = 'xyz';
|
||||
const indexPattern = '.monitoring-xyz-1-*,.monitoring-xyz-2-*';
|
||||
|
||||
it('returns the index pattern if ccs is not enabled', () => {
|
||||
const get = sinon.stub();
|
||||
const config = { get };
|
||||
|
||||
get.withArgs(indexPatternName).returns(indexPattern);
|
||||
get.withArgs('xpack.monitoring.ccs.enabled').returns(false);
|
||||
|
||||
// falsy string values should be ignored
|
||||
const allPattern = prefixIndexPattern(config, indexPatternName, '*');
|
||||
const onePattern = prefixIndexPattern(config, indexPatternName, 'do_not_use_me');
|
||||
const allPattern = prefixIndexPattern(config, indexPattern, '*');
|
||||
const onePattern = prefixIndexPattern(config, indexPattern, 'do_not_use_me');
|
||||
|
||||
expect(allPattern).to.be(indexPattern);
|
||||
expect(onePattern).to.be(indexPattern);
|
||||
// uses the config and indexPatternName supplied
|
||||
expect(get.callCount).to.eql(4);
|
||||
expect(get.callCount).to.eql(2);
|
||||
});
|
||||
|
||||
it('returns the index pattern if ccs is not used', () => {
|
||||
const get = sinon.stub();
|
||||
const config = { get };
|
||||
|
||||
get.withArgs(indexPatternName).returns(indexPattern);
|
||||
get.withArgs('xpack.monitoring.ccs.enabled').returns(true);
|
||||
|
||||
// falsy string values should be ignored
|
||||
const undefinedPattern = prefixIndexPattern(config, indexPatternName);
|
||||
const nullPattern = prefixIndexPattern(config, indexPatternName, null);
|
||||
const blankPattern = prefixIndexPattern(config, indexPatternName, '');
|
||||
const undefinedPattern = prefixIndexPattern(config, indexPattern);
|
||||
const nullPattern = prefixIndexPattern(config, indexPattern, null);
|
||||
const blankPattern = prefixIndexPattern(config, indexPattern, '');
|
||||
|
||||
expect(undefinedPattern).to.be(indexPattern);
|
||||
expect(nullPattern).to.be(indexPattern);
|
||||
expect(blankPattern).to.be(indexPattern);
|
||||
// uses the config and indexPatternName supplied
|
||||
expect(get.callCount).to.eql(6);
|
||||
expect(get.callCount).to.eql(3);
|
||||
});
|
||||
|
||||
it('returns the ccs-prefixed index pattern', () => {
|
||||
const get = sinon.stub();
|
||||
const config = { get };
|
||||
|
||||
get.withArgs(indexPatternName).returns(indexPattern);
|
||||
get.withArgs('xpack.monitoring.ccs.enabled').returns(true);
|
||||
|
||||
const abcPattern = prefixIndexPattern(config, indexPatternName, 'aBc');
|
||||
const underscorePattern = prefixIndexPattern(config, indexPatternName, 'cluster_one');
|
||||
const abcPattern = prefixIndexPattern(config, indexPattern, 'aBc');
|
||||
const underscorePattern = prefixIndexPattern(config, indexPattern, 'cluster_one');
|
||||
|
||||
expect(abcPattern).to.eql('aBc:.monitoring-xyz-1-*,aBc:.monitoring-xyz-2-*');
|
||||
expect(underscorePattern).to.eql('cluster_one:.monitoring-xyz-1-*,cluster_one:.monitoring-xyz-2-*');
|
||||
|
||||
// uses the config and indexPatternName supplied, but only calls once
|
||||
expect(get.callCount).to.eql(4);
|
||||
expect(get.callCount).to.eql(2);
|
||||
});
|
||||
|
||||
it('returns the ccs-prefixed index pattern when wildcard and the local cluster pattern', () => {
|
||||
const get = sinon.stub();
|
||||
const config = { get };
|
||||
|
||||
get.withArgs(indexPatternName).returns(indexPattern);
|
||||
get.withArgs('xpack.monitoring.ccs.enabled').returns(true);
|
||||
|
||||
const pattern = prefixIndexPattern(config, indexPatternName, '*');
|
||||
const pattern = prefixIndexPattern(config, indexPattern, '*');
|
||||
|
||||
// it should have BOTH patterns so that it searches all CCS clusters and the local cluster
|
||||
expect(pattern).to.eql('*:.monitoring-xyz-1-*,*:.monitoring-xyz-2-*' + ',' + indexPattern);
|
||||
|
||||
// uses the config and indexPatternName supplied, but only calls once
|
||||
expect(get.callCount).to.eql(2);
|
||||
expect(get.callCount).to.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
* which means that the index pattern will be returned without using {@code ccs}.
|
||||
*
|
||||
* @param {Object} config The Kibana configuration object.
|
||||
* @param {String} indexPatternName The index pattern name (e.g., 'xpack.monitoring.elasticsearch.index_pattern')
|
||||
* @param {String} indexPattern The index pattern name
|
||||
* @param {String} ccs The optional cluster-prefix to prepend.
|
||||
* @return {String} The index pattern with the {@code cluster} prefix appropriately prepended.
|
||||
*/
|
||||
export function prefixIndexPattern(config, indexPatternName, ccs) {
|
||||
export function prefixIndexPattern(config, indexPattern, ccs) {
|
||||
const ccsEnabled = config.get('xpack.monitoring.ccs.enabled');
|
||||
const indexPattern = config.get(indexPatternName);
|
||||
|
||||
if (!ccsEnabled || !ccs) {
|
||||
return indexPattern;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import Boom from 'boom';
|
||||
import { INDEX_PATTERN } from '../../../common/constants';
|
||||
|
||||
/*
|
||||
* Check the currently logged-in user's privileges for "read" privileges on the
|
||||
|
@ -36,7 +37,6 @@ export async function verifyMonitoringAuth(req) {
|
|||
*/
|
||||
async function verifyHasPrivileges(req) {
|
||||
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');
|
||||
const config = req.server.config();
|
||||
|
||||
const response = await callWithRequest(req, 'transport.request', {
|
||||
method: 'POST',
|
||||
|
@ -44,7 +44,7 @@ async function verifyHasPrivileges(req) {
|
|||
body: {
|
||||
index: [
|
||||
{
|
||||
names: [ config.get('xpack.monitoring.index_pattern') ], // uses wildcard
|
||||
names: [ INDEX_PATTERN ], // uses wildcard
|
||||
privileges: [ 'read' ]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -9,6 +9,7 @@ import { alertsClusterSearch } from '../../../../cluster_alerts/alerts_cluster_s
|
|||
import { checkLicense } from '../../../../cluster_alerts/check_license';
|
||||
import { getClusterLicense } from '../../../../lib/cluster/get_cluster_license';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH, INDEX_ALERTS } from '../../../../../common/constants';
|
||||
|
||||
/*
|
||||
* Cluster Alerts route.
|
||||
|
@ -35,8 +36,8 @@ export function clusterAlertsRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, 'xpack.monitoring.cluster_alerts.index', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, INDEX_ALERTS, ccs);
|
||||
const options = {
|
||||
start: req.payload.timeRange.min,
|
||||
end: req.payload.timeRange.max
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics';
|
|||
import { metricSet } from './metric_set_overview';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { getApmInfo } from '../../../../lib/apm';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function apmInstanceRoute(server) {
|
||||
server.route({
|
||||
|
@ -35,7 +36,7 @@ export function apmInstanceRoute(server) {
|
|||
const config = server.config();
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const ccs = req.payload.ccs;
|
||||
const apmIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
try {
|
||||
const [ metrics, apmSummary ] = await Promise.all([
|
||||
|
|
|
@ -8,6 +8,7 @@ import Joi from 'joi';
|
|||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { getStats, getApms } from '../../../../lib/apm';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function apmInstancesRoute(server) {
|
||||
server.route({
|
||||
|
@ -31,7 +32,7 @@ export function apmInstancesRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const apmIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics';
|
|||
import { metricSet } from './metric_set_overview';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { getApmClusterStatus } from './_get_apm_cluster_status';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function apmOverviewRoute(server) {
|
||||
server.route({
|
||||
|
@ -33,7 +34,7 @@ export function apmOverviewRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const apmIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
try {
|
||||
const [
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getBeatSummary } from '../../../../lib/beats';
|
|||
import { getMetrics } from '../../../../lib/details/get_metrics';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { metricSet } from './metric_set_detail';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function beatsDetailRoute(server) {
|
||||
server.route({
|
||||
|
@ -36,7 +37,7 @@ export function beatsDetailRoute(server) {
|
|||
const beatUuid = req.params.beatUuid;
|
||||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const beatsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
const summaryOptions = {
|
||||
clusterUuid,
|
||||
|
|
|
@ -8,6 +8,7 @@ import Joi from 'joi';
|
|||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { getStats, getBeats } from '../../../../lib/beats';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function beatsListingRoute(server) {
|
||||
server.route({
|
||||
|
@ -32,7 +33,7 @@ export function beatsListingRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const beatsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics';
|
|||
import { getLatestStats, getStats } from '../../../../lib/beats';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { metricSet } from './metric_set_overview';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../common/constants';
|
||||
|
||||
export function beatsOverviewRoute(server) {
|
||||
server.route({
|
||||
|
@ -34,7 +35,7 @@ export function beatsOverviewRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const beatsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
|
||||
try {
|
||||
const [
|
||||
|
|
|
@ -8,6 +8,13 @@ import Joi from 'joi';
|
|||
import { getClustersFromRequest } from '../../../../lib/cluster/get_clusters_from_request';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import {
|
||||
INDEX_PATTERN_KIBANA,
|
||||
INDEX_PATTERN_ELASTICSEARCH,
|
||||
INDEX_PATTERN_LOGSTASH,
|
||||
INDEX_PATTERN_BEATS,
|
||||
INDEX_ALERTS
|
||||
} from '../../../../../common/constants';
|
||||
|
||||
export function clusterRoute(server) {
|
||||
/*
|
||||
|
@ -33,12 +40,12 @@ export function clusterRoute(server) {
|
|||
handler: (req) => {
|
||||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.kibana.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, 'xpack.monitoring.cluster_alerts.index', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, INDEX_ALERTS, ccs);
|
||||
const indexPatterns = { esIndexPattern, kbnIndexPattern, lsIndexPattern, beatsIndexPattern, apmIndexPattern, alertsIndex };
|
||||
const options = {
|
||||
clusterUuid: req.params.clusterUuid,
|
||||
|
|
|
@ -9,6 +9,13 @@ import { getClustersFromRequest } from '../../../../lib/cluster/get_clusters_fro
|
|||
import { verifyMonitoringAuth } from '../../../../lib/elasticsearch/verify_monitoring_auth';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import {
|
||||
INDEX_PATTERN_ELASTICSEARCH,
|
||||
INDEX_PATTERN_KIBANA,
|
||||
INDEX_PATTERN_LOGSTASH,
|
||||
INDEX_PATTERN_BEATS,
|
||||
INDEX_ALERTS
|
||||
} from '../../../../../common/constants';
|
||||
|
||||
export function clustersRoute(server) {
|
||||
/*
|
||||
|
@ -40,12 +47,12 @@ export function clustersRoute(server) {
|
|||
// wildcard means to search _all_ clusters
|
||||
const ccs = '*';
|
||||
const config = server.config();
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.kibana.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.beats.index_pattern', ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, 'xpack.monitoring.cluster_alerts.index', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
const beatsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
const apmIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_BEATS, ccs);
|
||||
const alertsIndex = prefixIndexPattern(config, INDEX_ALERTS, ccs);
|
||||
const indexPatterns = { esIndexPattern, kbnIndexPattern, lsIndexPattern, beatsIndexPattern, apmIndexPattern, alertsIndex };
|
||||
|
||||
clusters = await getClustersFromRequest(req, indexPatterns);
|
||||
|
|
|
@ -9,6 +9,7 @@ import moment from 'moment';
|
|||
import { get, groupBy } from 'lodash';
|
||||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
function getBucketScript(max, min) {
|
||||
return {
|
||||
|
@ -185,7 +186,7 @@ export function ccrRoute(server) {
|
|||
async handler(req) {
|
||||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
try {
|
||||
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');
|
||||
|
|
|
@ -10,6 +10,7 @@ import Joi from 'joi';
|
|||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { getMetrics } from '../../../../lib/details/get_metrics';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
function getFormattedLeaderIndex(leaderIndex) {
|
||||
let leader = leaderIndex;
|
||||
|
@ -92,7 +93,7 @@ export function ccrShardRoute(server) {
|
|||
const index = req.params.index;
|
||||
const shardId = req.params.shardId;
|
||||
const ccs = req.payload.ccs;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
const filters = [
|
||||
{
|
||||
|
|
|
@ -13,6 +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 } from '../../../../../common/constants';
|
||||
|
||||
const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSet;
|
||||
|
||||
|
@ -45,7 +46,7 @@ export function esIndexRoute(server) {
|
|||
const indexUuid = req.params.id;
|
||||
const start = req.payload.timeRange.min;
|
||||
const end = req.payload.timeRange.max;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
const isAdvanced = req.payload.is_advanced;
|
||||
const metricSet = isAdvanced ? metricSetAdvanced : metricSetOverview;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import { getIndices } from '../../../../lib/elasticsearch/indices';
|
|||
import { getShardStats } from '../../../../lib/elasticsearch/shards';
|
||||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
export function esIndicesRoute(server) {
|
||||
server.route({
|
||||
|
@ -38,7 +39,7 @@ export function esIndicesRoute(server) {
|
|||
const { clusterUuid } = req.params;
|
||||
const { show_system_indices: showSystemIndices } = req.query;
|
||||
const { ccs } = req.payload;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
try {
|
||||
const clusterStats = await getClusterStats(req, esIndexPattern, clusterUuid);
|
||||
|
|
|
@ -11,6 +11,7 @@ import { getMlJobs } from '../../../../lib/elasticsearch/get_ml_jobs';
|
|||
import { getShardStats } from '../../../../lib/elasticsearch/shards';
|
||||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
export function mlJobRoute(server) {
|
||||
server.route({
|
||||
|
@ -34,7 +35,7 @@ export function mlJobRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
try {
|
||||
const clusterStats = await getClusterStats(req, esIndexPattern, clusterUuid);
|
||||
|
|
|
@ -13,6 +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 } from '../../../../../common/constants';
|
||||
|
||||
const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSets;
|
||||
|
||||
|
@ -45,7 +46,7 @@ export function esNodeRoute(server) {
|
|||
const nodeUuid = req.params.nodeUuid;
|
||||
const start = req.payload.timeRange.min;
|
||||
const end = req.payload.timeRange.max;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
const isAdvanced = req.payload.is_advanced;
|
||||
|
||||
let metricSet;
|
||||
|
|
|
@ -11,6 +11,7 @@ import { getNodes } from '../../../../lib/elasticsearch/nodes';
|
|||
import { getShardStats } from '../../../../lib/elasticsearch/shards';
|
||||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
export function esNodesRoute(server) {
|
||||
server.route({
|
||||
|
@ -34,7 +35,7 @@ export function esNodesRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
try {
|
||||
const clusterStats = await getClusterStats(req, esIndexPattern, clusterUuid);
|
||||
|
|
|
@ -13,6 +13,7 @@ import { getShardStats } from '../../../../lib/elasticsearch/shards';
|
|||
import { handleError } from '../../../../lib/errors/handle_error';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { metricSet } from './metric_set_overview';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
export function esOverviewRoute(server) {
|
||||
server.route({
|
||||
|
@ -36,7 +37,7 @@ export function esOverviewRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const esIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.elasticsearch.index_pattern', ccs);
|
||||
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
|
||||
|
||||
try {
|
||||
const [ clusterStats, metrics, shardActivity ] = await Promise.all([
|
||||
|
|
|
@ -10,6 +10,7 @@ import { handleError } from '../../../../lib/errors';
|
|||
import { getMetrics } from '../../../../lib/details/get_metrics';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { metricSet } from './metric_set_instance';
|
||||
import { INDEX_PATTERN_KIBANA } from '../../../../../common/constants';
|
||||
|
||||
/**
|
||||
* Kibana instance: This will fetch all data required to display a Kibana
|
||||
|
@ -41,7 +42,7 @@ export function kibanaInstanceRoute(server) {
|
|||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const kibanaUuid = req.params.kibanaUuid;
|
||||
const kbnIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.kibana.index_pattern', ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
|
||||
|
||||
try {
|
||||
const [ metrics, kibanaSummary ] = await Promise.all([
|
||||
|
|
|
@ -9,6 +9,7 @@ import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
|||
import { getKibanaClusterStatus } from './_get_kibana_cluster_status';
|
||||
import { getKibanas } from '../../../../lib/kibana/get_kibanas';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { INDEX_PATTERN_KIBANA } from '../../../../../common/constants';
|
||||
|
||||
export function kibanaInstancesRoute(server) {
|
||||
/**
|
||||
|
@ -35,7 +36,7 @@ export function kibanaInstancesRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const kbnIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.kibana.index_pattern', ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
|
||||
|
||||
try {
|
||||
const [ clusterStatus, kibanas ] = await Promise.all([
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getKibanaClusterStatus } from './_get_kibana_cluster_status';
|
|||
import { getMetrics } from '../../../../lib/details/get_metrics';
|
||||
import { metricSet } from './metric_set_overview';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { INDEX_PATTERN_KIBANA } from '../../../../../common/constants';
|
||||
|
||||
export function kibanaOverviewRoute(server) {
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ export function kibanaOverviewRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const kbnIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.kibana.index_pattern', ccs);
|
||||
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
|
||||
|
||||
try {
|
||||
const [ clusterStatus, metrics ] = await Promise.all([
|
||||
|
|
|
@ -10,6 +10,7 @@ import { handleError } from '../../../../lib/errors';
|
|||
import { getMetrics } from '../../../../lib/details/get_metrics';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { metricSets } from './metric_set_node';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSets;
|
||||
|
||||
|
@ -50,7 +51,7 @@ export function logstashNodeRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
const logstashUuid = req.params.logstashUuid;
|
||||
|
||||
let metricSet;
|
||||
|
|
|
@ -9,6 +9,7 @@ import { getClusterStatus } from '../../../../lib/logstash/get_cluster_status';
|
|||
import { getNodes } from '../../../../lib/logstash/get_nodes';
|
||||
import { handleError } from '../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
/*
|
||||
* Logstash Nodes route.
|
||||
|
@ -45,7 +46,7 @@ export function logstashNodesRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
|
||||
try {
|
||||
const [ clusterStatus, nodes ] = await Promise.all([
|
||||
|
|
|
@ -10,6 +10,7 @@ import { getMetrics } from '../../../../lib/details/get_metrics';
|
|||
import { handleError } from '../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { metricSet } from './metric_set_overview';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
/*
|
||||
* Logstash Overview route.
|
||||
|
@ -46,7 +47,7 @@ export function logstashOverviewRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
|
||||
try {
|
||||
const [ metrics, clusterStatus ] = await Promise.all([
|
||||
|
|
|
@ -8,6 +8,7 @@ import Joi from 'joi';
|
|||
import { handleError } from '../../../../lib/errors';
|
||||
import { getPipeline } from '../../../../lib/logstash/get_pipeline';
|
||||
import { prefixIndexPattern } from '../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
/*
|
||||
* Logstash Pipeline route.
|
||||
|
@ -41,7 +42,7 @@ export function logstashPipelineRoute(server) {
|
|||
const config = server.config();
|
||||
const ccs = req.payload.ccs;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
|
||||
const pipelineId = req.params.pipelineId;
|
||||
// Optional params default to empty string, set to null to be more explicit.
|
||||
|
|
|
@ -9,6 +9,7 @@ import { getClusterStatus } from '../../../../../lib/logstash/get_cluster_status
|
|||
import { getPipelines, processPipelinesAPIResponse } from '../../../../../lib/logstash/get_pipelines';
|
||||
import { handleError } from '../../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../../common/constants';
|
||||
|
||||
/**
|
||||
* Retrieve pipelines for a cluster
|
||||
|
@ -35,7 +36,7 @@ export function logstashClusterPipelinesRoute(server) {
|
|||
const config = server.config();
|
||||
const { ccs } = req.payload;
|
||||
const clusterUuid = req.params.clusterUuid;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
|
||||
const throughputMetric = 'logstash_cluster_pipeline_throughput';
|
||||
const nodesCountMetric = 'logstash_cluster_pipeline_nodes_count';
|
||||
|
|
|
@ -9,6 +9,7 @@ import { getNodeInfo } from '../../../../../lib/logstash/get_node_info';
|
|||
import { getPipelines, processPipelinesAPIResponse } from '../../../../../lib/logstash/get_pipelines';
|
||||
import { handleError } from '../../../../../lib/errors';
|
||||
import { prefixIndexPattern } from '../../../../../lib/ccs_utils';
|
||||
import { INDEX_PATTERN_LOGSTASH } from '../../../../../../common/constants';
|
||||
|
||||
/**
|
||||
* Retrieve pipelines for a node
|
||||
|
@ -36,7 +37,7 @@ export function logstashNodePipelinesRoute(server) {
|
|||
const config = server.config();
|
||||
const { ccs } = req.payload;
|
||||
const { clusterUuid, logstashUuid } = req.params;
|
||||
const lsIndexPattern = prefixIndexPattern(config, 'xpack.monitoring.logstash.index_pattern', ccs);
|
||||
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs);
|
||||
const throughputMetric = 'logstash_node_pipeline_throughput';
|
||||
const nodesCountMetric = 'logstash_node_pipeline_nodes_count';
|
||||
const metricSet = [
|
||||
|
|
|
@ -34,6 +34,12 @@ export const KIBANA_SYSTEM_ID = 'kibana';
|
|||
*/
|
||||
export const BEATS_SYSTEM_ID = 'beats';
|
||||
|
||||
/**
|
||||
* The name of the Apm System ID used to publish and look up Apm stats through the Monitoring system.
|
||||
* @type {string}
|
||||
*/
|
||||
export const APM_SYSTEM_ID = 'beats';
|
||||
|
||||
/**
|
||||
* The name of the Kibana System ID used to look up Logstash stats through the Monitoring system.
|
||||
* @type {string}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import { createQuery } from './create_query';
|
||||
import { INDEX_PATTERN_BEATS } from '../../../../../monitoring/common/constants';
|
||||
|
||||
const HITS_SIZE = 10000; // maximum hits to receive from ES with each search
|
||||
|
||||
|
@ -173,10 +174,8 @@ export function processResults(results = [], { clusters, clusterHostSets, cluste
|
|||
* @return {Promise}
|
||||
*/
|
||||
async function fetchBeatsByType(server, callCluster, clusterUuids, start, end, { page = 0, ...options } = {}, type) {
|
||||
const config = server.config();
|
||||
|
||||
const params = {
|
||||
index: config.get('xpack.monitoring.beats.index_pattern'),
|
||||
index: INDEX_PATTERN_BEATS,
|
||||
ignoreUnavailable: true,
|
||||
filterPath: [
|
||||
'hits.hits._source.cluster_uuid',
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import { createQuery } from './create_query';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../monitoring/common/constants';
|
||||
|
||||
/**
|
||||
* Get a list of Cluster UUIDs that exist within the specified timespan.
|
||||
|
@ -33,7 +34,7 @@ export function getClusterUuids(server, callCluster, start, end) {
|
|||
export function fetchClusterUuids(server, callCluster, start, end) {
|
||||
const config = server.config();
|
||||
const params = {
|
||||
index: config.get('xpack.monitoring.elasticsearch.index_pattern'),
|
||||
index: INDEX_PATTERN_ELASTICSEARCH,
|
||||
size: 0,
|
||||
ignoreUnavailable: true,
|
||||
filterPath: 'aggregations.cluster_uuids.buckets.key',
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { get } from 'lodash';
|
||||
import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../../monitoring/common/constants';
|
||||
|
||||
/**
|
||||
* Get statistics for all selected Elasticsearch clusters.
|
||||
|
@ -30,7 +31,7 @@ export function getElasticsearchStats(server, callCluster, clusterUuids) {
|
|||
export function fetchElasticsearchStats(server, callCluster, clusterUuids) {
|
||||
const config = server.config();
|
||||
const params = {
|
||||
index: config.get('xpack.monitoring.elasticsearch.index_pattern'),
|
||||
index: INDEX_PATTERN_ELASTICSEARCH,
|
||||
size: config.get('xpack.monitoring.max_bucket_size'),
|
||||
ignoreUnavailable: true,
|
||||
filterPath: [
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import { createQuery } from './create_query';
|
||||
import { INDEX_PATTERN_KIBANA, INDEX_PATTERN_BEATS, INDEX_PATTERN_LOGSTASH } from '../../../../../monitoring/common/constants';
|
||||
import { KIBANA_SYSTEM_ID, BEATS_SYSTEM_ID, APM_SYSTEM_ID, LOGSTASH_SYSTEM_ID } from '../../../../common/constants';
|
||||
|
||||
/**
|
||||
* Update a counter associated with the {@code key}.
|
||||
|
@ -139,6 +141,24 @@ function mapToList(map, keyName) {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the right index pattern to find monitoring documents based on the product id
|
||||
*
|
||||
* @param {*} product The product id, which should be in the constants file
|
||||
*/
|
||||
function getIndexPatternForStackProduct(product) {
|
||||
switch (product) {
|
||||
case KIBANA_SYSTEM_ID:
|
||||
return INDEX_PATTERN_KIBANA;
|
||||
case BEATS_SYSTEM_ID:
|
||||
case APM_SYSTEM_ID:
|
||||
return INDEX_PATTERN_BEATS;
|
||||
case LOGSTASH_SYSTEM_ID:
|
||||
return INDEX_PATTERN_LOGSTASH;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get statistics about selected Elasticsearch clusters, for the selected {@code product}.
|
||||
*
|
||||
|
@ -170,7 +190,7 @@ export function getHighLevelStats(server, callCluster, clusterUuids, start, end,
|
|||
export function fetchHighLevelStats(server, callCluster, clusterUuids, start, end, product) {
|
||||
const config = server.config();
|
||||
const params = {
|
||||
index: config.get(`xpack.monitoring.${product}.index_pattern`),
|
||||
index: getIndexPatternForStackProduct(product),
|
||||
size: config.get('xpack.monitoring.max_bucket_size'),
|
||||
ignoreUnavailable: true,
|
||||
filterPath: [
|
||||
|
|
Loading…
Reference in a new issue