mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Uptime] Uptime index config using kibana.yml (#115775)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
0b2dcdf408
commit
98231f45ac
5 changed files with 35 additions and 1 deletions
|
@ -375,6 +375,7 @@ kibana_vars=(
|
|||
xpack.task_manager.poll_interval
|
||||
xpack.task_manager.request_capacity
|
||||
xpack.task_manager.version_conflict_threshold
|
||||
xpack.uptime.index
|
||||
)
|
||||
|
||||
longopts=''
|
||||
|
|
19
x-pack/plugins/uptime/server/config.ts
Normal file
19
x-pack/plugins/uptime/server/config.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
|
||||
export const config: PluginConfigDescriptor = {
|
||||
schema: schema.maybe(
|
||||
schema.object({
|
||||
index: schema.string(),
|
||||
})
|
||||
),
|
||||
};
|
||||
|
||||
export type UptimeConfig = TypeOf<typeof config.schema>;
|
|
@ -10,3 +10,5 @@ import { Plugin } from './plugin';
|
|||
|
||||
export const plugin = (initializerContext: PluginInitializerContext) =>
|
||||
new Plugin(initializerContext);
|
||||
|
||||
export { config } from './config';
|
||||
|
|
|
@ -10,8 +10,10 @@ import { DYNAMIC_SETTINGS_DEFAULTS } from '../../common/constants';
|
|||
import { DynamicSettings } from '../../common/runtime_types';
|
||||
import { SavedObjectsType, SavedObjectsErrorHelpers } from '../../../../../src/core/server';
|
||||
import { UMSavedObjectsQueryFn } from './adapters';
|
||||
import { UptimeConfig } from '../config';
|
||||
|
||||
export interface UMSavedObjectsAdapter {
|
||||
config: UptimeConfig;
|
||||
getUptimeDynamicSettings: UMSavedObjectsQueryFn<DynamicSettings>;
|
||||
setUptimeDynamicSettings: UMSavedObjectsQueryFn<void, DynamicSettings>;
|
||||
}
|
||||
|
@ -55,12 +57,17 @@ export const umDynamicSettings: SavedObjectsType = {
|
|||
};
|
||||
|
||||
export const savedObjectsAdapter: UMSavedObjectsAdapter = {
|
||||
config: null,
|
||||
getUptimeDynamicSettings: async (client): Promise<DynamicSettings> => {
|
||||
try {
|
||||
const obj = await client.get<DynamicSettings>(umDynamicSettings.name, settingsObjectId);
|
||||
return obj?.attributes ?? DYNAMIC_SETTINGS_DEFAULTS;
|
||||
} catch (getErr) {
|
||||
const config = savedObjectsAdapter.config;
|
||||
if (SavedObjectsErrorHelpers.isNotFoundError(getErr)) {
|
||||
if (config?.index) {
|
||||
return { ...DYNAMIC_SETTINGS_DEFAULTS, heartbeatIndices: config.index };
|
||||
}
|
||||
return DYNAMIC_SETTINGS_DEFAULTS;
|
||||
}
|
||||
throw getErr;
|
||||
|
|
|
@ -16,9 +16,10 @@ import {
|
|||
import { uptimeRuleFieldMap } from '../common/rules/uptime_rule_field_map';
|
||||
import { initServerWithKibana } from './kibana.index';
|
||||
import { KibanaTelemetryAdapter, UptimeCorePlugins } from './lib/adapters';
|
||||
import { umDynamicSettings } from './lib/saved_objects';
|
||||
import { savedObjectsAdapter, umDynamicSettings } from './lib/saved_objects';
|
||||
import { mappingFromFieldMap } from '../../rule_registry/common/mapping_from_field_map';
|
||||
import { Dataset } from '../../rule_registry/server';
|
||||
import { UptimeConfig } from './config';
|
||||
|
||||
export type UptimeRuleRegistry = ReturnType<Plugin['setup']>['ruleRegistry'];
|
||||
|
||||
|
@ -32,6 +33,10 @@ export class Plugin implements PluginType {
|
|||
}
|
||||
|
||||
public setup(core: CoreSetup, plugins: UptimeCorePlugins) {
|
||||
const config = this.initContext.config.get<UptimeConfig>();
|
||||
|
||||
savedObjectsAdapter.config = config;
|
||||
|
||||
this.logger = this.initContext.logger.get();
|
||||
const { ruleDataService } = plugins.ruleRegistry;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue