diff --git a/src/core_plugins/apm_oss/index.js b/src/core_plugins/apm_oss/index.js new file mode 100644 index 0000000000000..69ff8901d2f3f --- /dev/null +++ b/src/core_plugins/apm_oss/index.js @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export default function apmOss(kibana) { + return new kibana.Plugin({ + id: 'apm_oss', + + config(Joi) { + return Joi.object({ + // enable plugin + enabled: Joi.boolean().default(true), + + // Kibana Index pattern + indexPattern: Joi.string().default('apm-*'), + + // ES Indices + errorIndices: Joi.string().default('apm-*-error-*'), + onboardingIndices: Joi.string().default('apm-*-onboarding-*'), + spanIndices: Joi.string().default('apm-*-span-*'), + transactionIndices: Joi.string().default('apm-*-transaction-*'), + }).default(); + }, + }); +} diff --git a/src/core_plugins/apm_oss/package.json b/src/core_plugins/apm_oss/package.json new file mode 100644 index 0000000000000..4ca161f293e79 --- /dev/null +++ b/src/core_plugins/apm_oss/package.json @@ -0,0 +1,4 @@ +{ + "name": "apm_oss", + "version": "kibana" +} diff --git a/src/core_plugins/kibana/server/tutorials/apm/index.js b/src/core_plugins/kibana/server/tutorials/apm/index.js index 72224ead9c610..107b1ad8d1da8 100644 --- a/src/core_plugins/kibana/server/tutorials/apm/index.js +++ b/src/core_plugins/kibana/server/tutorials/apm/index.js @@ -24,8 +24,8 @@ import { getSavedObjects } from './saved_objects/get_saved_objects'; const apmIntro = 'Collect in-depth performance metrics and errors from inside your applications.'; -const ENABLED_KEY = 'xpack.apm.ui.enabled'; function isEnabled(config) { + const ENABLED_KEY = 'xpack.apm.ui.enabled'; if (config.has(ENABLED_KEY)) { return config.get(ENABLED_KEY); } @@ -33,19 +33,9 @@ function isEnabled(config) { return false; } -const TITLE_KEY = 'xpack.apm.indexPattern'; -const DEFAULT_TITLE = 'apm*'; -function getIndexPatternTitle(config) { - if (config.has(TITLE_KEY)) { - return config.get(TITLE_KEY); - } - - return DEFAULT_TITLE; -} - export function apmSpecProvider(server) { const config = server.config(); - const apmIndexPattern = getIndexPatternTitle(config); + const apmIndexPattern = config.get('apm_oss.indexPattern'); const artifacts = { dashboards: [ diff --git a/src/core_plugins/kibana/server/tutorials/apm/saved_objects/get_saved_objects.test.js b/src/core_plugins/kibana/server/tutorials/apm/saved_objects/get_saved_objects.test.js index 19991f17877b0..139f66ae7f564 100644 --- a/src/core_plugins/kibana/server/tutorials/apm/saved_objects/get_saved_objects.test.js +++ b/src/core_plugins/kibana/server/tutorials/apm/saved_objects/get_saved_objects.test.js @@ -22,7 +22,7 @@ import { getSavedObjects } from './get_saved_objects'; const indexPatternTitle = 'dynamic index pattern title'; -test('should dynamically set index title to "xpack.apm.indexPattern" yaml config value', () => { +test('should dynamically set index title to "apm_oss.indexPattern" yaml config value', () => { const savedObjects = getSavedObjects(indexPatternTitle); const indexPattern = savedObjects[0]; expect(indexPattern.type).to.be('index-pattern'); diff --git a/x-pack/plugins/apm/index.js b/x-pack/plugins/apm/index.js index 8b60392ef2d06..4929056878dc4 100644 --- a/x-pack/plugins/apm/index.js +++ b/x-pack/plugins/apm/index.js @@ -12,7 +12,7 @@ import { initStatusApi } from './server/routes/status_check'; export function apm(kibana) { return new kibana.Plugin({ - require: ['kibana', 'elasticsearch', 'xpack_main'], + require: ['kibana', 'elasticsearch', 'xpack_main', 'apm_oss'], id: 'apm', configPrefix: 'xpack.apm', publicDir: resolve(__dirname, 'public'), @@ -30,7 +30,7 @@ export function apm(kibana) { return { mlEnabled: config.get('xpack.ml.enabled'), apmUiEnabled: config.get('xpack.apm.ui.enabled'), - apmIndexPattern: config.get('xpack.apm.indexPattern') + apmIndexPattern: config.get('apm_oss.indexPattern') }; }, hacks: ['plugins/apm/hacks/toggle_app_link_in_nav'] @@ -38,11 +38,15 @@ export function apm(kibana) { config(Joi) { return Joi.object({ + // display menu item ui: Joi.object({ enabled: Joi.boolean().default(true) }).default(), + + // enable plugin enabled: Joi.boolean().default(true), - indexPattern: Joi.string().default('apm*'), + + // buckets minimumBucketSize: Joi.number().default(15), bucketTargetCount: Joi.number().default(27) }).default(); diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js index a8f7450e024b6..9d77099e6d94f 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js @@ -10,7 +10,7 @@ export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_group.js b/x-pack/plugins/apm/server/lib/errors/get_error_group.js index 409b389dafbfa..f46a36262b4d2 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_group.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_group.js @@ -11,7 +11,7 @@ export async function getErrorGroup({ serviceName, groupId, setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.errorIndices'), body: { size: 1, query: { diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js b/x-pack/plugins/apm/server/lib/errors/get_error_groups.js index c2cfd84daab96..32d3cc685b5d6 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_groups.js @@ -24,7 +24,7 @@ export async function getErrorGroups({ const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/services/get_service.js b/x-pack/plugins/apm/server/lib/services/get_service.js index f7515a5dedcd0..416dfaf3746c4 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service.js +++ b/x-pack/plugins/apm/server/lib/services/get_service.js @@ -15,7 +15,10 @@ export async function getService({ serviceName, setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: [ + config.get('apm_oss.errorIndices'), + config.get('apm_oss.transactionIndices') + ], body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/services/get_services.js b/x-pack/plugins/apm/server/lib/services/get_services.js index 47648e0d638a8..37da74123ffdd 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services.js +++ b/x-pack/plugins/apm/server/lib/services/get_services.js @@ -16,7 +16,10 @@ export async function getServices({ setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: [ + config.get('apm_oss.errorIndices'), + config.get('apm_oss.transactionIndices') + ], body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/status_check/agent_check.js b/x-pack/plugins/apm/server/lib/status_check/agent_check.js index 35384ef857501..555a9bc120f54 100644 --- a/x-pack/plugins/apm/server/lib/status_check/agent_check.js +++ b/x-pack/plugins/apm/server/lib/status_check/agent_check.js @@ -10,7 +10,10 @@ export async function getAgentStatus({ setup }) { const { client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: [ + config.get('apm_oss.errorIndices'), + config.get('apm_oss.transactionIndices') + ], body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/status_check/server_check.js b/x-pack/plugins/apm/server/lib/status_check/server_check.js index 250811dd6f983..b216cd2c420a6 100644 --- a/x-pack/plugins/apm/server/lib/status_check/server_check.js +++ b/x-pack/plugins/apm/server/lib/status_check/server_check.js @@ -8,7 +8,7 @@ export async function getServerStatus({ setup }) { const { client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.onboardingIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js index 01080437678ed..8a9c68c013336 100644 --- a/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js +++ b/x-pack/plugins/apm/server/lib/transactions/charts/get_timeseries_data.js @@ -26,7 +26,7 @@ export async function getTimeseriesData({ const { intervalString, bucketSize } = getBucketSize(start, end, 'auto'); const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.js b/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.js index 90a5950c5f7a2..1102211f0cc1b 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.js +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/calculate_bucket_size.js @@ -18,7 +18,7 @@ export async function calculateBucketSize({ const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.js b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.js index 56e275cc372c0..d5c0d4835a7bf 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.js +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets.js @@ -24,7 +24,7 @@ export async function getBuckets({ const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.js b/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.js index f0fc70a58d3e4..e9e607f277f1a 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.js +++ b/x-pack/plugins/apm/server/lib/transactions/get_top_transactions.js @@ -25,7 +25,7 @@ export async function getTopTransactions({ const minutes = duration.asMinutes(); const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 0, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction.js b/x-pack/plugins/apm/server/lib/transactions/get_transaction.js index 2132a4602890d..3319814a4ec90 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction.js +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction.js @@ -11,7 +11,7 @@ async function getTransaction({ transactionId, setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 1, query: { diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction_duration.js b/x-pack/plugins/apm/server/lib/transactions/get_transaction_duration.js index a3ec24cba7834..fb9620fe9659a 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction_duration.js +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction_duration.js @@ -15,7 +15,7 @@ export async function getTransactionDuration({ transactionId, setup }) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.transactionIndices'), body: { size: 1, _source: TRANSACTION_DURATION, diff --git a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.js b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.js index d2ae00b47268e..b7f3a9f3d96df 100644 --- a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.js +++ b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.js @@ -15,7 +15,7 @@ async function getSpans({ transactionId, setup }) { const { start, end, client, config } = setup; const params = { - index: config.get('xpack.apm.indexPattern'), + index: config.get('apm_oss.spanIndices'), body: { size: 500, query: {