diff --git a/x-pack/legacy/plugins/canvas/public/components/router/index.js b/x-pack/legacy/plugins/canvas/public/components/router/index.js deleted file mode 100644 index 430d6a5343662..0000000000000 --- a/x-pack/legacy/plugins/canvas/public/components/router/index.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { connect } from 'react-redux'; -import { setFullscreen } from '../../state/actions/transient'; -import { - enableAutoplay, - setRefreshInterval, - setAutoplayInterval, -} from '../../state/actions/workpad'; -import { Router as Component } from './router'; - -const mapDispatchToState = { - enableAutoplay, - setAutoplayInterval, - setFullscreen, - setRefreshInterval, -}; - -export const Router = connect(null, mapDispatchToState)(Component); diff --git a/x-pack/legacy/plugins/canvas/public/components/router/index.ts b/x-pack/legacy/plugins/canvas/public/components/router/index.ts new file mode 100644 index 0000000000000..5e014870f5158 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/public/components/router/index.ts @@ -0,0 +1,63 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { connect } from 'react-redux'; +// @ts-ignore untyped local +import { setFullscreen } from '../../state/actions/transient'; +import { + enableAutoplay, + setRefreshInterval, + setAutoplayInterval, + // @ts-ignore untyped local +} from '../../state/actions/workpad'; +// @ts-ignore untyped local +import { Router as Component } from './router'; +import { State } from '../../../types'; + +const mapDispatchToProps = { + enableAutoplay, + setAutoplayInterval, + setFullscreen, + setRefreshInterval, +}; + +const mapStateToProps = (state: State) => ({ + refreshInterval: state.transient.refresh.interval, + autoplayInterval: state.transient.autoplay.interval, + autoplay: state.transient.autoplay.enabled, + fullscreen: state.transient.fullScreen, +}); + +export const Router = connect( + mapStateToProps, + mapDispatchToProps, + (stateProps, dispatchProps, ownProps) => { + return { + ...ownProps, + ...dispatchProps, + setRefreshInterval: (interval: number) => { + if (interval !== stateProps.refreshInterval) { + dispatchProps.setRefreshInterval(interval); + } + }, + setAutoplayInterval: (interval: number) => { + if (interval !== stateProps.autoplayInterval) { + dispatchProps.setRefreshInterval(interval); + } + }, + enableAutoplay: (autoplay: boolean) => { + if (autoplay !== stateProps.autoplay) { + dispatchProps.enableAutoplay(autoplay); + } + }, + setFullscreen: (fullscreen: boolean) => { + if (fullscreen !== stateProps.fullscreen) { + dispatchProps.setFullscreen(fullscreen); + } + }, + }; + } +)(Component); diff --git a/x-pack/legacy/plugins/canvas/public/legacy_start.ts b/x-pack/legacy/plugins/canvas/public/legacy_start.ts index 972427e166afc..21bf5aaa6d818 100644 --- a/x-pack/legacy/plugins/canvas/public/legacy_start.ts +++ b/x-pack/legacy/plugins/canvas/public/legacy_start.ts @@ -16,6 +16,12 @@ import 'uiExports/spyModes'; import 'uiExports/embeddableFactories'; import 'uiExports/interpreter'; +// TODO: These dependencies should be moved into plugin startup methods +// Load the interpreter so that the kbnInterpreter global will be available when plugins load +import 'plugins/interpreter/interpreter'; +// Load our app component to initialize registries +import './components/app'; + // load application code import 'uiExports/canvas'; diff --git a/x-pack/legacy/plugins/canvas/public/lib/app_state.ts b/x-pack/legacy/plugins/canvas/public/lib/app_state.ts index 955125b713140..c93e505c595fd 100644 --- a/x-pack/legacy/plugins/canvas/public/lib/app_state.ts +++ b/x-pack/legacy/plugins/canvas/public/lib/app_state.ts @@ -13,7 +13,7 @@ import { getWindow } from './get_window'; import { historyProvider } from './history_provider'; // @ts-ignore untyped local import { routerProvider } from './router_provider'; -import { createTimeInterval, isValidTimeInterval } from './time_interval'; +import { createTimeInterval, isValidTimeInterval, getTimeInterval } from './time_interval'; import { AppState, AppStateKeys } from '../../types'; export function getDefaultAppState(): AppState { @@ -112,7 +112,12 @@ export function setRefreshInterval(payload: string) { const appValue = appState[AppStateKeys.REFRESH_INTERVAL]; if (payload !== appValue) { - appState[AppStateKeys.REFRESH_INTERVAL] = payload; - routerProvider().updateAppState(appState); + if (getTimeInterval(payload)) { + appState[AppStateKeys.REFRESH_INTERVAL] = payload; + routerProvider().updateAppState(appState); + } else { + delete appState[AppStateKeys.REFRESH_INTERVAL]; + routerProvider().updateAppState(appState); + } } } diff --git a/x-pack/legacy/plugins/console_extensions/index.js b/x-pack/legacy/plugins/console_extensions/index.js deleted file mode 100644 index fd1b48f0fd6b1..0000000000000 --- a/x-pack/legacy/plugins/console_extensions/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { join } from 'path'; -import { processors } from './spec/ingest'; - -export function consoleExtensions(kibana) { - return new kibana.Plugin({ - id: 'console_extensions', - require: ['kibana', 'console'], - isEnabled(config) { - return ( - config.get('console_extensions.enabled') && - config.has('console.enabled') && - config.get('console.enabled') - ); - }, - - config(Joi) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - - init: server => { - if ( - server.plugins.console && - server.plugins.console.addExtensionSpecFilePath && - server.plugins.console.addProcessorDefinition - ) { - const { addExtensionSpecFilePath, addProcessorDefinition } = server.plugins.console; - - addExtensionSpecFilePath(join(__dirname, 'spec/')); - - processors.forEach(processor => addProcessorDefinition(processor)); - } else { - console.warn( - 'Missing server.plugins.console.addExtensionSpecFilePath extension point.', - 'Cannot add xpack APIs to autocomplete.' - ); - } - }, - }); -} diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.ts b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.ts index b8b67a0f36bd2..dcee956130a29 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.ts @@ -13,4 +13,4 @@ export const setup = (props: any) => wrapComponent: false, }, defaultProps: props, - }); + })(); diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx index 9e390e785c7d5..723c105d403b8 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/__jest__/client_integration/mappings_editor.test.tsx @@ -28,7 +28,7 @@ describe('', () => { }, }, }; - const testBed = await setup({ onUpdate: mockOnUpdate, defaultValue })(); + const testBed = await setup({ onUpdate: mockOnUpdate, defaultValue }); const { exists } = testBed; expect(exists('mappingsEditor')).toBe(true); @@ -44,7 +44,7 @@ describe('', () => { }, }, }; - const testBed = await setup({ onUpdate: mockOnUpdate, defaultValue })(); + const testBed = await setup({ onUpdate: mockOnUpdate, defaultValue }); const { exists } = testBed; expect(exists('mappingsEditor')).toBe(true); diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx new file mode 100644 index 0000000000000..a9433d3a7530f --- /dev/null +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React from 'react'; +import { act } from 'react-dom/test-utils'; + +jest.mock('@elastic/eui', () => ({ + ...jest.requireActual('@elastic/eui'), + // Mocking EuiCodeEditor, which uses React Ace under the hood + EuiCodeEditor: (props: any) => ( + { + props.onChange(syntheticEvent.jsonString); + }} + /> + ), +})); + +import { registerTestBed, nextTick, TestBed } from '../../../../../../../../../test_utils'; +import { LoadMappingsProvider } from './load_mappings_provider'; + +const ComponentToTest = ({ onJson }: { onJson: () => void }) => ( + + {openModal => ( + + )} + +); + +const setup = (props: any) => + registerTestBed(ComponentToTest, { + memoryRouter: { wrapComponent: false }, + defaultProps: props, + })(); + +const openModalWithJsonContent = ({ find, component }: TestBed) => async (json: any) => { + find('load-json-button').simulate('click'); + component.update(); + + // Set the mappings to load + // @ts-ignore + await act(async () => { + find('mockCodeEditor').simulate('change', { + jsonString: JSON.stringify(json), + }); + await nextTick(300); // There is a debounce in the JsonEditor that we need to wait for + }); +}; + +describe('', () => { + test('it should forward valid mapping definition', async () => { + const mappingsToLoad = { + properties: { + title: { + type: 'text', + }, + }, + }; + + const onJson = jest.fn(); + const testBed = await setup({ onJson }); + + // Open the modal and add the JSON + await openModalWithJsonContent(testBed)(mappingsToLoad); + + // Confirm + testBed.find('confirmModalConfirmButton').simulate('click'); + + const [jsonReturned] = onJson.mock.calls[0]; + expect(jsonReturned).toEqual({ ...mappingsToLoad, dynamic_templates: [] }); + }); +}); diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx index a55bd96dce3d0..6bc360a1ec70e 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/components/load_mappings/load_mappings_provider.tsx @@ -25,7 +25,7 @@ type OpenJsonModalFunc = () => void; interface Props { onJson(json: { [key: string]: any }): void; - children: (deleteProperty: OpenJsonModalFunc) => React.ReactNode; + children: (openModal: OpenJsonModalFunc) => React.ReactNode; } interface State { diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/extract_mappings_definition.ts b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/extract_mappings_definition.ts index eae3c5b15759c..817b0f4a4d3d0 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/extract_mappings_definition.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/extract_mappings_definition.ts @@ -6,15 +6,10 @@ import { isPlainObject } from 'lodash'; import { GenericObject } from '../types'; -import { - validateMappingsConfiguration, - mappingsConfigurationSchemaKeys, -} from './mappings_validator'; - -const ALLOWED_PARAMETERS = [...mappingsConfigurationSchemaKeys, 'dynamic_templates', 'properties']; +import { validateMappingsConfiguration, VALID_MAPPINGS_PARAMETERS } from './mappings_validator'; const isMappingDefinition = (obj: GenericObject): boolean => { - const areAllKeysValid = Object.keys(obj).every(key => ALLOWED_PARAMETERS.includes(key)); + const areAllKeysValid = Object.keys(obj).every(key => VALID_MAPPINGS_PARAMETERS.includes(key)); if (!areAllKeysValid) { return false; diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.test.ts b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.test.ts index f1e6efb06c649..d67c267dda6ae 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.test.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.test.ts @@ -18,6 +18,24 @@ describe('Mappings configuration validator', () => { }); }); + it('should detect valid mappings configuration', () => { + const mappings = { + _source: { + includes: [], + excludes: [], + enabled: true, + }, + _meta: {}, + _routing: { + required: false, + }, + dynamic: true, + }; + + const { errors } = validateMappings(mappings); + expect(errors).toBe(undefined); + }); + it('should strip out unknown configuration', () => { const mappings = { dynamic: true, @@ -30,6 +48,7 @@ describe('Mappings configuration validator', () => { excludes: ['abc'], }, properties: { title: { type: 'text' } }, + dynamic_templates: [], unknown: 123, }; @@ -37,7 +56,7 @@ describe('Mappings configuration validator', () => { const { unknown, ...expected } = mappings; expect(value).toEqual(expected); - expect(errors).toBe(undefined); + expect(errors).toEqual([{ code: 'ERR_CONFIG', configName: 'unknown' }]); }); it('should strip out invalid configuration and returns the errors for each of them', () => { @@ -47,9 +66,8 @@ describe('Mappings configuration validator', () => { dynamic_date_formats: false, // wrong format _source: { enabled: true, - includes: 'abc', + unknownProp: 'abc', // invalid excludes: ['abc'], - wrong: 123, // parameter not allowed }, properties: 'abc', }; @@ -59,10 +77,10 @@ describe('Mappings configuration validator', () => { expect(value).toEqual({ dynamic: true, properties: {}, + dynamic_templates: [], }); expect(errors).not.toBe(undefined); - expect(errors!.length).toBe(3); expect(errors!).toEqual([ { code: 'ERR_CONFIG', configName: '_source' }, { code: 'ERR_CONFIG', configName: 'dynamic_date_formats' }, diff --git a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.ts b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.ts index 6ccbfeb50dcf4..78d638e398593 100644 --- a/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.ts +++ b/x-pack/legacy/plugins/index_management/public/app/components/mappings_editor/lib/mappings_validator.ts @@ -196,23 +196,30 @@ export const validateProperties = (properties = {}): PropertiesValidatorResponse * Single source of truth to validate the *configuration* of the mappings. * Whenever a user loads a JSON object it will be validate against this Joi schema. */ -export const mappingsConfigurationSchema = t.partial({ - dynamic: t.union([t.literal(true), t.literal(false), t.literal('strict')]), - date_detection: t.boolean, - numeric_detection: t.boolean, - dynamic_date_formats: t.array(t.string), - _source: t.partial({ - enabled: t.boolean, - includes: t.array(t.string), - excludes: t.array(t.string), - }), - _meta: t.UnknownRecord, - _routing: t.partial({ - required: t.boolean, - }), -}); - -export const mappingsConfigurationSchemaKeys = Object.keys(mappingsConfigurationSchema.props); +export const mappingsConfigurationSchema = t.exact( + t.partial({ + dynamic: t.union([t.literal(true), t.literal(false), t.literal('strict')]), + date_detection: t.boolean, + numeric_detection: t.boolean, + dynamic_date_formats: t.array(t.string), + _source: t.exact( + t.partial({ + enabled: t.boolean, + includes: t.array(t.string), + excludes: t.array(t.string), + }) + ), + _meta: t.UnknownRecord, + _routing: t.interface({ + required: t.boolean, + }), + }) +); + +const mappingsConfigurationSchemaKeys = Object.keys(mappingsConfigurationSchema.type.props); +const sourceConfigurationSchemaKeys = Object.keys( + mappingsConfigurationSchema.type.props._source.type.props +); export const validateMappingsConfiguration = ( mappingsConfiguration: any @@ -222,8 +229,20 @@ export const validateMappingsConfiguration = ( let copyOfMappingsConfig = { ...mappingsConfiguration }; const result = mappingsConfigurationSchema.decode(mappingsConfiguration); + const isSchemaInvalid = isLeft(result); - if (isLeft(result)) { + const unknownConfigurationParameters = Object.keys(mappingsConfiguration).filter( + key => mappingsConfigurationSchemaKeys.includes(key) === false + ); + + const unknownSourceConfigurationParameters = + mappingsConfiguration._source !== undefined + ? Object.keys(mappingsConfiguration._source).filter( + key => sourceConfigurationSchemaKeys.includes(key) === false + ) + : []; + + if (isSchemaInvalid) { /** * To keep the logic simple we will strip out the parameters that contain errors */ @@ -235,6 +254,15 @@ export const validateMappingsConfiguration = ( }); } + if (unknownConfigurationParameters.length > 0) { + unknownConfigurationParameters.forEach(configName => configurationRemoved.add(configName)); + } + + if (unknownSourceConfigurationParameters.length > 0) { + configurationRemoved.add('_source'); + delete copyOfMappingsConfig._source; + } + copyOfMappingsConfig = pick(copyOfMappingsConfig, mappingsConfigurationSchemaKeys); const errors: MappingsValidationError[] = toArray(ordString)(configurationRemoved) @@ -252,7 +280,7 @@ export const validateMappings = (mappings: any = {}): MappingsValidatorResponse return { value: {} }; } - const { properties, dynamic_templates, ...mappingsConfiguration } = mappings; + const { properties, dynamic_templates: dynamicTemplates, ...mappingsConfiguration } = mappings; const { value: parsedConfiguration, errors: configurationErrors } = validateMappingsConfiguration( mappingsConfiguration @@ -265,8 +293,14 @@ export const validateMappings = (mappings: any = {}): MappingsValidatorResponse value: { ...parsedConfiguration, properties: parsedProperties, - dynamic_templates, + dynamic_templates: dynamicTemplates ?? [], }, errors: errors.length ? errors : undefined, }; }; + +export const VALID_MAPPINGS_PARAMETERS = [ + ...mappingsConfigurationSchemaKeys, + 'dynamic_templates', + 'properties', +]; diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 4409667d8390a..4b1aa774a523f 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -241,6 +241,7 @@ export class KibanaFramework { public async makeTSVBRequest( requestContext: RequestHandlerContext, + rawRequest: KibanaRequest, model: TSVBMetricModel, timerange: { min: number; max: number }, filters: any[] @@ -254,6 +255,6 @@ export class KibanaFramework { panels: [model], filters, }; - return getVisData(requestContext, options); + return getVisData(requestContext, rawRequest, options); } } diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts index eb5ac05644a22..5a5f9d0f8f529 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts @@ -51,7 +51,7 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter { } const requests = options.metrics.map(metricId => - this.makeTSVBRequest(metricId, options, nodeField, requestContext) + this.makeTSVBRequest(metricId, options, nodeField, requestContext, rawRequest) ); return Promise.all(requests) @@ -93,7 +93,8 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter { metricId: InventoryMetric, options: InfraMetricsRequestOptions, nodeField: string, - requestContext: RequestHandlerContext + requestContext: RequestHandlerContext, + rawRequest: KibanaRequest ) { const createTSVBModel = get(metrics, ['tsvb', metricId]) as TSVBMetricModelCreator | undefined; if (!createTSVBModel) { @@ -152,6 +153,6 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter { ? [{ match: { [model.map_field_to]: id } }] : [{ match: { [nodeField]: id } }]; - return this.framework.makeTSVBRequest(requestContext, model, timerange, filters); + return this.framework.makeTSVBRequest(requestContext, rawRequest, model, timerange, filters); } } diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts b/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts index 8ab3fdccbe72b..347feca67aa99 100644 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts +++ b/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts @@ -76,7 +76,13 @@ export const populateSeriesWithTSVBData = ( } // Get TSVB results using the model, timerange and filters - const tsvbResults = await framework.makeTSVBRequest(requestContext, model, timerange, filters); + const tsvbResults = await framework.makeTSVBRequest( + requestContext, + request, + model, + timerange, + filters + ); // If there is no data `custom` will not exist. if (!tsvbResults.custom) { diff --git a/x-pack/legacy/plugins/maps/public/components/single_field_select.js b/x-pack/legacy/plugins/maps/public/components/single_field_select.js index ba9ef1f22c54c..7351ce7691a82 100644 --- a/x-pack/legacy/plugins/maps/public/components/single_field_select.js +++ b/x-pack/legacy/plugins/maps/public/components/single_field_select.js @@ -8,63 +8,50 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; -import { EuiComboBox } from '@elastic/eui'; +import { EuiComboBox, EuiHighlight } from '@elastic/eui'; +import { FieldIcon } from '../../../../../../src/plugins/kibana_react/public'; -const sortByLabel = (a, b) => { - if (a.label < b.label) return -1; - if (a.label > b.label) return 1; - return 0; -}; - -// Creates grouped options by grouping fields by field type -export const getGroupedFieldOptions = (fields, filterField) => { +function fieldsToOptions(fields) { if (!fields) { - return; + return []; } - const fieldsByTypeMap = new Map(); - - fields.filter(filterField).forEach(field => { - const fieldLabel = 'label' in field ? field.label : field.name; - if (fieldsByTypeMap.has(field.type)) { - const fieldsList = fieldsByTypeMap.get(field.type); - fieldsList.push({ value: field.name, label: fieldLabel }); - fieldsByTypeMap.set(field.type, fieldsList); - } else { - fieldsByTypeMap.set(field.type, [{ value: field.name, label: fieldLabel }]); - } - }); - - const groupedFieldOptions = []; - fieldsByTypeMap.forEach((fieldsList, fieldType) => { - const sortedOptions = fieldsList.sort(sortByLabel).map(({ value, label }) => { - return { value: value, label: label }; + return fields + .map(field => { + return { + value: field, + label: 'label' in field ? field.label : field.name, + }; + }) + .sort((a, b) => { + return a.label.toLowerCase().localeCompare(b.label.toLowerCase()); }); +} - groupedFieldOptions.push({ - label: fieldType, - options: sortedOptions, - }); - }); - - groupedFieldOptions.sort(sortByLabel); - - return groupedFieldOptions; -}; +function renderOption(option, searchValue, contentClassName) { + return ( + + +   + {option.label} + + ); +} -export function SingleFieldSelect({ fields, filterField, onChange, value, placeholder, ...rest }) { +export function SingleFieldSelect({ fields, onChange, value, placeholder, ...rest }) { const onSelection = selectedOptions => { - onChange(_.get(selectedOptions, '0.value')); + onChange(_.get(selectedOptions, '0.value.name')); }; return ( ); @@ -75,11 +62,4 @@ SingleFieldSelect.propTypes = { fields: PropTypes.array, onChange: PropTypes.func.isRequired, value: PropTypes.string, // fieldName - filterField: PropTypes.func, -}; - -SingleFieldSelect.defaultProps = { - filterField: () => { - return true; - }, }; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js index 76827e71df9ec..777c8ae0923fe 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js @@ -23,7 +23,6 @@ import { getTermsFields } from '../../../../index_pattern_util'; import { indexPatternService } from '../../../../kibana_services'; import { npStart } from 'ui/new_platform'; -import { isNestedField } from '../../../../../../../../../src/plugins/data/public'; const { IndexPatternSelect } = npStart.plugins.data.ui; export class JoinExpression extends Component { @@ -134,10 +133,6 @@ export class JoinExpression extends Component { return null; } - const filterStringOrNumberFields = field => { - return (field.type === 'string' && !isNestedField(field)) || field.type === 'number'; - }; - return ( diff --git a/x-pack/legacy/plugins/maps/public/index_pattern_util.js b/x-pack/legacy/plugins/maps/public/index_pattern_util.js index 10837bc2f0d0c..96d4a4b19fbfa 100644 --- a/x-pack/legacy/plugins/maps/public/index_pattern_util.js +++ b/x-pack/legacy/plugins/maps/public/index_pattern_util.js @@ -6,6 +6,7 @@ import { indexPatternService } from './kibana_services'; import { isNestedField } from '../../../../../src/plugins/data/public'; +import { ES_GEO_FIELD_TYPE } from '../common/constants'; export async function getIndexPatternsFromIds(indexPatternIds = []) { const promises = []; @@ -29,6 +30,18 @@ export function getTermsFields(fields) { }); } +export const AGGREGATABLE_GEO_FIELD_TYPES = [ES_GEO_FIELD_TYPE.GEO_POINT]; + +export function getAggregatableGeoFields(fields) { + return fields.filter(field => { + return ( + field.aggregatable && + !isNestedField(field) && + AGGREGATABLE_GEO_FIELD_TYPES.includes(field.type) + ); + }); +} + // Returns filtered fields list containing only fields that exist in _source. export function getSourceFields(fields) { return fields.filter(field => { diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/create_source_editor.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/create_source_editor.js index c32b857b49171..bd074386edb3f 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/create_source_editor.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/create_source_editor.js @@ -15,16 +15,14 @@ import { NoIndexPatternCallout } from '../../../components/no_index_pattern_call import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiComboBox, EuiSpacer } from '@elastic/eui'; -import { ES_GEO_FIELD_TYPE } from '../../../../common/constants'; -import { isNestedField } from '../../../../../../../../src/plugins/data/public'; +import { + AGGREGATABLE_GEO_FIELD_TYPES, + getAggregatableGeoFields, +} from '../../../index_pattern_util'; import { npStart } from 'ui/new_platform'; const { IndexPatternSelect } = npStart.plugins.data.ui; -function filterGeoField({ type }) { - return [ES_GEO_FIELD_TYPE.GEO_POINT].includes(type); -} - const requestTypeOptions = [ { label: i18n.translate('xpack.maps.source.esGeoGrid.gridRectangleDropdownOption', { @@ -116,9 +114,7 @@ export class CreateSourceEditor extends Component { }); //make default selection - const geoFields = indexPattern.fields - .filter(field => !isNestedField(field)) - .filter(filterGeoField); + const geoFields = getAggregatableGeoFields(indexPattern.fields); if (geoFields[0]) { this._onGeoFieldSelect(geoFields[0].name); } @@ -173,10 +169,9 @@ export class CreateSourceEditor extends Component { })} value={this.state.geoField} onChange={this._onGeoFieldSelect} - filterField={filterGeoField} fields={ this.state.indexPattern - ? this.state.indexPattern.fields.filter(field => !isNestedField(field)) + ? getAggregatableGeoFields(this.state.indexPattern.fields) : undefined } /> @@ -223,7 +218,7 @@ export class CreateSourceEditor extends Component { placeholder={i18n.translate('xpack.maps.source.esGeoGrid.indexPatternPlaceholder', { defaultMessage: 'Select index pattern', })} - fieldTypes={[ES_GEO_FIELD_TYPE.GEO_POINT]} + fieldTypes={AGGREGATABLE_GEO_FIELD_TYPES} onNoIndexPatterns={this._onNoIndexPatterns} /> diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/create_source_editor.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/create_source_editor.js index 85d63c9da8a31..5e4727cd7ab0c 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/create_source_editor.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/create_source_editor.js @@ -14,16 +14,13 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFormRow, EuiCallOut } from '@elastic/eui'; -import { ES_GEO_FIELD_TYPE } from '../../../../common/constants'; -import { isNestedField } from '../../../../../../../../src/plugins/data/public'; +import { + AGGREGATABLE_GEO_FIELD_TYPES, + getAggregatableGeoFields, +} from '../../../index_pattern_util'; import { npStart } from 'ui/new_platform'; const { IndexPatternSelect } = npStart.plugins.data.ui; -const GEO_FIELD_TYPES = [ES_GEO_FIELD_TYPE.GEO_POINT]; - -function filterGeoField({ type }) { - return GEO_FIELD_TYPES.includes(type); -} export class CreateSourceEditor extends Component { static propTypes = { @@ -92,10 +89,7 @@ export class CreateSourceEditor extends Component { return; } - const geoFields = indexPattern.fields - .filter(field => !isNestedField(field)) - .filter(filterGeoField); - + const geoFields = getAggregatableGeoFields(indexPattern.fields); this.setState({ isLoadingIndexPattern: false, indexPattern: indexPattern, @@ -136,6 +130,9 @@ export class CreateSourceEditor extends Component { return null; } + const fields = this.state.indexPattern + ? getAggregatableGeoFields(this.state.indexPattern.fields) + : undefined; return ( @@ -165,12 +161,7 @@ export class CreateSourceEditor extends Component { })} value={this.state.destGeoField} onChange={this._onDestGeoSelect} - filterField={filterGeoField} - fields={ - this.state.indexPattern - ? this.state.indexPattern.fields.filter(field => !isNestedField(field)) - : undefined - } + fields={fields} /> @@ -190,7 +181,7 @@ export class CreateSourceEditor extends Component { placeholder={i18n.translate('xpack.maps.source.pewPew.indexPatternPlaceholder', { defaultMessage: 'Select index pattern', })} - fieldTypes={GEO_FIELD_TYPES} + fieldTypes={AGGREGATABLE_GEO_FIELD_TYPES} /> ); diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/__snapshots__/update_source_editor.test.js.snap b/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/__snapshots__/update_source_editor.test.js.snap index 9afe22a5f4550..80368fd5d5e3e 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/__snapshots__/update_source_editor.test.js.snap +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/__snapshots__/update_source_editor.test.js.snap @@ -53,7 +53,6 @@ exports[`should enable sort order select when sort field provided 1`] = ` @@ -230,7 +228,6 @@ exports[`should render top hits form when useTopHits is true 1`] = ` diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/create_source_editor.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/create_source_editor.js index 69e4c09eed118..ad55a279f9cd7 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/create_source_editor.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/create_source_editor.js @@ -26,8 +26,13 @@ import { isNestedField } from '../../../../../../../../src/plugins/data/public'; import { npStart } from 'ui/new_platform'; const { IndexPatternSelect } = npStart.plugins.data.ui; -function filterGeoField(field) { - return [ES_GEO_FIELD_TYPE.GEO_POINT, ES_GEO_FIELD_TYPE.GEO_SHAPE].includes(field.type); +function getGeoFields(fields) { + return fields.filter(field => { + return ( + !isNestedField(field) && + [ES_GEO_FIELD_TYPE.GEO_POINT, ES_GEO_FIELD_TYPE.GEO_SHAPE].includes(field.type) + ); + }); } const RESET_INDEX_PATTERN_STATE = { indexPattern: undefined, @@ -125,9 +130,7 @@ export class CreateSourceEditor extends Component { }); //make default selection - const geoFields = indexPattern.fields - .filter(field => !isNestedField(field)) - .filter(filterGeoField); + const geoFields = getGeoFields(indexPattern.fields); if (geoFields[0]) { this.onGeoFieldSelect(geoFields[0].name); } @@ -180,11 +183,8 @@ export class CreateSourceEditor extends Component { })} value={this.state.geoField} onChange={this.onGeoFieldSelect} - filterField={filterGeoField} fields={ - this.state.indexPattern - ? this.state.indexPattern.fields.filter(field => !isNestedField(field)) - : undefined + this.state.indexPattern ? getGeoFields(this.state.indexPattern.fields) : undefined } /> diff --git a/x-pack/legacy/plugins/ml/public/application/util/url_state.test.ts b/x-pack/legacy/plugins/ml/public/application/util/url_state.test.ts index 91bbef2dba6c2..0813f2e3da97f 100644 --- a/x-pack/legacy/plugins/ml/public/application/util/url_state.test.ts +++ b/x-pack/legacy/plugins/ml/public/application/util/url_state.test.ts @@ -75,7 +75,7 @@ describe('useUrlState', () => { expect(mockHistoryPush).toHaveBeenCalledWith({ search: - '_a=%28mlExplorerFilter%3A%28%29%2CmlExplorerSwimlane%3A%28viewByFieldName%3Aaction%29%2Cquery%3A%28%29%29&_g=%28ml%3A%28jobIds%3A%21%28dec-2%29%29%2CrefreshInterval%3A%28display%3AOff%2Cpause%3A%21f%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272019-01-01T00%3A03%3A40.000Z%27%2Cmode%3Aabsolute%2Cto%3A%272019-08-30T11%3A55%3A07.000Z%27%29%29&savedSearchId=%27571aaf70-4c88-11e8-b3d7-01146121b73d%27', + '_a=%28mlExplorerFilter%3A%28%29%2CmlExplorerSwimlane%3A%28viewByFieldName%3Aaction%29%2Cquery%3A%28%29%29&_g=%28ml%3A%28jobIds%3A%21%28dec-2%29%29%2CrefreshInterval%3A%28display%3AOff%2Cpause%3A%21f%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272019-01-01T00%3A03%3A40.000Z%27%2Cmode%3Aabsolute%2Cto%3A%272019-08-30T11%3A55%3A07.000Z%27%29%29&savedSearchId=571aaf70-4c88-11e8-b3d7-01146121b73d', }); }); }); diff --git a/x-pack/legacy/plugins/ml/public/application/util/url_state.ts b/x-pack/legacy/plugins/ml/public/application/util/url_state.ts index 546944b1a33bf..e7d5a94e2694f 100644 --- a/x-pack/legacy/plugins/ml/public/application/util/url_state.ts +++ b/x-pack/legacy/plugins/ml/public/application/util/url_state.ts @@ -18,14 +18,26 @@ import { getNestedProperty } from './object_utils'; export type SetUrlState = (attribute: string | Dictionary, value?: any) => void; export type UrlState = [Dictionary, SetUrlState]; -const decodedParams = new Set(['_a', '_g']); +/** + * Set of URL query parameters that require the rison serialization. + */ +const risonSerializedParams = new Set(['_a', '_g']); + +/** + * Checks if the URL query parameter requires rison serialization. + * @param queryParam + */ +function isRisonSerializationRequired(queryParam: string): boolean { + return risonSerializedParams.has(queryParam); +} + export function getUrlState(search: string): Dictionary { const urlState: Dictionary = {}; const parsedQueryString = queryString.parse(search); try { Object.keys(parsedQueryString).forEach(a => { - if (decodedParams.has(a)) { + if (isRisonSerializationRequired(a)) { urlState[a] = decode(parsedQueryString[a]) as Dictionary; } else { urlState[a] = parsedQueryString[a]; @@ -75,7 +87,11 @@ export const useUrlState = (accessor: string): UrlState => { const oldLocationSearch = queryString.stringify(parsedQueryString, { encode: false }); Object.keys(urlState).forEach(a => { - parsedQueryString[a] = encode(urlState[a]); + if (isRisonSerializationRequired(a)) { + parsedQueryString[a] = encode(urlState[a]); + } else { + parsedQueryString[a] = urlState[a]; + } }); const newLocationSearch = queryString.stringify(parsedQueryString, { encode: false }); diff --git a/x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.js b/x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.ts similarity index 53% rename from x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.js rename to x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.ts index e74a81e92420f..2487943b5efc0 100644 --- a/x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.js +++ b/x-pack/legacy/plugins/ml/server/models/calendar/calendar_manager.ts @@ -4,23 +4,44 @@ * you may not use this file except in compliance with the Elastic License. */ -import _ from 'lodash'; +import { difference } from 'lodash'; import Boom from 'boom'; -import { EventManager } from './event_manager'; +import { EventManager, CalendarEvent } from './event_manager'; + +interface BasicCalendar { + job_ids: string[]; + description?: string; + events: CalendarEvent[]; +} + +export interface Calendar extends BasicCalendar { + calendar_id: string; +} + +export interface FormCalendar extends BasicCalendar { + calendarId: string; +} export class CalendarManager { - constructor(callWithRequest) { - this.callWithRequest = callWithRequest; - this.eventManager = new EventManager(callWithRequest); + private _client: any; + private _eventManager: any; + + constructor(isLegacy: boolean, client: any) { + const actualClient = isLegacy === true ? client : client.ml!.mlClient.callAsCurrentUser; + this._client = actualClient; + this._eventManager = new EventManager(actualClient); } - async getCalendar(calendarId) { + async getCalendar(calendarId: string) { try { - const resp = await this.callWithRequest('ml.calendars', { calendarId }); + const resp = await this._client('ml.calendars', { + calendarId, + }); + const calendars = resp.calendars; if (calendars.length) { const calendar = calendars[0]; - calendar.events = await this.eventManager.getCalendarEvents(calendarId); + calendar.events = await this._eventManager.getCalendarEvents(calendarId); return calendar; } else { throw Boom.notFound(`Calendar with the id "${calendarId}" not found`); @@ -32,9 +53,10 @@ export class CalendarManager { async getAllCalendars() { try { - const calendarsResp = await this.callWithRequest('ml.calendars'); - const events = await this.eventManager.getAllEvents(); - const calendars = calendarsResp.calendars; + const calendarsResp = await this._client('ml.calendars'); + + const events: CalendarEvent[] = await this._eventManager.getAllEvents(); + const calendars: Calendar[] = calendarsResp.calendars; calendars.forEach(cal => (cal.events = [])); // loop events and combine with related calendars @@ -55,24 +77,28 @@ export class CalendarManager { * @param calendarIds * @returns {Promise<*>} */ - async getCalendarsByIds(calendarIds) { + async getCalendarsByIds(calendarIds: string) { try { - const calendars = await this.getAllCalendars(); + const calendars: Calendar[] = await this.getAllCalendars(); return calendars.filter(calendar => calendarIds.includes(calendar.calendar_id)); } catch (error) { throw Boom.badRequest(error); } } - async newCalendar(calendar) { + async newCalendar(calendar: FormCalendar) { const calendarId = calendar.calendarId; const events = calendar.events; delete calendar.calendarId; delete calendar.events; try { - await this.callWithRequest('ml.addCalendar', { calendarId, body: calendar }); + await this._client('ml.addCalendar', { + calendarId, + body: calendar, + }); + if (events.length) { - await this.eventManager.addEvents(calendarId, events); + await this._eventManager.addEvents(calendarId, events); } // return the newly created calendar @@ -82,38 +108,38 @@ export class CalendarManager { } } - async updateCalendar(calendarId, calendar) { - const origCalendar = await this.getCalendar(calendarId); + async updateCalendar(calendarId: string, calendar: Calendar) { + const origCalendar: Calendar = await this.getCalendar(calendarId); try { // update job_ids - const jobsToAdd = _.difference(calendar.job_ids, origCalendar.job_ids); - const jobsToRemove = _.difference(origCalendar.job_ids, calendar.job_ids); + const jobsToAdd = difference(calendar.job_ids, origCalendar.job_ids); + const jobsToRemove = difference(origCalendar.job_ids, calendar.job_ids); // workout the differences between the original events list and the new one // if an event has no event_id, it must be new const eventsToAdd = calendar.events.filter( - event => origCalendar.events.find(e => this.eventManager.isEqual(e, event)) === undefined + event => origCalendar.events.find(e => this._eventManager.isEqual(e, event)) === undefined ); // if an event in the original calendar cannot be found, it must have been deleted - const eventsToRemove = origCalendar.events.filter( - event => calendar.events.find(e => this.eventManager.isEqual(e, event)) === undefined + const eventsToRemove: CalendarEvent[] = origCalendar.events.filter( + event => calendar.events.find(e => this._eventManager.isEqual(e, event)) === undefined ); // note, both of the loops below could be removed if the add and delete endpoints // allowed multiple job_ids - //add all new jobs + // add all new jobs if (jobsToAdd.length) { - await this.callWithRequest('ml.addJobToCalendar', { + await this._client('ml.addJobToCalendar', { calendarId, jobId: jobsToAdd.join(','), }); } - //remove all removed jobs + // remove all removed jobs if (jobsToRemove.length) { - await this.callWithRequest('ml.removeJobFromCalendar', { + await this._client('ml.removeJobFromCalendar', { calendarId, jobId: jobsToRemove.join(','), }); @@ -121,13 +147,13 @@ export class CalendarManager { // add all new events if (eventsToAdd.length !== 0) { - await this.eventManager.addEvents(calendarId, eventsToAdd); + await this._eventManager.addEvents(calendarId, eventsToAdd); } // remove all removed events await Promise.all( eventsToRemove.map(async event => { - await this.eventManager.deleteEvent(calendarId, event.event_id); + await this._eventManager.deleteEvent(calendarId, event.event_id); }) ); } catch (error) { @@ -138,7 +164,7 @@ export class CalendarManager { return await this.getCalendar(calendarId); } - async deleteCalendar(calendarId) { - return this.callWithRequest('ml.deleteCalendar', { calendarId }); + async deleteCalendar(calendarId: string) { + return this._client('ml.deleteCalendar', { calendarId }); } } diff --git a/x-pack/legacy/plugins/ml/server/models/calendar/event_manager.js b/x-pack/legacy/plugins/ml/server/models/calendar/event_manager.ts similarity index 51% rename from x-pack/legacy/plugins/ml/server/models/calendar/event_manager.js rename to x-pack/legacy/plugins/ml/server/models/calendar/event_manager.ts index 8bdb5dcf4a3e3..19f2eda466179 100644 --- a/x-pack/legacy/plugins/ml/server/models/calendar/event_manager.js +++ b/x-pack/legacy/plugins/ml/server/models/calendar/event_manager.ts @@ -6,14 +6,24 @@ import Boom from 'boom'; +export interface CalendarEvent { + calendar_id?: string; + event_id?: string; + description: string; + start_time: number; + end_time: number; +} + export class EventManager { - constructor(callWithRequest) { - this.callWithRequest = callWithRequest; + private _client: any; + constructor(client: any) { + this._client = client; } - async getCalendarEvents(calendarId) { + async getCalendarEvents(calendarId: string) { try { - const resp = await this.callWithRequest('ml.events', { calendarId }); + const resp = await this._client('ml.events', { calendarId }); + return resp.events; } catch (error) { throw Boom.badRequest(error); @@ -21,31 +31,38 @@ export class EventManager { } // jobId is optional - async getAllEvents(jobId) { + async getAllEvents(jobId?: string) { const calendarId = '_all'; try { - const resp = await this.callWithRequest('ml.events', { calendarId, jobId }); + const resp = await this._client('ml.events', { + calendarId, + jobId, + }); + return resp.events; } catch (error) { throw Boom.badRequest(error); } } - async addEvents(calendarId, events) { + async addEvents(calendarId: string, events: CalendarEvent[]) { const body = { events }; try { - return await this.callWithRequest('ml.addEvent', { calendarId, body }); + return await this._client('ml.addEvent', { + calendarId, + body, + }); } catch (error) { throw Boom.badRequest(error); } } - async deleteEvent(calendarId, eventId) { - return this.callWithRequest('ml.deleteEvent', { calendarId, eventId }); + async deleteEvent(calendarId: string, eventId: string) { + return this._client('ml.deleteEvent', { calendarId, eventId }); } - isEqual(ev1, ev2) { + isEqual(ev1: CalendarEvent, ev2: CalendarEvent) { return ( ev1.event_id === ev2.event_id && ev1.description === ev2.description && diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/index.ts b/x-pack/legacy/plugins/ml/server/models/calendar/index.ts similarity index 67% rename from x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/index.ts rename to x-pack/legacy/plugins/ml/server/models/calendar/index.ts index bd86daba1bcb6..2364c3ac73811 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/index.ts +++ b/x-pack/legacy/plugins/ml/server/models/calendar/index.ts @@ -4,5 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { savedObjectsAdapter } from './kibana_saved_objects_adapter'; -export { UMSavedObjectsAdapter } from './types'; +export { CalendarManager, Calendar, FormCalendar } from './calendar_manager'; diff --git a/x-pack/legacy/plugins/ml/server/models/job_service/groups.js b/x-pack/legacy/plugins/ml/server/models/job_service/groups.js index 91f82f04a9a0c..58237b2a8a730 100644 --- a/x-pack/legacy/plugins/ml/server/models/job_service/groups.js +++ b/x-pack/legacy/plugins/ml/server/models/job_service/groups.js @@ -7,7 +7,7 @@ import { CalendarManager } from '../calendar'; export function groupsProvider(callWithRequest) { - const calMngr = new CalendarManager(callWithRequest); + const calMngr = new CalendarManager(true, callWithRequest); async function getAllGroups() { const groups = {}; diff --git a/x-pack/legacy/plugins/ml/server/models/job_service/jobs.js b/x-pack/legacy/plugins/ml/server/models/job_service/jobs.js index b4b476c1f926e..e60593c9f0ed5 100644 --- a/x-pack/legacy/plugins/ml/server/models/job_service/jobs.js +++ b/x-pack/legacy/plugins/ml/server/models/job_service/jobs.js @@ -22,7 +22,7 @@ export function jobsProvider(callWithRequest) { const { forceDeleteDatafeed, getDatafeedIdsByJobId } = datafeedsProvider(callWithRequest); const { getAuditMessagesSummary } = jobAuditMessagesProvider(callWithRequest); const { getLatestBucketTimestampByJob } = resultsServiceProvider(callWithRequest); - const calMngr = new CalendarManager(callWithRequest); + const calMngr = new CalendarManager(true, callWithRequest); async function forceDeleteJob(jobId) { return callWithRequest('ml.deleteJob', { jobId, force: true }); diff --git a/x-pack/legacy/plugins/ml/server/new_platform/calendars_schema.ts b/x-pack/legacy/plugins/ml/server/new_platform/calendars_schema.ts new file mode 100644 index 0000000000000..f5e59d983a9aa --- /dev/null +++ b/x-pack/legacy/plugins/ml/server/new_platform/calendars_schema.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { schema } from '@kbn/config-schema'; + +export const calendarSchema = { + calendar_id: schema.maybe(schema.string()), + calendarId: schema.string(), + job_ids: schema.arrayOf(schema.maybe(schema.string())), + description: schema.maybe(schema.string()), + events: schema.arrayOf( + schema.maybe( + schema.object({ + event_id: schema.maybe(schema.string()), + calendar_id: schema.maybe(schema.string()), + description: schema.maybe(schema.string()), + start_time: schema.any(), + end_time: schema.any(), + }) + ) + ), +}; diff --git a/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts b/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts index 681b2ff20c8aa..2b9219b2226f5 100644 --- a/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts +++ b/x-pack/legacy/plugins/ml/server/new_platform/plugin.ts @@ -41,13 +41,11 @@ import { makeMlUsageCollector } from '../lib/ml_telemetry'; import { notificationRoutes } from '../routes/notification_settings'; // @ts-ignore: could not find declaration file for module import { systemRoutes } from '../routes/system'; -// @ts-ignore: could not find declaration file for module import { dataFrameAnalyticsRoutes } from '../routes/data_frame_analytics'; // @ts-ignore: could not find declaration file for module import { dataRecognizer } from '../routes/modules'; // @ts-ignore: could not find declaration file for module import { dataVisualizerRoutes } from '../routes/data_visualizer'; -// @ts-ignore: could not find declaration file for module import { calendars } from '../routes/calendars'; // @ts-ignore: could not find declaration file for module import { fieldsService } from '../routes/fields_service'; diff --git a/x-pack/legacy/plugins/ml/server/routes/calendars.js b/x-pack/legacy/plugins/ml/server/routes/calendars.js deleted file mode 100644 index 7a0f341ef9666..0000000000000 --- a/x-pack/legacy/plugins/ml/server/routes/calendars.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { callWithRequestFactory } from '../client/call_with_request_factory'; -import { wrapError } from '../client/errors'; -import { CalendarManager } from '../models/calendar'; - -function getAllCalendars(callWithRequest) { - const cal = new CalendarManager(callWithRequest); - return cal.getAllCalendars(); -} - -function getCalendar(callWithRequest, calendarId) { - const cal = new CalendarManager(callWithRequest); - return cal.getCalendar(calendarId); -} - -function newCalendar(callWithRequest, calendar) { - const cal = new CalendarManager(callWithRequest); - return cal.newCalendar(calendar); -} - -function updateCalendar(callWithRequest, calendarId, calendar) { - const cal = new CalendarManager(callWithRequest); - return cal.updateCalendar(calendarId, calendar); -} - -function deleteCalendar(callWithRequest, calendarId) { - const cal = new CalendarManager(callWithRequest); - return cal.deleteCalendar(calendarId); -} - -function getCalendarsByIds(callWithRequest, calendarIds) { - const cal = new CalendarManager(callWithRequest); - return cal.getCalendarsByIds(calendarIds); -} - -export function calendars({ commonRouteConfig, elasticsearchPlugin, route }) { - route({ - method: 'GET', - path: '/api/ml/calendars', - handler(request) { - const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); - return getAllCalendars(callWithRequest).catch(resp => wrapError(resp)); - }, - config: { - ...commonRouteConfig, - }, - }); - - route({ - method: 'GET', - path: '/api/ml/calendars/{calendarIds}', - handler(request) { - const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); - const calendarIds = request.params.calendarIds.split(','); - if (calendarIds.length === 1) { - return getCalendar(callWithRequest, calendarIds[0]).catch(resp => wrapError(resp)); - } else { - return getCalendarsByIds(callWithRequest, calendarIds).catch(resp => wrapError(resp)); - } - }, - config: { - ...commonRouteConfig, - }, - }); - - route({ - method: 'PUT', - path: '/api/ml/calendars', - handler(request) { - const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); - const body = request.payload; - return newCalendar(callWithRequest, body).catch(resp => wrapError(resp)); - }, - config: { - ...commonRouteConfig, - }, - }); - - route({ - method: 'PUT', - path: '/api/ml/calendars/{calendarId}', - handler(request) { - const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); - const calendarId = request.params.calendarId; - const body = request.payload; - return updateCalendar(callWithRequest, calendarId, body).catch(resp => wrapError(resp)); - }, - config: { - ...commonRouteConfig, - }, - }); - - route({ - method: 'DELETE', - path: '/api/ml/calendars/{calendarId}', - handler(request) { - const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request); - const calendarId = request.params.calendarId; - return deleteCalendar(callWithRequest, calendarId).catch(resp => wrapError(resp)); - }, - config: { - ...commonRouteConfig, - }, - }); -} diff --git a/x-pack/legacy/plugins/ml/server/routes/calendars.ts b/x-pack/legacy/plugins/ml/server/routes/calendars.ts new file mode 100644 index 0000000000000..19d614a4e6a22 --- /dev/null +++ b/x-pack/legacy/plugins/ml/server/routes/calendars.ts @@ -0,0 +1,155 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { RequestHandlerContext } from 'src/core/server'; +import { schema } from '@kbn/config-schema'; +import { licensePreRoutingFactory } from '../new_platform/licence_check_pre_routing_factory'; +import { wrapError } from '../client/error_wrapper'; +import { RouteInitialization } from '../new_platform/plugin'; +import { calendarSchema } from '../new_platform/calendars_schema'; +import { CalendarManager, Calendar, FormCalendar } from '../models/calendar'; + +function getAllCalendars(context: RequestHandlerContext) { + const cal = new CalendarManager(false, context); + return cal.getAllCalendars(); +} + +function getCalendar(context: RequestHandlerContext, calendarId: string) { + const cal = new CalendarManager(false, context); + return cal.getCalendar(calendarId); +} + +function newCalendar(context: RequestHandlerContext, calendar: FormCalendar) { + const cal = new CalendarManager(false, context); + return cal.newCalendar(calendar); +} + +function updateCalendar(context: RequestHandlerContext, calendarId: string, calendar: Calendar) { + const cal = new CalendarManager(false, context); + return cal.updateCalendar(calendarId, calendar); +} + +function deleteCalendar(context: RequestHandlerContext, calendarId: string) { + const cal = new CalendarManager(false, context); + return cal.deleteCalendar(calendarId); +} + +function getCalendarsByIds(context: RequestHandlerContext, calendarIds: string) { + const cal = new CalendarManager(false, context); + return cal.getCalendarsByIds(calendarIds); +} + +export function calendars({ xpackMainPlugin, router }: RouteInitialization) { + router.get( + { + path: '/api/ml/calendars', + validate: false, + }, + licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => { + try { + const resp = await getAllCalendars(context); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); + + router.get( + { + path: '/api/ml/calendars/{calendarIds}', + validate: { + params: schema.object({ calendarIds: schema.string() }), + }, + }, + licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => { + let returnValue; + try { + const calendarIds = request.params.calendarIds.split(','); + + if (calendarIds.length === 1) { + returnValue = await getCalendar(context, calendarIds[0]); + } else { + returnValue = await getCalendarsByIds(context, calendarIds); + } + + return response.ok({ + body: returnValue, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); + + router.put( + { + path: '/api/ml/calendars', + validate: { + body: schema.object({ ...calendarSchema }), + }, + }, + licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => { + try { + const body = request.body; + const resp = await newCalendar(context, body); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); + + router.put( + { + path: '/api/ml/calendars/{calendarId}', + validate: { + params: schema.object({ calendarId: schema.string() }), + body: schema.object({ ...calendarSchema }), + }, + }, + licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => { + try { + const { calendarId } = request.params; + const body = request.body; + const resp = await updateCalendar(context, calendarId, body); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); + + router.delete( + { + path: '/api/ml/calendars/{calendarId}', + validate: { + params: schema.object({ calendarId: schema.string() }), + }, + }, + licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => { + try { + const { calendarId } = request.params; + const resp = await deleteCalendar(context, calendarId); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); +} diff --git a/x-pack/legacy/plugins/monitoring/config.js b/x-pack/legacy/plugins/monitoring/config.js index 91c1ee99a0b2e..778b656c056f2 100644 --- a/x-pack/legacy/plugins/monitoring/config.js +++ b/x-pack/legacy/plugins/monitoring/config.js @@ -15,12 +15,12 @@ export const config = Joi => { const DEFAULT_REQUEST_HEADERS = ['authorization']; return Joi.object({ - ccs: Joi.object({ - enabled: Joi.boolean().default(true), - }).default(), enabled: Joi.boolean().default(true), ui: Joi.object({ enabled: Joi.boolean().default(true), + ccs: Joi.object({ + enabled: Joi.boolean().default(true), + }).default(), container: Joi.object({ elasticsearch: Joi.object({ enabled: Joi.boolean().default(false), @@ -29,6 +29,51 @@ export const config = Joi => { enabled: Joi.boolean().default(false), }).default(), }).default(), + max_bucket_size: Joi.number().default(10000), + min_interval_seconds: Joi.number().default(10), + show_license_expiration: Joi.boolean().default(true), + elasticsearch: Joi.object({ + customHeaders: Joi.object().default({}), + logQueries: Joi.boolean().default(false), + requestHeadersWhitelist: Joi.array() + .items() + .single() + .default(DEFAULT_REQUEST_HEADERS), + sniffOnStart: Joi.boolean().default(false), + sniffInterval: Joi.number() + .allow(false) + .default(false), + sniffOnConnectionFault: Joi.boolean().default(false), + hosts: Joi.array() + .items(Joi.string().uri({ scheme: ['http', 'https'] })) + .single(), // if empty, use Kibana's connection config + username: Joi.string(), + password: Joi.string(), + requestTimeout: Joi.number().default(30000), + pingTimeout: Joi.number().default(30000), + ssl: Joi.object({ + verificationMode: Joi.string() + .valid('none', 'certificate', 'full') + .default('full'), + certificateAuthorities: Joi.array() + .single() + .items(Joi.string()), + certificate: Joi.string(), + key: Joi.string(), + keyPassphrase: Joi.string(), + keystore: Joi.object({ + path: Joi.string(), + password: Joi.string(), + }).default(), + truststore: Joi.object({ + path: Joi.string(), + password: Joi.string(), + }).default(), + alwaysPresentCertificate: Joi.boolean().default(false), + }).default(), + apiVersion: Joi.string().default('master'), + logFetchCount: Joi.number().default(10), + }).default(), }).default(), kibana: Joi.object({ collection: Joi.object({ @@ -46,56 +91,11 @@ export const config = Joi => { xpack_api_polling_frequency_millis: Joi.number().default( XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS ), - max_bucket_size: Joi.number().default(10000), - min_interval_seconds: Joi.number().default(10), - show_license_expiration: Joi.boolean().default(true), agent: Joi.object({ interval: Joi.string() .regex(/[\d\.]+[yMwdhms]/) .default('10s'), }).default(), - elasticsearch: Joi.object({ - customHeaders: Joi.object().default({}), - logQueries: Joi.boolean().default(false), - requestHeadersWhitelist: Joi.array() - .items() - .single() - .default(DEFAULT_REQUEST_HEADERS), - sniffOnStart: Joi.boolean().default(false), - sniffInterval: Joi.number() - .allow(false) - .default(false), - sniffOnConnectionFault: Joi.boolean().default(false), - hosts: Joi.array() - .items(Joi.string().uri({ scheme: ['http', 'https'] })) - .single(), // if empty, use Kibana's connection config - username: Joi.string(), - password: Joi.string(), - requestTimeout: Joi.number().default(30000), - pingTimeout: Joi.number().default(30000), - ssl: Joi.object({ - verificationMode: Joi.string() - .valid('none', 'certificate', 'full') - .default('full'), - certificateAuthorities: Joi.array() - .single() - .items(Joi.string()), - certificate: Joi.string(), - key: Joi.string(), - keyPassphrase: Joi.string(), - keystore: Joi.object({ - path: Joi.string(), - password: Joi.string(), - }).default(), - truststore: Joi.object({ - path: Joi.string(), - password: Joi.string(), - }).default(), - alwaysPresentCertificate: Joi.boolean().default(false), - }).default(), - apiVersion: Joi.string().default('master'), - logFetchCount: Joi.number().default(10), - }).default(), tests: Joi.object({ cloud_detector: Joi.object({ enabled: Joi.boolean().default(true), diff --git a/x-pack/legacy/plugins/monitoring/deprecations.js b/x-pack/legacy/plugins/monitoring/deprecations.js index c3b2b70690f33..6e35e86dd9d71 100644 --- a/x-pack/legacy/plugins/monitoring/deprecations.js +++ b/x-pack/legacy/plugins/monitoring/deprecations.js @@ -28,7 +28,7 @@ export const deprecations = () => { } }, (settings, log) => { - const fromPath = 'xpack.monitoring.elasticsearch'; + const fromPath = 'monitoring.elasticsearch'; const es = get(settings, 'elasticsearch'); if (es) { if (es.username === 'elastic') { @@ -39,7 +39,7 @@ export const deprecations = () => { } }, (settings, log) => { - const fromPath = 'xpack.monitoring.elasticsearch.ssl'; + const fromPath = 'monitoring.elasticsearch.ssl'; const ssl = get(settings, 'elasticsearch.ssl'); if (ssl) { if (ssl.key !== undefined && ssl.certificate === undefined) { diff --git a/x-pack/legacy/plugins/monitoring/index.js b/x-pack/legacy/plugins/monitoring/index.js index 8e0201bea710b..ca595836133c2 100644 --- a/x-pack/legacy/plugins/monitoring/index.js +++ b/x-pack/legacy/plugins/monitoring/index.js @@ -20,31 +20,31 @@ export const monitoring = kibana => new kibana.Plugin({ require: ['kibana', 'elasticsearch', 'xpack_main'], id: 'monitoring', - configPrefix: 'xpack.monitoring', + configPrefix: 'monitoring', publicDir: resolve(__dirname, 'public'), init(server) { const configs = [ - 'xpack.monitoring.ui.enabled', - 'xpack.monitoring.kibana.collection.enabled', - 'xpack.monitoring.max_bucket_size', - 'xpack.monitoring.min_interval_seconds', + 'monitoring.ui.enabled', + 'monitoring.kibana.collection.enabled', + 'monitoring.ui.max_bucket_size', + 'monitoring.ui.min_interval_seconds', 'kibana.index', - 'xpack.monitoring.show_license_expiration', - 'xpack.monitoring.ui.container.elasticsearch.enabled', - 'xpack.monitoring.ui.container.logstash.enabled', - 'xpack.monitoring.tests.cloud_detector.enabled', - 'xpack.monitoring.kibana.collection.interval', - 'xpack.monitoring.elasticsearch.hosts', - 'xpack.monitoring.elasticsearch', - 'xpack.monitoring.xpack_api_polling_frequency_millis', + 'monitoring.ui.show_license_expiration', + 'monitoring.ui.container.elasticsearch.enabled', + 'monitoring.ui.container.logstash.enabled', + 'monitoring.tests.cloud_detector.enabled', + 'monitoring.kibana.collection.interval', + 'monitoring.ui.elasticsearch.hosts', + 'monitoring.ui.elasticsearch', + 'monitoring.xpack_api_polling_frequency_millis', 'server.uuid', 'server.name', 'server.host', 'server.port', - 'xpack.monitoring.cluster_alerts.email_notifications.enabled', - 'xpack.monitoring.cluster_alerts.email_notifications.email_address', - 'xpack.monitoring.ccs.enabled', - 'xpack.monitoring.elasticsearch.logFetchCount', + 'monitoring.cluster_alerts.email_notifications.enabled', + 'monitoring.cluster_alerts.email_notifications.email_address', + 'monitoring.ui.ccs.enabled', + 'monitoring.ui.elasticsearch.logFetchCount', ]; const serverConfig = server.config(); diff --git a/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/flyout/__snapshots__/flyout.test.js.snap b/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/flyout/__snapshots__/flyout.test.js.snap index 7f48f3386b180..eb1c65c6a696d 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/flyout/__snapshots__/flyout.test.js.snap +++ b/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/flyout/__snapshots__/flyout.test.js.snap @@ -1174,7 +1174,7 @@ exports[`Flyout kibana part two should show instructions to disable internal col isCopyable={true} language="bash" > - xpack.monitoring.kibana.collection.enabled: false + monitoring.kibana.collection.enabled: false - xpack.monitoring.enabled + monitoring.enabled , "defaultValue": true @@ -2091,7 +2091,7 @@ exports[`Flyout should show a restart warning for restarting the primary Kibana isCopyable={true} language="bash" > - xpack.monitoring.kibana.collection.enabled: false + monitoring.kibana.collection.enabled: false - xpack.monitoring.enabled + monitoring.enabled , "defaultValue": true diff --git a/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/instruction_steps/kibana/disable_internal_collection_instructions.js b/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/instruction_steps/kibana/disable_internal_collection_instructions.js index 9326156c1ac36..5f7f97b74e871 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/instruction_steps/kibana/disable_internal_collection_instructions.js +++ b/x-pack/legacy/plugins/monitoring/public/components/metricbeat_migration/instruction_steps/kibana/disable_internal_collection_instructions.js @@ -61,7 +61,7 @@ export function getKibanaInstructionsForDisablingInternalCollection(product, met - xpack.monitoring.kibana.collection.enabled: false + monitoring.kibana.collection.enabled: false @@ -70,7 +70,7 @@ export function getKibanaInstructionsForDisablingInternalCollection(product, met id="xpack.monitoring.metricbeatMigration.kibanaInstructions.disableInternalCollection.note" defaultMessage="For {config}, leave the default value of ({defaultValue})." values={{ - config: xpack.monitoring.enabled, + config: monitoring.enabled, defaultValue: true, }} /> diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js index 0c9fb4bd04ee7..eff9875d794ad 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/alerts_cluster_search.js @@ -157,7 +157,7 @@ export function alertsClusterSearch(req, alertsIndex, cluster, checkLicense, opt if (prodLicenseInfo.clusterAlerts.enabled) { const config = req.server.config(); - const size = options.size || config.get('xpack.monitoring.max_bucket_size'); + const size = options.size || config.get('monitoring.ui.max_bucket_size'); const params = { index: alertsIndex, diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js index 9cc67e11c28d5..e94f4e08fbdb1 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/verify_monitoring_license.js @@ -19,7 +19,7 @@ export function verifyMonitoringLicense(server) { const config = server.config(); // if cluster alerts are enabled, then ensure that we can use it according to the license - if (config.get('xpack.monitoring.cluster_alerts.enabled')) { + if (config.get('monitoring.cluster_alerts.enabled')) { const xpackInfo = get(server.plugins.monitoring, 'info'); if (xpackInfo) { const monitoringCluster = xpackInfo.feature('monitoring').getLicenseCheckResults(); diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js b/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js index 6844bd5febf8e..88cf9734d5f57 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js +++ b/x-pack/legacy/plugins/monitoring/server/es_client/__tests__/instantiate_client.js @@ -11,8 +11,8 @@ import { exposeClient, hasMonitoringCluster } from '../instantiate_client'; function getMockServerFromConnectionUrl(monitoringClusterUrl) { const server = { - xpack: { - monitoring: { + monitoring: { + ui: { elasticsearch: { hosts: monitoringClusterUrl ? [monitoringClusterUrl] : [], username: 'monitoring-user-internal-test', @@ -27,7 +27,7 @@ function getMockServerFromConnectionUrl(monitoringClusterUrl) { }; return { - elasticsearchConfig: server.xpack.monitoring.elasticsearch, + elasticsearchConfig: server.monitoring.ui.elasticsearch, elasticsearchPlugin: { getCluster: sinon .stub() diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts index c6f4e0fa68504..8d9b5335732c0 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts +++ b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.test.ts @@ -168,14 +168,14 @@ describe('throws when config is invalid', () => { it('throws if key and keystore.path are both specified', () => { const value = { ssl: { key: 'foo', keystore: { path: 'bar' } } }; expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot( - `"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"` + `"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [key] when [keystore.path] is specified"` ); }); it('throws if certificate and keystore.path are both specified', () => { const value = { ssl: { certificate: 'foo', keystore: { path: 'bar' } } }; expect(() => parse(value)).toThrowErrorMatchingInlineSnapshot( - `"[config validation of [xpack.monitoring.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"` + `"[config validation of [monitoring.ui.elasticsearch].ssl]: cannot use [certificate] when [keystore.path] is specified"` ); }); }); diff --git a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts index 70e6235602b5b..728b3433bf06c 100644 --- a/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts +++ b/x-pack/legacy/plugins/monitoring/server/es_client/parse_elasticsearch_config.ts @@ -7,7 +7,7 @@ import { readFileSync } from 'fs'; import { readPkcs12Truststore, readPkcs12Keystore } from '../../../../../../src/core/utils'; -const KEY = 'xpack.monitoring.elasticsearch'; +const KEY = 'monitoring.ui.elasticsearch'; /* * Parse a config object's Elasticsearch configuration, reading any diff --git a/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js b/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js index b43430ead23b0..ba07f512de896 100644 --- a/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js +++ b/x-pack/legacy/plugins/monitoring/server/init_monitoring_xpack_info.js @@ -15,7 +15,7 @@ export const initMonitoringXpackInfo = async ({ config, xpackMainPlugin, expose, const xpackInfo = hasMonitoringCluster(config) ? xpackMainPlugin.createXPackInfo({ clusterSource: 'monitoring', - pollFrequencyInMillis: config.get('xpack.monitoring.xpack_api_polling_frequency_millis'), + pollFrequencyInMillis: config.get('monitoring.xpack_api_polling_frequency_millis'), }) : xpackMainPlugin.info; diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/bulk_uploader.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/bulk_uploader.js index 5e0d8aa4be1fd..cf68ec073bebc 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/bulk_uploader.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/bulk_uploader.js @@ -24,7 +24,7 @@ const LOGGING_TAGS = [LOGGING_TAG, KIBANA_MONITORING_LOGGING_TAG]; * NOTE: internal collection will be removed in 7.0 * * Depends on - * - 'xpack.monitoring.kibana.collection.enabled' config + * - 'monitoring.kibana.collection.enabled' config * - monitoring enabled in ES (checked against xpack_main.info license info change) * The dependencies are handled upstream * - Ops Events - essentially Kibana's /api/status diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js index 96dc461c03fd3..10f52a82a830c 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/__tests__/get_default_admin_email.js @@ -14,14 +14,10 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { function setup({ enabled = true, adminEmail = null } = {}) { const config = { get: sinon.stub() }; - config.get - .withArgs('xpack.monitoring.cluster_alerts.email_notifications.enabled') - .returns(enabled); + config.get.withArgs('monitoring.cluster_alerts.email_notifications.enabled').returns(enabled); if (adminEmail) { - config.get - .withArgs(`xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`) - .returns(adminEmail); + config.get.withArgs(`monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`).returns(adminEmail); } config.get.withArgs('kibana.index').returns('.kibana'); @@ -31,7 +27,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { return config; } - describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = false', () => { + describe('monitoring.cluster_alerts.email_notifications.enabled = false', () => { it('returns null when email is defined', async () => { const config = setup({ enabled: false }); expect(await getDefaultAdminEmail(config)).to.be(null); @@ -43,7 +39,7 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => { }); }); - describe('xpack.monitoring.cluster_alerts.email_notifications.enabled = true', () => { + describe('monitoring.cluster_alerts.email_notifications.enabled = true', () => { it('returns value when email is defined', async () => { const config = setup({ adminEmail: 'hello@world' }); expect(await getDefaultAdminEmail(config)).to.be('hello@world'); diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js index d0e1d32a2baa4..f51e7d22a0c7c 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/get_settings_collector.js @@ -11,11 +11,11 @@ import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY, KIBANA_SETTINGS_TYPE } from '../../. * If so, get email from kibana.yml */ export async function getDefaultAdminEmail(config) { - if (!config.get('xpack.monitoring.cluster_alerts.email_notifications.enabled')) { + if (!config.get('monitoring.cluster_alerts.email_notifications.enabled')) { return null; } - const emailAddressConfigKey = `xpack.monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`; + const emailAddressConfigKey = `monitoring.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}`; const configuredEmailAddress = config.get(emailAddressConfigKey); return configuredEmailAddress || null; diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js index d58f6f3254c76..699a364433b3e 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/collectors/ops_buffer/ops_buffer.js @@ -17,7 +17,7 @@ export function opsBuffer({ config, log, getOSInfo }) { // determine the cloud service in the background const cloudDetector = new CloudDetector(); - if (config.get('xpack.monitoring.tests.cloud_detector.enabled')) { + if (config.get('monitoring.tests.cloud_detector.enabled')) { cloudDetector.detectCloudService(); } diff --git a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js index bf79ddc210902..3c02e2be58dec 100644 --- a/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js +++ b/x-pack/legacy/plugins/monitoring/server/kibana_monitoring/init.js @@ -16,7 +16,7 @@ import { BulkUploader } from './bulk_uploader'; * @param {Object} server HapiJS server instance */ export function initBulkUploader({ config, ...params }) { - const interval = config.get('xpack.monitoring.kibana.collection.interval'); + const interval = config.get('monitoring.kibana.collection.interval'); return new BulkUploader({ interval, config, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js b/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js index 844dfc96bb19b..2d310962238fd 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/__tests__/ccs_utils.js @@ -17,7 +17,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('xpack.monitoring.ccs.enabled').returns(false); + get.withArgs('monitoring.ui.ccs.enabled').returns(false); // falsy string values should be ignored const allPattern = prefixIndexPattern(config, indexPattern, '*'); @@ -32,7 +32,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('xpack.monitoring.ccs.enabled').returns(true); + get.withArgs('monitoring.ui.ccs.enabled').returns(true); // falsy string values should be ignored const undefinedPattern = prefixIndexPattern(config, indexPattern); @@ -49,7 +49,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('xpack.monitoring.ccs.enabled').returns(true); + get.withArgs('monitoring.ui.ccs.enabled').returns(true); const abcPattern = prefixIndexPattern(config, indexPattern, 'aBc'); const underscorePattern = prefixIndexPattern(config, indexPattern, 'cluster_one'); @@ -67,7 +67,7 @@ describe('ccs_utils', () => { const get = sinon.stub(); const config = { get }; - get.withArgs('xpack.monitoring.ccs.enabled').returns(true); + get.withArgs('monitoring.ui.ccs.enabled').returns(true); const pattern = prefixIndexPattern(config, indexPattern, '*'); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js index ef8db59620f1a..40070a6b0d0f2 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms.js @@ -84,7 +84,7 @@ export async function getApms(req, apmIndexPattern, clusterUuid) { const params = { index: apmIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), // FIXME + size: config.get('monitoring.ui.max_bucket_size'), // FIXME ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js index 95ccb81f696be..a24936dc0f832 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_apms_for_clusters.js @@ -35,7 +35,7 @@ export function getApmsForClusters(req, apmIndexPattern, clusters) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const config = req.server.config(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); return Promise.all( clusters.map(async cluster => { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js index 54a0609d945de..bfaec4f8a1294 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/apm/get_stats.js @@ -28,7 +28,7 @@ export async function getStats(req, apmIndexPattern, clusterUuid) { const config = req.server.config(); const start = moment.utc(req.payload.timeRange.min).valueOf(); const end = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const params = { index: apmIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js index 5857ec32b2259..ef878e4892557 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats.js @@ -83,7 +83,7 @@ export async function getBeats(req, beatsIndexPattern, clusterUuid) { const params = { index: beatsIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), // FIXME + size: config.get('monitoring.ui.max_bucket_size'), // FIXME ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js index 82a738755931d..624abb894e508 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_beats_for_clusters.js @@ -34,7 +34,7 @@ export function getBeatsForClusters(req, beatsIndexPattern, clusters) { const start = req.payload.timeRange.min; const end = req.payload.timeRange.max; const config = req.server.config(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); return Promise.all( clusters.map(async cluster => { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js index d326c84634e12..1139489728dbf 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_latest_stats.js @@ -71,7 +71,7 @@ export function getLatestStats(req, beatsIndexPattern, clusterUuid) { uuids: { terms: { field: 'beats_stats.beat.uuid', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, }, }, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js index 80851a8498c26..0f90750a293fb 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/beats/get_stats.js @@ -28,7 +28,7 @@ export async function getStats(req, beatsIndexPattern, clusterUuid) { const config = req.server.config(); const start = moment.utc(req.payload.timeRange.min).valueOf(); const end = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const params = { index: beatsIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js b/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js index 5b3980d9619a8..3409462156a07 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/ccs_utils.js @@ -16,7 +16,7 @@ * @return {String} The index pattern with the {@code cluster} prefix appropriately prepended. */ export function prefixIndexPattern(config, indexPattern, ccs) { - const ccsEnabled = config.get('xpack.monitoring.ccs.enabled'); + const ccsEnabled = config.get('monitoring.ui.ccs.enabled'); if (!ccsEnabled || !ccs) { return indexPattern; diff --git a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js index d3456eeb2fe4e..2b080a5c333fc 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js @@ -55,7 +55,7 @@ export async function getClustersFromRequest( } = indexPatterns; const config = req.server.config(); - const size = config.get('xpack.monitoring.max_bucket_size'); + const size = config.get('monitoring.ui.max_bucket_size'); const isStandaloneCluster = clusterUuid === STANDALONE_CLUSTER_CLUSTER_UUID; let clusters = []; diff --git a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js index c323cb381aaf2..54dc58a374c2c 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/cluster/get_clusters_stats.js @@ -46,7 +46,7 @@ function fetchClusterStats(req, esIndexPattern, clusterUuid) { const metric = ElasticsearchMetric.getMetricFields(); const params = { index: esIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, filterPath: [ 'hits.hits._index', diff --git a/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js b/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js index b7c387e74ec96..fbe6c8ec4cfa3 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/details/__test__/get_metrics.test.js @@ -20,7 +20,7 @@ function getMockReq(metricsBuckets = []) { get: sinon.stub(), }; - config.get.withArgs('xpack.monitoring.min_interval_seconds').returns(10); + config.get.withArgs('monitoring.ui.min_interval_seconds').returns(10); return { server: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js b/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js index 798a94abbe484..0c4736e91ea10 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/details/get_metrics.js @@ -28,7 +28,7 @@ export async function getMetrics( // TODO: Pass in req parameters as explicit function parameters let min = moment.utc(req.payload.timeRange.min).valueOf(); const max = moment.utc(req.payload.timeRange.max).valueOf(); - const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); + const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); const bucketSize = calculateTimeseriesInterval(min, max, minIntervalSeconds); const timezone = await getTimezone(req); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js index 658ee96c1f084..8aef402f881e8 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.js @@ -23,7 +23,7 @@ export function getMlJobs(req, esIndexPattern) { checkParam(esIndexPattern, 'esIndexPattern in getMlJobs'); const config = req.server.config(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const start = req.payload.timeRange.min; // no wrapping in moment :) const end = req.payload.timeRange.max; const clusterUuid = req.params.clusterUuid; diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js index 6fe8ccfd89043..938a9b9d55e43 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.js @@ -97,7 +97,7 @@ export function getIndices(req, esIndexPattern, showSystemIndices = false, shard const params = { index: esIndexPattern, // TODO: composite aggregation - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, filterPath: [ // only filter path can filter for inner_hits diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js index 7581a32590971..c248ad743e0ec 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.js @@ -44,7 +44,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n const min = start; const bucketSize = Math.max( - config.get('xpack.monitoring.min_interval_seconds'), + config.get('monitoring.ui.min_interval_seconds'), calculateAuto(100, duration).asSeconds() ); @@ -59,7 +59,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n const params = { index: esIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ @@ -78,7 +78,7 @@ export async function getNodes(req, esIndexPattern, pageOfNodes, clusterStats, n terms: { field: `source_node.uuid`, include: uuidsToInclude, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, aggs: { by_date: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js index 51c61046e9cda..e18d328e8725b 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_paginated_nodes.js @@ -38,7 +38,7 @@ export async function getPaginatedNodes( { clusterStats, nodesShardCount } ) { const config = req.server.config(); - const size = config.get('xpack.monitoring.max_bucket_size'); + const size = config.get('monitoring.ui.max_bucket_size'); const nodes = await getNodeIds(req, esIndexPattern, { clusterUuid }, size); // Add `isOnline` and shards from the cluster state and shard stats @@ -63,7 +63,7 @@ export async function getPaginatedNodes( const groupBy = { field: `source_node.uuid`, include: nodes.map(node => node.uuid), - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }; const metricSeriesData = await getMetrics( req, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js index e8d484e7021f4..c77bcc4f62e61 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.js @@ -12,7 +12,7 @@ import { calculateIndicesTotals } from './calculate_shard_stat_indices_totals'; async function getUnassignedShardData(req, esIndexPattern, cluster) { const config = req.server.config(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const metric = ElasticsearchMetric.getMetricFields(); const params = { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js index c11bd4aead693..7823884dc749d 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.js @@ -11,7 +11,7 @@ import { ElasticsearchMetric } from '../../metrics'; async function getShardCountPerNode(req, esIndexPattern, cluster) { const config = req.server.config(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const metric = ElasticsearchMetric.getMetricFields(); const params = { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js index 3be5650b7d3bc..40412c03b0ef9 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.js @@ -55,7 +55,7 @@ export function getShardAllocation( const metric = ElasticsearchMetric.getMetricFields(); const params = { index: esIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ type: 'shards', clusterUuid, metric, filters }), diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js index eddd50612cdb1..8c4834e5d5e40 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stat_aggs.js @@ -9,7 +9,7 @@ * @param {Boolean} includeNodes - whether to add the aggs for node shards */ export function getShardAggs(config, includeNodes, includeIndices) { - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const aggSize = 10; const indicesAgg = { terms: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js index af6563bae682d..c272c38f00d55 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas.js @@ -31,7 +31,7 @@ export function getKibanas(req, kbnIndexPattern, { clusterUuid }) { const params = { index: kbnIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, body: { query: createQuery({ diff --git a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js index dbf1c41dcf4e5..e50e8bda3c907 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.js @@ -49,7 +49,7 @@ export function getKibanasForClusters(req, kbnIndexPattern, clusters) { kibana_uuids: { terms: { field: 'kibana_stats.kibana.uuid', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, aggs: { latest_report: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js index 7a20d7737c5e8..b876e3ba05d70 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js @@ -70,7 +70,7 @@ export async function getLogs( const params = { index: filebeatIndexPattern, - size: Math.min(50, config.get('xpack.monitoring.elasticsearch.logFetchCount')), + size: Math.min(50, config.get('monitoring.ui.elasticsearch.logFetchCount')), filterPath: [ 'hits.hits._source.message', 'hits.hits._source.log.level', diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js index d0de2c3f5df3a..55baa3cf10b50 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.js @@ -60,7 +60,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { logstash_uuids: { terms: { field: 'logstash_stats.logstash.uuid', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, aggs: { latest_report: { @@ -119,7 +119,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { logstash_versions: { terms: { field: 'logstash_stats.logstash.version', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, }, pipelines_nested: { @@ -135,7 +135,7 @@ export function getLogstashForClusters(req, lsIndexPattern, clusters) { queue_types: { terms: { field: 'logstash_stats.pipelines.queue.type', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, aggs: { num_pipelines: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js index 93b70d7b79f0a..06696abdb031f 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_nodes.js @@ -31,7 +31,7 @@ export function getNodes(req, lsIndexPattern, { clusterUuid }) { const params = { index: lsIndexPattern, - size: config.get('xpack.monitoring.max_bucket_size'), // FIXME + size: config.get('monitoring.ui.max_bucket_size'), // FIXME ignoreUnavailable: true, body: { query: createQuery({ diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js index ef9ef90e8f310..ffc7e9ce1d6c2 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.js @@ -37,7 +37,7 @@ export async function getPaginatedPipelines( queryText ) { const config = req.server.config(); - const size = config.get('xpack.monitoring.max_bucket_size'); + const size = config.get('monitoring.ui.max_bucket_size'); const pipelines = await getLogstashPipelineIds( req, lsIndexPattern, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js index eeeffd74e91f7..35a4295de298b 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline.js @@ -111,7 +111,7 @@ export async function getPipeline(req, config, lsIndexPattern, clusterUuid, pipe }; // Determine metrics' timeseries interval based on version's timespan - const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); + const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); const timeseriesInterval = calculateTimeseriesInterval( version.firstSeen, version.lastSeen, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js index 1858674a01b86..d9c03819b0098 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.js @@ -171,7 +171,7 @@ export function getPipelineStatsAggregation( logstashIndexPattern, pipelineId, version, - config.get('xpack.monitoring.max_bucket_size'), + config.get('monitoring.ui.max_bucket_size'), callWithRequest, req ); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js index 7dfa8d4a163ce..7521389c379ea 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_versions.js @@ -37,7 +37,7 @@ function fetchPipelineVersions(...args) { by_pipeline_hash: { terms: { field: 'logstash_stats.pipelines.hash', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), order: { 'path_to_root>first_seen': 'desc' }, }, aggs: { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js index 49c2dff2d6080..134dd88b36ce6 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex.js @@ -130,7 +130,7 @@ export async function getPipelineVertex( }; // Determine metrics' timeseries interval based on version's timespan - const minIntervalSeconds = config.get('xpack.monitoring.min_interval_seconds'); + const minIntervalSeconds = config.get('monitoring.ui.min_interval_seconds'); const timeseriesInterval = calculateTimeseriesInterval( version.firstSeen, version.lastSeen, diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js index c91182188b213..425ca5731926c 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.js @@ -216,7 +216,7 @@ export function getPipelineVertexStatsAggregation( version, vertexId, timeSeriesIntervalInSeconds, - config.get('xpack.monitoring.max_bucket_size'), + config.get('monitoring.ui.max_bucket_size'), callWithRequest, req ); diff --git a/x-pack/legacy/plugins/monitoring/server/plugin.js b/x-pack/legacy/plugins/monitoring/server/plugin.js index 163bc43945be1..ef346e95ad075 100644 --- a/x-pack/legacy/plugins/monitoring/server/plugin.js +++ b/x-pack/legacy/plugins/monitoring/server/plugin.js @@ -48,7 +48,7 @@ export class Plugin { /* * End-user-facing services */ - const uiEnabled = config.get('xpack.monitoring.ui.enabled'); + const uiEnabled = config.get('monitoring.ui.enabled'); if (uiEnabled) { await instantiateClient({ @@ -98,7 +98,7 @@ export class Plugin { kbnServerStatus: kbnServer.status, kbnServerVersion: kbnServer.version, }); - const kibanaCollectionEnabled = config.get('xpack.monitoring.kibana.collection.enabled'); + const kibanaCollectionEnabled = config.get('monitoring.kibana.collection.enabled'); if (kibanaCollectionEnabled) { /* @@ -125,14 +125,12 @@ export class Plugin { core.injectUiAppVars('monitoring', () => { const config = core.config(); return { - maxBucketSize: config.get('xpack.monitoring.max_bucket_size'), - minIntervalSeconds: config.get('xpack.monitoring.min_interval_seconds'), + maxBucketSize: config.get('monitoring.ui.max_bucket_size'), + minIntervalSeconds: config.get('monitoring.ui.min_interval_seconds'), kbnIndex: config.get('kibana.index'), - showLicenseExpiration: config.get('xpack.monitoring.show_license_expiration'), - showCgroupMetricsElasticsearch: config.get( - 'xpack.monitoring.ui.container.elasticsearch.enabled' - ), - showCgroupMetricsLogstash: config.get('xpack.monitoring.ui.container.logstash.enabled'), // Note, not currently used, but see https://github.com/elastic/x-pack-kibana/issues/1559 part 2 + showLicenseExpiration: config.get('monitoring.ui.show_license_expiration'), + showCgroupMetricsElasticsearch: config.get('monitoring.ui.container.elasticsearch.enabled'), + showCgroupMetricsLogstash: config.get('monitoring.ui.container.logstash.enabled'), // Note, not currently used, but see https://github.com/elastic/x-pack-kibana/issues/1559 part 2 }; }); } diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js index 2d4bded9fc4c8..fcdf4ad8a706c 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr.js @@ -26,7 +26,7 @@ function getBucketScript(max, min) { function buildRequest(req, config, esIndexPattern) { const min = moment.utc(req.payload.timeRange.min).valueOf(); const max = moment.utc(req.payload.timeRange.max).valueOf(); - const maxBucketSize = config.get('xpack.monitoring.max_bucket_size'); + const maxBucketSize = config.get('monitoring.ui.max_bucket_size'); const aggs = { ops_synced_max: { max: { 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 10226d74ed001..25ead723e3ddb 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 @@ -61,7 +61,7 @@ export function esNodeRoute(server) { metricSet = metricSetOverview; // set the cgroup option if needed const showCgroupMetricsElasticsearch = config.get( - 'xpack.monitoring.ui.container.elasticsearch.enabled' + 'monitoring.ui.container.elasticsearch.enabled' ); const metricCpu = metricSet.find(m => m.name === 'node_cpu_metric'); if (showCgroupMetricsElasticsearch) { diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js index d5ce9d1686f8a..bd3ae5f5c2679 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/node.js @@ -60,9 +60,7 @@ export function logstashNodeRoute(server) { } else { metricSet = metricSetOverview; // set the cgroup option if needed - const showCgroupMetricsLogstash = config.get( - 'xpack.monitoring.ui.container.logstash.enabled' - ); + const showCgroupMetricsLogstash = config.get('monitoring.ui.container.logstash.enabled'); const metricCpu = metricSet.find(m => m.name === 'logstash_node_cpu_metric'); if (showCgroupMetricsLogstash) { metricCpu.keys = ['logstash_node_cgroup_quota_as_cpu_utilization']; diff --git a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js index c5fd76487cca1..93330880babcc 100644 --- a/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js +++ b/x-pack/legacy/plugins/monitoring/server/routes/api/v1/logstash/pipelines/cluster_pipeline_ids.js @@ -36,7 +36,7 @@ export function logstashClusterPipelineIdsRoute(server) { const { ccs } = req.payload; const clusterUuid = req.params.clusterUuid; const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs); - const size = config.get('xpack.monitoring.max_bucket_size'); + const size = config.get('monitoring.ui.max_bucket_size'); try { const pipelines = await getLogstashPipelineIds(req, lsIndexPattern, { clusterUuid }, size); diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts index fc85cbe442ddf..4738ab5b8af83 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts @@ -40,7 +40,7 @@ export function fetchClusterUuids({ server, callCluster, start, end }: StatsColl cluster_uuids: { terms: { field: 'cluster_uuid', - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), }, }, }, diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js index 8e5a59361e52f..52d34258b5fa4 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_es_stats.js @@ -31,7 +31,7 @@ export function fetchElasticsearchStats(server, callCluster, clusterUuids) { const config = server.config(); const params = { index: INDEX_PATTERN_ELASTICSEARCH, - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), ignoreUnavailable: true, filterPath: [ 'hits.hits._source.cluster_uuid', diff --git a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js index 2632a8f6e041d..b87f632308e4d 100644 --- a/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js +++ b/x-pack/legacy/plugins/monitoring/server/telemetry_collection/get_high_level_stats.js @@ -217,7 +217,7 @@ export async function fetchHighLevelStats(server, callCluster, clusterUuids, sta const params = { index: getIndexPatternForStackProduct(product), - size: config.get('xpack.monitoring.max_bucket_size'), + size: config.get('monitoring.ui.max_bucket_size'), headers: { 'X-QUERY-SOURCE': TELEMETRY_QUERY_SOURCE, }, diff --git a/x-pack/legacy/plugins/monitoring/ui_exports.js b/x-pack/legacy/plugins/monitoring/ui_exports.js index 2b5ea21a2bb45..9251deb673bd1 100644 --- a/x-pack/legacy/plugins/monitoring/ui_exports.js +++ b/x-pack/legacy/plugins/monitoring/ui_exports.js @@ -32,7 +32,7 @@ export const getUiExports = () => ({ injectDefaultVars(server) { const config = server.config(); return { - monitoringUiEnabled: config.get('xpack.monitoring.ui.enabled'), + monitoringUiEnabled: config.get('monitoring.ui.enabled'), }; }, hacks: ['plugins/monitoring/hacks/toggle_app_link_in_nav'], diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/http_requests.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/http_requests.js deleted file mode 100644 index 4552e62c371a1..0000000000000 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/http_requests.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import sinon from 'sinon'; - -// Register helpers to mock HTTP Requests -const registerHttpRequestMockHelpers = server => { - const setIndexPatternValidityResponse = response => { - const defaultResponse = { - doesMatchIndices: true, - doesMatchRollupIndices: false, - dateFields: ['foo', 'bar'], - numericFields: [], - keywordFields: [], - }; - server.respondWith(/\/api\/rollup\/index_pattern_validity\/.*/, [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify({ ...defaultResponse, ...response }), - ]); - }; - - const setCreateJobResponse = (responsePayload = {}) => { - server.respondWith(/\/api\/rollup\/create/, [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(responsePayload), - ]); - }; - - const setStartJobResponse = () => { - server.respondWith(/\/api\/rollup\/start/, [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify({}), - ]); - }; - - const setLoadJobsResponse = response => { - server.respondWith('GET', '/api/rollup/jobs', [ - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify(response), - ]); - }; - - return { - setIndexPatternValidityResponse, - setCreateJobResponse, - setLoadJobsResponse, - setStartJobResponse, - }; -}; - -export const init = () => { - const server = sinon.fakeServer.create(); - server.respondImmediately = true; - - // We make requests to APIs which don't impact the UX, e.g. UI metric telemetry, - // and we can mock them all with a 200 instead of mocking each one individually. - server.respondWith([200, {}, '']); - - return { - server, - httpRequestsMockHelpers: registerHttpRequestMockHelpers(server), - }; -}; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js index 9573e2f405b84..4a5b67e687d85 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js @@ -10,7 +10,9 @@ import { setup as jobCloneSetup } from './job_clone.helpers'; export { nextTick, getRandomString, findTestSubject } from '../../../../../../test_utils'; -export { setupEnvironment } from './setup_environment'; +export { mockHttpRequest } from './setup_environment'; + +export { wrapComponent } from './setup_context'; export const pageHelpers = { jobCreate: { setup: jobCreateSetup }, diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js index db0bb49289b60..a8376bb31b23f 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js @@ -10,8 +10,10 @@ import { JobCreate } from '../../../public/crud_app/sections'; import { JOB_TO_CLONE } from './constants'; import { deserializeJob } from '../../../public/crud_app/services'; +import { wrapComponent } from './setup_context'; + export const setup = props => { - const initTestBed = registerTestBed(JobCreate, { + const initTestBed = registerTestBed(wrapComponent(JobCreate), { store: createRollupJobsStore({ cloneJob: { job: deserializeJob(JOB_TO_CLONE.jobs[0]) }, }), diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js index 5de5d02dadd83..2395fd014dd1e 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js @@ -10,7 +10,9 @@ import { JobCreate } from '../../../public/crud_app/sections'; import { JOB_TO_CREATE } from './constants'; -const initTestBed = registerTestBed(JobCreate, { store: rollupJobsStore }); +import { wrapComponent } from './setup_context'; + +const initTestBed = registerTestBed(wrapComponent(JobCreate), { store: rollupJobsStore }); export const setup = props => { const testBed = initTestBed(props); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js index 10fa79f775fdc..bcad8c29c87c0 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js @@ -9,6 +9,8 @@ import { registerRouter } from '../../../public/crud_app/services'; import { createRollupJobsStore } from '../../../public/crud_app/store'; import { JobList } from '../../../public/crud_app/sections/job_list'; +import { wrapComponent } from './setup_context'; + const testBedConfig = { store: createRollupJobsStore, memoryRouter: { @@ -19,4 +21,4 @@ const testBedConfig = { }, }; -export const setup = registerTestBed(JobList, testBedConfig); +export const setup = registerTestBed(wrapComponent(JobList), testBedConfig); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_context.tsx b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_context.tsx new file mode 100644 index 0000000000000..4c5a8e17c586a --- /dev/null +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_context.tsx @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { FunctionComponent } from 'react'; + +import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; +import { coreMock } from '../../../../../../../src/core/public/mocks'; +const startMock = coreMock.createStart(); + +const services = { + setBreadcrumbs: startMock.chrome.setBreadcrumbs, +}; + +const wrapComponent = (Component: FunctionComponent) => (props: any) => ( + + + +); + +export { wrapComponent }; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.js deleted file mode 100644 index 71e7f050786b5..0000000000000 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import axios from 'axios'; -import axiosXhrAdapter from 'axios/lib/adapters/xhr'; - -import { setHttp } from '../../../public/crud_app/services'; -import { init as initHttpRequests } from './http_requests'; - -export const setupEnvironment = () => { - // axios has a $http like interface so using it to simulate $http - setHttp(axios.create({ adapter: axiosXhrAdapter })); - - const { server, httpRequestsMockHelpers } = initHttpRequests(); - - return { - server, - httpRequestsMockHelpers, - }; -}; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.ts b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.ts new file mode 100644 index 0000000000000..a8db058908ad4 --- /dev/null +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.ts @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +interface RequestMocks { + jobs?: object; + createdJob?: object; + indxPatternVldtResp?: object; + [key: string]: any; +} + +const mockHttpRequest = ( + http: any, + { jobs = {}, createdJob = {}, indxPatternVldtResp = {} }: RequestMocks = {} +) => { + http.get.mockImplementation(async (url: string) => { + if (url === '/api/rollup/jobs') { + return jobs; + } + + if (url.startsWith('/api/rollup/index_pattern_validity')) { + return { + doesMatchIndices: true, + doesMatchRollupIndices: false, + dateFields: ['foo', 'bar'], + numericFields: [], + keywordFields: [], + ...indxPatternVldtResp, + }; + } + + return {}; + }); + + // mock '/api/rollup/start' + http.post.mockImplementation(async (url: string) => ({})); + + // mock '/api/rollup/create + http.put.mockImplementation(async (url: string) => createdJob); +}; + +export { mockHttpRequest }; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js index 4ffffd7574bd8..b7c98ed179c7a 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers, nextTick } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants'; jest.mock('ui/new_platform'); @@ -17,26 +18,28 @@ const { } = JOB_TO_CLONE; describe('Cloning a rollup job through create job wizard', () => { - let httpRequestsMockHelpers; - let server; let find; let exists; let form; let table; let actions; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { - httpRequestsMockHelpers.setIndexPatternValidityResponse(JOB_CLONE_INDEX_PATTERN_CHECK); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK }); ({ exists, find, form, actions, table } = setup()); }); - afterAll(() => { - server.restore(); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); }); it('should have fields correctly pre-populated', async () => { diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js index c4336c535a0ee..b8ec7d9f85d00 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js @@ -6,7 +6,8 @@ import moment from 'moment-timezone'; -import { setupEnvironment, pageHelpers } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers } from './helpers'; jest.mock('ui/new_platform'); @@ -15,30 +16,31 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 2: Date histogram', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; let goToStep; let form; let getEuiStepsHorizontalActive; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); - - afterAll(() => { - server.restore(); - }); - beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, form, getEuiStepsHorizontalActive, goToStep } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); + }); + describe('layout', () => { beforeEach(async () => { await goToStep(2); @@ -71,7 +73,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => { describe('Date field select', () => { it('should set the options value from the index pattern', async () => { const dateFields = ['field1', 'field2', 'field3']; - httpRequestsMockHelpers.setIndexPatternValidityResponse({ dateFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } }); await goToStep(2); @@ -83,7 +85,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => { it('should sort the options in ascending order', async () => { const dateFields = ['field3', 'field2', 'field1']; - httpRequestsMockHelpers.setIndexPatternValidityResponse({ dateFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } }); await goToStep(2); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js index f91c4582ba247..c4b5d753f1a26 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers } from './helpers'; jest.mock('ui/new_platform'); @@ -13,8 +14,6 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 4: Histogram', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; @@ -22,22 +21,26 @@ describe('Create Rollup Job, step 4: Histogram', () => { let goToStep; let table; let form; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, form } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); + }); + const numericFields = ['a-numericField', 'b-numericField']; const goToStepAndOpenFieldChooser = async () => { @@ -108,7 +111,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { describe('when no histogram fields are availalbe', () => { it('should indicate it to the user', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: [] }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: [] } }); await goToStepAndOpenFieldChooser(); const { tableCellsValues } = table.getMetaData('rollupJobHistogramFieldChooser-table'); @@ -119,7 +122,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { describe('when histogram fields are available', () => { beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); await goToStepAndOpenFieldChooser(); }); @@ -153,7 +156,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { it('should have a delete button on each row to remove an histogram field', async () => { // First let's add a term to the list - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); await goToStepAndOpenFieldChooser(); const { rows: fieldChooserRows } = table.getMetaData('rollupJobHistogramFieldChooser-table'); fieldChooserRows[0].reactWrapper.simulate('click'); @@ -180,7 +183,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { }; beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); await goToStep(4); addHistogramFieldToList(); }); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js index c960eabb37dcb..98af94437fa5a 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js @@ -13,7 +13,8 @@ import { YEAR, } from '../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; import { indexPatterns } from '../../../../../../src/plugins/data/public'; -import { setupEnvironment, pageHelpers } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers } from './helpers'; jest.mock('ui/new_platform'); @@ -22,29 +23,31 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 1: Logistics', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; let form; let getEuiStepsHorizontalActive; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, form, getEuiStepsHorizontalActive } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); + }); + it('should have the horizontal step active on "Logistics"', () => { expect(getEuiStepsHorizontalActive()).toContain('Logistics'); }); @@ -94,14 +97,14 @@ describe('Create Rollup Job, step 1: Logistics', () => { }); it('should not allow an unknown index pattern', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ doesMatchIndices: false }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { doesMatchIndices: false } }); await form.setInputValue('rollupIndexPattern', 'unknown', true); actions.clickNextStep(); expect(form.getErrorsMessages()).toContain("Index pattern doesn't match any indices."); }); it('should not allow an index pattern without time fields', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ dateFields: [] }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields: [] } }); await form.setInputValue('rollupIndexPattern', 'abc', true); actions.clickNextStep(); expect(form.getErrorsMessages()).toContain( @@ -110,7 +113,9 @@ describe('Create Rollup Job, step 1: Logistics', () => { }); it('should not allow an index pattern that matches a rollup index', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ doesMatchRollupIndices: true }); + mockHttpRequest(npStart.core.http, { + indxPatternVldtResp: { doesMatchRollupIndices: true }, + }); await form.setInputValue('rollupIndexPattern', 'abc', true); actions.clickNextStep(); expect(form.getErrorsMessages()).toContain('Index pattern must not match rollup indices.'); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js index bbbd2974c56db..a72dc8b25c083 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers } from './helpers'; jest.mock('ui/new_platform'); @@ -13,8 +14,6 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 5: Metrics', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; @@ -22,22 +21,26 @@ describe('Create Rollup Job, step 5: Metrics', () => { let goToStep; let table; let metrics; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, metrics } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); + }); + const numericFields = ['a-numericField', 'c-numericField']; const dateFields = ['b-dateField', 'd-dateField']; @@ -109,7 +112,7 @@ describe('Create Rollup Job, step 5: Metrics', () => { describe('table', () => { beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields, dateFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); await goToStepAndOpenFieldChooser(); }); @@ -166,7 +169,7 @@ describe('Create Rollup Job, step 5: Metrics', () => { describe('when fields are added', () => { beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields, dateFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); await goToStepAndOpenFieldChooser(); }); @@ -257,7 +260,8 @@ describe('Create Rollup Job, step 5: Metrics', () => { let getFieldListTableRows; beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields, dateFields }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); + await goToStep(5); await addFieldToList('numeric'); await addFieldToList('date'); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js index d7bc5416263fe..0fa9509368d3f 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js @@ -4,8 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers } from './helpers'; +import { pageHelpers, mockHttpRequest } from './helpers'; import { first } from 'lodash'; +import { setHttp } from '../../public/crud_app/services'; import { JOBS } from './helpers/constants'; jest.mock('ui/new_platform'); @@ -15,8 +16,6 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 6: Review', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; @@ -24,21 +23,25 @@ describe('Create Rollup Job, step 6: Review', () => { let goToStep; let table; let form; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, form } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + npStart.core.http.post.mockClear(); + npStart.core.http.put.mockClear(); + }); + describe('layout', () => { beforeEach(async () => { await goToStep(6); @@ -81,7 +84,7 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Terms" & "Request" tab if a term aggregation was added', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: ['my-field'] }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: ['my-field'] } }); await goToStep(3); selectFirstField('Terms'); @@ -93,7 +96,7 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Histogram" & "Request" tab if a histogram field was added', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: ['a-field'] }); + mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: ['a-field'] } }); await goToStep(4); selectFirstField('Histogram'); form.setInputValue('rollupJobCreateHistogramInterval', 3); // set an interval @@ -105,9 +108,11 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Metrics" & "Request" tab if a histogram field was added', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ - numericFields: ['a-field'], - dateFields: ['b-field'], + mockHttpRequest(npStart.core.http, { + indxPatternVldtResp: { + numericFields: ['a-field'], + dateFields: ['b-field'], + }, }); await goToStep(5); selectFirstField('Metrics'); @@ -125,27 +130,30 @@ describe('Create Rollup Job, step 6: Review', () => { describe('without starting job after creation', () => { it('should call the "create" Api server endpoint', async () => { - httpRequestsMockHelpers.setCreateJobResponse(first(JOBS.jobs)); + mockHttpRequest(npStart.core.http, { + createdJob: first(JOBS.jobs), + }); await goToStep(6); - expect(server.requests.find(r => r.url === jobCreateApiPath)).toBe(undefined); // make sure it hasn't been called - expect(server.requests.find(r => r.url === jobStartApiPath)).toBe(undefined); // make sure it hasn't been called + expect(npStart.core.http.put).not.toHaveBeenCalledWith(jobCreateApiPath); // make sure it hasn't been called + expect(npStart.core.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called actions.clickSave(); // Given the following anti-jitter sleep x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js // we add a longer sleep here :( await new Promise(res => setTimeout(res, 750)); - expect(server.requests.find(r => r.url === jobCreateApiPath)).not.toBe(undefined); // It has been called! - expect(server.requests.find(r => r.url === jobStartApiPath)).toBe(undefined); // It has still not been called! + expect(npStart.core.http.put).toHaveBeenCalledWith(jobCreateApiPath, expect.anything()); // It has been called! + expect(npStart.core.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // It has still not been called! }); }); describe('with starting job after creation', () => { it('should call the "create" and "start" Api server endpoints', async () => { - httpRequestsMockHelpers.setCreateJobResponse(first(JOBS.jobs)); - httpRequestsMockHelpers.setStartJobResponse(); + mockHttpRequest(npStart.core.http, { + createdJob: first(JOBS.jobs), + }); await goToStep(6); @@ -153,14 +161,14 @@ describe('Create Rollup Job, step 6: Review', () => { target: { checked: true }, }); - expect(server.requests.find(r => r.url === jobStartApiPath)).toBe(undefined); // make sure it hasn't been called + expect(npStart.core.http.post).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called actions.clickSave(); // Given the following anti-jitter sleep x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js // we add a longer sleep here :( await new Promise(res => setTimeout(res, 750)); - expect(server.requests.find(r => r.url === jobStartApiPath)).not.toBe(undefined); // It has been called! + expect(npStart.core.http.post).toHaveBeenCalledWith(jobStartApiPath, expect.anything()); // It has been called! }); }); }); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js index d3a0aaa08e148..f111a7df2c250 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers } from './helpers'; +import { setHttp } from '../../public/crud_app/services'; +import { pageHelpers, mockHttpRequest } from './helpers'; jest.mock('ui/new_platform'); @@ -13,30 +14,30 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 3: Terms', () => { - let server; - let httpRequestsMockHelpers; let find; let exists; let actions; let getEuiStepsHorizontalActive; let goToStep; let table; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - httpRequestsMockHelpers.setIndexPatternValidityResponse(); + mockHttpRequest(npStart.core.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table } = setup()); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + }); + const numericFields = ['a-numericField', 'c-numericField']; const keywordFields = ['b-keywordField', 'd-keywordField']; @@ -108,9 +109,11 @@ describe('Create Rollup Job, step 3: Terms', () => { describe('when no terms are available', () => { it('should indicate it to the user', async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ - numericFields: [], - keywordFields: [], + mockHttpRequest(npStart.core.http, { + indxPatternVldtResp: { + numericFields: [], + keywordFields: [], + }, }); await goToStepAndOpenFieldChooser(); @@ -122,7 +125,12 @@ describe('Create Rollup Job, step 3: Terms', () => { describe('when terms are available', () => { beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields, keywordFields }); + mockHttpRequest(npStart.core.http, { + indxPatternVldtResp: { + numericFields, + keywordFields, + }, + }); await goToStepAndOpenFieldChooser(); }); @@ -163,7 +171,12 @@ describe('Create Rollup Job, step 3: Terms', () => { it('should have a delete button on each row to remove a term', async () => { // First let's add a term to the list - httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields, keywordFields }); + mockHttpRequest(npStart.core.http, { + indxPatternVldtResp: { + numericFields, + keywordFields, + }, + }); await goToStepAndOpenFieldChooser(); const { rows: fieldChooserRows } = table.getMetaData('rollupJobTermsFieldChooser-table'); fieldChooserRows[0].reactWrapper.simulate('click'); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js index 16cb41bc76677..a9e474cf0b559 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRouter } from '../../public/crud_app/services'; -import { setupEnvironment, pageHelpers, nextTick } from './helpers'; +import { getRouter, setHttp } from '../../public/crud_app/services'; +import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOBS } from './helpers/constants'; jest.mock('ui/new_platform'); @@ -22,22 +22,18 @@ const { setup } = pageHelpers.jobList; describe('', () => { describe('detail panel', () => { - let server; - let httpRequestsMockHelpers; let component; let table; let exists; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(async () => { - httpRequestsMockHelpers.setLoadJobsResponse(JOBS); + mockHttpRequest(npStart.core.http, { jobs: JOBS }); ({ component, exists, table } = setup()); @@ -45,6 +41,10 @@ describe('', () => { component.update(); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + }); + test('should open the detail panel when clicking on a job in the table', () => { const { rows } = table.getMetaData('rollupJobsListTable'); const button = rows[0].columns[1].reactWrapper.find('button'); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js index 6feabe7f772ee..8a36af83def4c 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js @@ -4,9 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setupEnvironment, pageHelpers, nextTick } from './helpers'; +import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants'; import { getRouter } from '../../public/crud_app/services/routing'; +import { setHttp } from '../../public/crud_app/services'; import { CRUD_APP_BASE_PATH } from '../../public/crud_app/constants'; jest.mock('ui/new_platform'); @@ -16,24 +17,22 @@ jest.mock('lodash/function/debounce', () => fn => fn); const { setup } = pageHelpers.jobList; describe('Smoke test cloning an existing rollup job from job list', () => { - let server; - let httpRequestsMockHelpers; let table; let find; let component; let exists; + let npStart; beforeAll(() => { - ({ server, httpRequestsMockHelpers } = setupEnvironment()); - }); - - afterAll(() => { - server.restore(); + npStart = require('ui/new_platform').npStart; // eslint-disable-line + setHttp(npStart.core.http); }); beforeEach(async () => { - httpRequestsMockHelpers.setIndexPatternValidityResponse(JOB_CLONE_INDEX_PATTERN_CHECK); - httpRequestsMockHelpers.setLoadJobsResponse(JOB_TO_CLONE); + mockHttpRequest(npStart.core.http, { + jobs: JOB_TO_CLONE, + indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK, + }); ({ find, exists, table, component } = setup()); @@ -41,6 +40,10 @@ describe('Smoke test cloning an existing rollup job from job list', () => { component.update(); }); + afterEach(() => { + npStart.core.http.get.mockClear(); + }); + it('should navigate to create view with default values set', async () => { const router = getRouter(); const { rows } = table.getMetaData('rollupJobsListTable'); diff --git a/x-pack/legacy/plugins/rollup/common/index.js b/x-pack/legacy/plugins/rollup/common/index.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/common/index.js rename to x-pack/legacy/plugins/rollup/common/index.ts diff --git a/x-pack/legacy/plugins/rollup/common/ui_metric.js b/x-pack/legacy/plugins/rollup/common/ui_metric.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/common/ui_metric.js rename to x-pack/legacy/plugins/rollup/common/ui_metric.ts diff --git a/x-pack/legacy/plugins/rollup/index.js b/x-pack/legacy/plugins/rollup/index.js index f4210435abc09..cace3bba1592b 100644 --- a/x-pack/legacy/plugins/rollup/index.js +++ b/x-pack/legacy/plugins/rollup/index.js @@ -26,7 +26,7 @@ export function rollup(kibana) { require: ['kibana', 'elasticsearch', 'xpack_main'], uiExports: { styleSheetPaths: resolve(__dirname, 'public/index.scss'), - managementSections: ['plugins/rollup/crud_app'], + managementSections: ['plugins/rollup/legacy'], uiSettingDefaults: { [CONFIG_ROLLUPS]: { name: i18n.translate('xpack.rollupJobs.rollupIndexPatternsTitle', { @@ -41,13 +41,9 @@ export function rollup(kibana) { category: ['rollups'], }, }, - indexManagement: [ - 'plugins/rollup/index_pattern_creation', - 'plugins/rollup/index_pattern_list', - 'plugins/rollup/extend_index_management', - ], - visualize: ['plugins/rollup/visualize'], - search: ['plugins/rollup/search'], + indexManagement: ['plugins/rollup/legacy'], + visualize: ['plugins/rollup/legacy'], + search: ['plugins/rollup/legacy'], }, init: function(server) { const { usageCollection } = server.newPlatform.setup.plugins; @@ -64,7 +60,7 @@ export function rollup(kibana) { server.plugins.index_management.addIndexManagementDataEnricher(rollupDataEnricher); } - registerRollupSearchStrategy(this.kbnServer, server); + registerRollupSearchStrategy(this.kbnServer); }, }); } diff --git a/x-pack/legacy/plugins/rollup/public/application.tsx b/x-pack/legacy/plugins/rollup/public/application.tsx new file mode 100644 index 0000000000000..df17d37bc3465 --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/application.tsx @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { render, unmountComponentAtNode } from 'react-dom'; +import { Provider } from 'react-redux'; +import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; +import { ChromeBreadcrumb, CoreSetup } from '../../../../../src/core/public'; +// @ts-ignore +import { rollupJobsStore } from './crud_app/store'; +// @ts-ignore +import { App } from './crud_app/app'; + +/** + * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. + */ +export const renderApp = async ( + core: CoreSetup, + { + element, + setBreadcrumbs, + }: { element: HTMLElement; setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void } +) => { + const [coreStart] = await core.getStartServices(); + const I18nContext = coreStart.i18n.Context; + + render( + + + + + + + , + element + ); + return () => { + unmountComponentAtNode(element); + }; +}; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss b/x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss index e1166d0942a5c..9e3bd491115ce 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss +++ b/x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss @@ -5,10 +5,6 @@ align-items: flex-end; /* 1 */ } -.rollupJobsRoot { - display: flex; -} - /** * 1. Ensure panel fills width of parent when search input yields no matching rollup jobs. */ diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/index.js b/x-pack/legacy/plugins/rollup/public/crud_app/index.js deleted file mode 100644 index 82bbb90d2e33c..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/crud_app/index.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { - FeatureCatalogueRegistryProvider, - FeatureCatalogueCategory, -} from 'ui/registry/feature_catalogue'; -import { render, unmountComponentAtNode } from 'react-dom'; -import { Provider } from 'react-redux'; -import { i18n } from '@kbn/i18n'; -import { I18nContext } from 'ui/i18n'; -import { management } from 'ui/management'; -import routes from 'ui/routes'; - -import { CRUD_APP_BASE_PATH } from './constants'; -import { setHttp, setUserHasLeftApp } from './services'; -import { App } from './app'; -import template from './main.html'; -import { rollupJobsStore } from './store'; - -const esSection = management.getSection('elasticsearch'); - -esSection.register('rollup_jobs', { - visible: true, - display: i18n.translate('xpack.rollupJobs.appTitle', { defaultMessage: 'Rollup Jobs' }), - order: 3, - url: `#${CRUD_APP_BASE_PATH}/job_list`, -}); - -const renderReact = async elem => { - render( - - - - - , - elem - ); -}; - -routes.when(`${CRUD_APP_BASE_PATH}/:view?`, { - template: template, - controllerAs: 'rollupJobs', - controller: class IndexRollupJobsController { - constructor($scope, $route, $injector) { - // NOTE: We depend upon Angular's $http service because it's decorated with interceptors, - // e.g. to check license status per request. - setHttp($injector.get('$http')); - - // If returning to the app, we'll need to reset this state. - setUserHasLeftApp(false); - - $scope.$$postDigest(() => { - const appElement = document.getElementById('rollupJobsReactRoot'); - renderReact(appElement); - - const appRoute = $route.current; - const stopListeningForLocationChange = $scope.$on('$locationChangeSuccess', () => { - const currentRoute = $route.current; - - const isNavigationInApp = currentRoute.$$route.template === appRoute.$$route.template; - - // When we navigate within rollups, prevent Angular from re-matching the route and - // rebuilding the app. - if (isNavigationInApp) { - $route.current = appRoute; - } else { - // Set internal flag so we can prevent reacting to the route change internally. - setUserHasLeftApp(true); - } - }); - - $scope.$on('$destroy', () => { - stopListeningForLocationChange(); - unmountComponentAtNode(appElement); - }); - }); - } - }, -}); - -FeatureCatalogueRegistryProvider.register(() => { - return { - id: 'rollup_jobs', - title: 'Rollups', - description: i18n.translate('xpack.rollupJobs.featureCatalogueDescription', { - defaultMessage: 'Summarize and store historical data in a smaller index for future analysis.', - }), - icon: 'indexRollupApp', - path: `#${CRUD_APP_BASE_PATH}/job_list`, - showOnHomePage: true, - category: FeatureCatalogueCategory.ADMIN, - }; -}); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/main.html b/x-pack/legacy/plugins/rollup/public/crud_app/main.html deleted file mode 100644 index 2956d157e784c..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/crud_app/main.html +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js index 183a3765e1fd9..de1bee29aed4d 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js @@ -6,11 +6,12 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui'; -class ConfirmDeleteModalUi extends Component { +export class ConfirmDeleteModal extends Component { static propTypes = { isSingleSelection: PropTypes.bool.isRequired, jobs: PropTypes.array.isRequired, @@ -19,12 +20,14 @@ class ConfirmDeleteModalUi extends Component { }; renderJobs() { - const { jobs, intl } = this.props; + const { jobs } = this.props; const jobItems = jobs.map(({ id, status }) => { - const startedMessage = intl.formatMessage({ - id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.startedMessage', - defaultMessage: 'started', - }); + const startedMessage = i18n.translate( + 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.startedMessage', + { + defaultMessage: 'started', + } + ); const statusText = status === 'started' ? ` (${startedMessage})` : null; return (
  • @@ -38,19 +41,19 @@ class ConfirmDeleteModalUi extends Component { } render() { - const { isSingleSelection, jobs, onCancel, onConfirm, intl } = this.props; + const { isSingleSelection, jobs, onCancel, onConfirm } = this.props; let title; let content; if (isSingleSelection) { const { id, status } = jobs[0]; - title = intl.formatMessage( + title = i18n.translate( + 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.deleteSingleJobTitle', { - id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.deleteSingleJobTitle', defaultMessage: "Delete rollup job '{id}'?", - }, - { id } + values: { id }, + } ); if (status === 'started') { @@ -64,12 +67,12 @@ class ConfirmDeleteModalUi extends Component { ); } } else { - title = intl.formatMessage( + title = i18n.translate( + 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.multipleDeletionTitle', { - id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.multipleDeletionTitle', defaultMessage: 'Delete {count} rollup jobs?', - }, - { count: jobs.length } + values: { count: jobs.length }, + } ); content = ( @@ -92,15 +95,19 @@ class ConfirmDeleteModalUi extends Component { title={title} onCancel={onCancel} onConfirm={onConfirm} - cancelButtonText={intl.formatMessage({ - id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.cancelButtonText', - defaultMessage: 'Cancel', - })} + cancelButtonText={i18n.translate( + 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.cancelButtonText', + { + defaultMessage: 'Cancel', + } + )} buttonColor="danger" - confirmButtonText={intl.formatMessage({ - id: 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.confirmButtonText', - defaultMessage: 'Delete', - })} + confirmButtonText={i18n.translate( + 'xpack.rollupJobs.jobActionMenu.deleteJob.confirmModal.confirmButtonText', + { + defaultMessage: 'Delete', + } + )} > {content} @@ -108,5 +115,3 @@ class ConfirmDeleteModalUi extends Component { ); } } - -export const ConfirmDeleteModal = injectI18n(ConfirmDeleteModalUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js index a8e921973efc0..5379778c77e2f 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js @@ -12,9 +12,9 @@ import debounce from 'lodash/function/debounce'; import first from 'lodash/array/first'; import { i18n } from '@kbn/i18n'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; -import chrome from 'ui/chrome'; -import { MANAGEMENT_BREADCRUMB } from 'ui/management'; +import { FormattedMessage } from '@kbn/i18n/react'; + +import { withKibana } from '../../../../../../../../src/plugins/kibana_react/public/'; import { EuiCallOut, @@ -27,8 +27,6 @@ import { EuiTitle, } from '@elastic/eui'; -import { fatalError } from 'ui/notify'; - import { validateIndexPattern, formatFields, @@ -59,6 +57,8 @@ import { hasErrors, } from './steps_config'; +import { getFatalErrors } from '../../../kibana_services'; + const stepIdToTitleMap = { [STEP_LOGISTICS]: i18n.translate('xpack.rollupJobs.create.steps.stepLogisticsTitle', { defaultMessage: 'Logistics', @@ -92,7 +92,7 @@ export class JobCreateUi extends Component { constructor(props) { super(props); - chrome.breadcrumbs.set([MANAGEMENT_BREADCRUMB, listBreadcrumb, createBreadcrumb]); + props.kibana.services.setBreadcrumbs([listBreadcrumb, createBreadcrumb]); const { jobToClone: stepDefaultOverrides } = props; const stepsFields = mapValues(stepIdToStepConfigMap, step => cloneDeep(step.getDefaultFields(stepDefaultOverrides)) @@ -181,7 +181,7 @@ export class JobCreateUi extends Component { dateFields: indexPatternDateFields, numericFields, keywordFields, - } = response.data; + } = response; let indexPatternAsyncErrors; @@ -298,9 +298,9 @@ export class JobCreateUi extends Component { return; } - // Expect an error in the shape provided by Angular's $http service. - if (error && error.data) { - const { error: errorString, statusCode } = error.data; + // Expect an error in the shape provided by http service. + if (error && error.body) { + const { error: errorString, statusCode } = error.body; const indexPatternAsyncErrors = [ ({ text: name, })); -export class StepDateHistogramUi extends Component { +export class StepDateHistogram extends Component { static propTypes = { fields: PropTypes.object.isRequired, onFieldsChange: PropTypes.func.isRequired, @@ -192,7 +192,7 @@ export class StepDateHistogramUi extends Component { + ; }; } - -export const StepDateHistogram = injectI18n(StepDateHistogramUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js index 4c4019b3161a9..9307c9074e663 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js @@ -6,7 +6,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty, @@ -20,13 +20,13 @@ import { EuiTitle, } from '@elastic/eui'; -import { histogramDetailsUrl } from '../../../services'; +import { getHistogramDetailsUrl } from '../../../services'; import { FieldList } from '../../components'; import { FieldChooser, StepError } from './components'; -export class StepHistogramUi extends Component { +export class StepHistogram extends Component { static propTypes = { fields: PropTypes.object.isRequired, onFieldsChange: PropTypes.func.isRequired, @@ -96,7 +96,7 @@ export class StepHistogramUi extends Component { ; }; } - -export const StepHistogram = injectI18n(StepHistogramUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js index 8cba18804b1c6..024001d463240 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js @@ -6,7 +6,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty, @@ -26,8 +26,8 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor'; -import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; -import { logisticalDetailsUrl, cronUrl } from '../../../services'; +import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../legacy_imports'; +import { getLogisticalDetailsUrl, getCronUrl } from '../../../services'; import { StepError } from './components'; import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; @@ -35,7 +35,7 @@ import { indexPatterns } from '../../../../../../../../../src/plugins/data/publi const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' '); const indexIllegalCharacters = INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' '); -export class StepLogisticsUi extends Component { +export class StepLogistics extends Component { static propTypes = { fields: PropTypes.object.isRequired, onFieldsChange: PropTypes.func.isRequired, @@ -146,7 +146,7 @@ export class StepLogisticsUi extends Component { isInvalid={Boolean(areStepErrorsVisible && errorRollupCron)} helpText={

    - + ; }; } - -export const StepLogistics = injectI18n(StepLogisticsUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js index 5022754ec5faa..b71b6bfc805bf 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js @@ -6,7 +6,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import get from 'lodash/object/get'; @@ -22,7 +22,7 @@ import { EuiButton, } from '@elastic/eui'; -import { metricsDetailsUrl } from '../../../services'; +import { getMetricsDetailsUrl } from '../../../services'; import { FieldList } from '../../components'; import { FieldChooser, StepError } from './components'; import { METRICS_CONFIG } from '../../../constants'; @@ -64,7 +64,7 @@ const metricTypesConfig = (function() { }); })(); -export class StepMetricsUi extends Component { +export class StepMetrics extends Component { static propTypes = { fields: PropTypes.object.isRequired, onFieldsChange: PropTypes.func.isRequired, @@ -247,7 +247,7 @@ export class StepMetricsUi extends Component { } getListColumns() { - return StepMetricsUi.chooserColumns.concat({ + return StepMetrics.chooserColumns.concat({ type: 'metrics', name: i18n.translate('xpack.rollupJobs.create.stepMetrics.metricsColumnHeader', { defaultMessage: 'Metrics', @@ -384,7 +384,7 @@ export class StepMetricsUi extends Component { } - columns={StepMetricsUi.chooserColumns} + columns={StepMetrics.chooserColumns} fields={metricsFields} selectedFields={metrics} onSelectField={this.onSelectField} @@ -472,5 +472,3 @@ export class StepMetricsUi extends Component { }, ]; } - -export const StepMetrics = injectI18n(StepMetricsUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js index 19937732275a2..0097792db3105 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js @@ -6,7 +6,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiErrorBoundary, EuiSpacer, EuiTab, EuiTabs, EuiTitle } from '@elastic/eui'; @@ -30,7 +30,7 @@ const JOB_DETAILS_TABS = [ JOB_DETAILS_TAB_REQUEST, ]; -export class StepReviewUi extends Component { +export class StepReview extends Component { static propTypes = { job: PropTypes.object.isRequired, }; @@ -121,5 +121,3 @@ export class StepReviewUi extends Component { ); } } - -export const StepReview = injectI18n(StepReviewUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js index cd3c6cc5127f1..48e045e19f478 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js @@ -6,7 +6,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty, @@ -17,13 +17,13 @@ import { EuiTitle, } from '@elastic/eui'; -import { termsDetailsUrl } from '../../../services'; +import { getTermsDetailsUrl } from '../../../services'; import { FieldList } from '../../components'; import { FieldChooser } from './components'; -export class StepTermsUi extends Component { +export class StepTerms extends Component { static propTypes = { fields: PropTypes.object.isRequired, onFieldsChange: PropTypes.func.isRequired, @@ -99,7 +99,7 @@ export class StepTermsUi extends Component { @@ -251,5 +251,3 @@ export class DetailPanelUi extends Component { ); } } - -export const DetailPanel = injectI18n(DetailPanelUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js index 39153cda1f99d..9ac8e6075e4cf 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js @@ -58,12 +58,12 @@ describe('', () => { }); it("should have children if it's open", () => { - expect(component.find('DetailPanelUi').children().length).toBeTruthy(); + expect(component.find('DetailPanel').children().length).toBeTruthy(); }); it('should *not* have children if its closed', () => { ({ component } = initTestBed({ isOpen: false })); - expect(component.find('DetailPanelUi').children().length).toBeFalsy(); + expect(component.find('DetailPanel').children().length).toBeFalsy(); }); it('should show a loading when the job is loading', () => { diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js index 035a53206c71d..98329a687217a 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js @@ -6,9 +6,8 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; -import chrome from 'ui/chrome'; -import { MANAGEMENT_BREADCRUMB } from 'ui/management'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; import { EuiButton, @@ -26,6 +25,8 @@ import { EuiCallOut, } from '@elastic/eui'; +import { withKibana } from '../../../../../../../../src/plugins/kibana_react/public/'; + import { CRUD_APP_BASE_PATH } from '../../constants'; import { getRouterLinkProps, extractQueryParams, listBreadcrumb } from '../../services'; @@ -67,7 +68,7 @@ export class JobListUi extends Component { props.loadJobs(); - chrome.breadcrumbs.set([MANAGEMENT_BREADCRUMB, listBreadcrumb]); + props.kibana.services.setBreadcrumbs([listBreadcrumb]); this.state = {}; } @@ -97,9 +98,7 @@ export class JobListUi extends Component { } renderNoPermission() { - const { intl } = this.props; - const title = intl.formatMessage({ - id: 'xpack.rollupJobs.jobList.noPermissionTitle', + const title = i18n.translate('xpack.rollupJobs.jobList.noPermissionTitle', { defaultMessage: 'Permission error', }); return ( @@ -122,13 +121,11 @@ export class JobListUi extends Component { } renderError(error) { - // We can safely depend upon the shape of this error coming from Angular $http, because we + // We can safely depend upon the shape of this error coming from http service, because we // handle unexpected error shapes in the API action. - const { statusCode, error: errorString } = error.data; + const { statusCode, error: errorString } = error.body; - const { intl } = this.props; - const title = intl.formatMessage({ - id: 'xpack.rollupJobs.jobList.loadingErrorTitle', + const title = i18n.translate('xpack.rollupJobs.jobList.loadingErrorTitle', { defaultMessage: 'Error loading rollup jobs', }); return ( @@ -254,4 +251,4 @@ export class JobListUi extends Component { } } -export const JobList = injectI18n(JobListUi); +export const JobList = withKibana(JobListUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js index 5c7d53efbd62c..725789fc584de 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js @@ -4,24 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ +import React from 'react'; import { registerTestBed } from '../../../../../../../test_utils'; import { rollupJobsStore } from '../../store'; import { JobList } from './job_list'; +import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; +import { coreMock } from '../../../../../../../../src/core/public/mocks'; +const startMock = coreMock.createStart(); + jest.mock('ui/new_platform'); -jest.mock('ui/chrome', () => ({ - addBasePath: () => {}, - breadcrumbs: { set: () => {} }, - getInjected: key => { - if (key === 'uiCapabilities') { - return { - navLinks: {}, - management: {}, - catalogue: {}, - }; - } - }, -})); jest.mock('../../services', () => { const services = require.requireActual('../../services'); @@ -40,7 +32,16 @@ const defaultProps = { isLoading: false, }; -const initTestBed = registerTestBed(JobList, { defaultProps, store: rollupJobsStore }); +const services = { + setBreadcrumbs: startMock.chrome.setBreadcrumbs, +}; +const Component = props => ( + + + +); + +const initTestBed = registerTestBed(Component, { defaultProps, store: rollupJobsStore }); describe('', () => { it('should render empty prompt when loading is complete and there are no jobs', () => { @@ -53,21 +54,21 @@ describe('', () => { const { component, exists } = initTestBed({ isLoading: true }); expect(exists('jobListLoading')).toBeTruthy(); - expect(component.find('JobTableUi').length).toBeFalsy(); + expect(component.find('JobTable').length).toBeFalsy(); }); it('should display the when there are jobs', () => { const { component, exists } = initTestBed({ hasJobs: true }); expect(exists('jobListLoading')).toBeFalsy(); - expect(component.find('JobTableUi').length).toBeTruthy(); + expect(component.find('JobTable').length).toBeTruthy(); }); describe('when there is an API error', () => { const { exists, find } = initTestBed({ jobLoadError: { status: 400, - data: { statusCode: 400, error: 'Houston we got a problem.' }, + body: { statusCode: 400, error: 'Houston we got a problem.' }, }, }); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js index 42d48702a3385..4dbe396ab8410 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js @@ -7,7 +7,7 @@ import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import { i18n } from '@kbn/i18n'; -import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiCheckbox, @@ -120,7 +120,7 @@ const COLUMNS = [ }, ]; -export class JobTableUi extends Component { +export class JobTable extends Component { static propTypes = { jobs: PropTypes.array, pager: PropTypes.object.isRequired, @@ -333,7 +333,7 @@ export class JobTableUi extends Component { } render() { - const { filterChanged, filter, jobs, intl, closeDetailPanel } = this.props; + const { filterChanged, filter, jobs, closeDetailPanel } = this.props; const { idToSelectedJobMap } = this.state; @@ -360,8 +360,7 @@ export class JobTableUi extends Component { filterChanged(event.target.value); }} data-test-subj="jobTableFilterInput" - placeholder={intl.formatMessage({ - id: 'xpack.rollupJobs.jobTable.searchInputPlaceholder', + placeholder={i18n.translate('xpack.rollupJobs.jobTable.searchInputPlaceholder', { defaultMessage: 'Search', })} aria-label="Search jobs" @@ -405,5 +404,3 @@ export class JobTableUi extends Component { ); } } - -export const JobTable = injectI18n(JobTableUi); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/api.js b/x-pack/legacy/plugins/rollup/public/crud_app/services/api.js index e712415f9568d..8f95561b72d1d 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/api.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/services/api.js @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import chrome from 'ui/chrome'; import { UIM_JOB_CREATE, UIM_JOB_DELETE, @@ -17,39 +16,45 @@ import { import { getHttp } from './http_provider'; import { trackUserRequest } from './track_ui_metric'; -const apiPrefix = chrome.addBasePath('/api/rollup'); +const apiPrefix = '/api/rollup'; export async function loadJobs() { - const { - data: { jobs }, - } = await getHttp().get(`${apiPrefix}/jobs`); + const { jobs } = await getHttp().get(`${apiPrefix}/jobs`); return jobs; } export async function startJobs(jobIds) { const body = { jobIds }; - const request = getHttp().post(`${apiPrefix}/start`, body); + const request = getHttp().post(`${apiPrefix}/start`, { + body: JSON.stringify(body), + }); const actionType = jobIds.length > 1 ? UIM_JOB_START_MANY : UIM_JOB_START; return await trackUserRequest(request, actionType); } export async function stopJobs(jobIds) { const body = { jobIds }; - const request = getHttp().post(`${apiPrefix}/stop`, body); + const request = getHttp().post(`${apiPrefix}/stop`, { + body: JSON.stringify(body), + }); const actionType = jobIds.length > 1 ? UIM_JOB_STOP_MANY : UIM_JOB_STOP; return await trackUserRequest(request, actionType); } export async function deleteJobs(jobIds) { const body = { jobIds }; - const request = getHttp().post(`${apiPrefix}/delete`, body); + const request = getHttp().post(`${apiPrefix}/delete`, { + body: JSON.stringify(body), + }); const actionType = jobIds.length > 1 ? UIM_JOB_DELETE_MANY : UIM_JOB_DELETE; return await trackUserRequest(request, actionType); } export async function createJob(job) { const body = { job }; - const request = getHttp().put(`${apiPrefix}/create`, body); + const request = getHttp().put(`${apiPrefix}/create`, { + body: JSON.stringify(body), + }); return await trackUserRequest(request, UIM_JOB_CREATE); } diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.js b/x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.ts similarity index 54% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.js rename to x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.ts index bacaf13405898..af9e1a16e4cc5 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fatalError, toastNotifications } from 'ui/notify'; +import { getNotifications, getFatalErrors } from '../../kibana_services'; -function createToastConfig(error, errorTitle) { - // Expect an error in the shape provided by Angular's $http service. - if (error && error.data) { - const { error: errorString, statusCode, message } = error.data; +function createToastConfig(error: any, errorTitle: string) { + // Expect an error in the shape provided by http service. + if (error && error.body) { + const { error: errorString, statusCode, message } = error.body; return { title: errorTitle, text: `${statusCode}: ${errorString}. ${message}`, @@ -17,26 +17,26 @@ function createToastConfig(error, errorTitle) { } } -export function showApiWarning(error, errorTitle) { +export function showApiWarning(error: any, errorTitle: string) { const toastConfig = createToastConfig(error, errorTitle); if (toastConfig) { - return toastNotifications.addWarning(toastConfig); + return getNotifications().toasts.addWarning(toastConfig); } // This error isn't an HTTP error, so let the fatal error screen tell the user something // unexpected happened. - return fatalError(error, errorTitle); + return getFatalErrors().add(error, errorTitle); } -export function showApiError(error, errorTitle) { +export function showApiError(error: any, errorTitle: string) { const toastConfig = createToastConfig(error, errorTitle); if (toastConfig) { - return toastNotifications.addDanger(toastConfig); + return getNotifications().toasts.addDanger(toastConfig); } // This error isn't an HTTP error, so let the fatal error screen tell the user something // unexpected happened. - fatalError(error, errorTitle); + getFatalErrors().add(error, errorTitle); } diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js b/x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js index 7616d8bc179c0..ce42b26cc3e86 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js @@ -4,16 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links'; +let esBase = ''; +let xPackBase = ''; -const esBase = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}`; -const xPackBase = `${ELASTIC_WEBSITE_URL}guide/en/x-pack/${DOC_LINK_VERSION}`; +export function setEsBaseAndXPackBase(elasticWebsiteUrl, docLinksVersion) { + esBase = `${elasticWebsiteUrl}guide/en/elasticsearch/reference/${docLinksVersion}`; + xPackBase = `${elasticWebsiteUrl}guide/en/x-pack/${docLinksVersion}`; +} -export const logisticalDetailsUrl = `${esBase}/rollup-job-config.html#_logistical_details`; -export const dateHistogramDetailsUrl = `${esBase}/rollup-job-config.html#_date_histogram_2`; -export const termsDetailsUrl = `${esBase}/rollup-job-config.html#_terms_2`; -export const histogramDetailsUrl = `${esBase}/rollup-job-config.html#_histogram_2`; -export const metricsDetailsUrl = `${esBase}/rollup-job-config.html#rollup-metrics-config`; +export const getLogisticalDetailsUrl = () => `${esBase}/rollup-job-config.html#_logistical_details`; +export const getDateHistogramDetailsUrl = () => + `${esBase}/rollup-job-config.html#_date_histogram_2`; +export const getTermsDetailsUrl = () => `${esBase}/rollup-job-config.html#_terms_2`; +export const getHistogramDetailsUrl = () => `${esBase}/rollup-job-config.html#_histogram_2`; +export const getMetricsDetailsUrl = () => `${esBase}/rollup-job-config.html#rollup-metrics-config`; -export const dateHistogramAggregationUrl = `${esBase}/search-aggregations-bucket-datehistogram-aggregation.html`; -export const cronUrl = `${xPackBase}/trigger-schedule.html#_cron_expressions`; +export const getDateHistogramAggregationUrl = () => + `${esBase}/search-aggregations-bucket-datehistogram-aggregation.html`; +export const getCronUrl = () => `${xPackBase}/trigger-schedule.html#_cron_expressions`; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.js b/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts similarity index 61% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.js rename to x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts index 835a7bdc09d86..dd84328084d05 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts @@ -4,14 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -// This is an Angular service, which is why we use this provider pattern to access it within -// our React app. -let _http; +import { HttpStart } from 'src/core/public'; -export function setHttp(http) { +let _http: HttpStart | null = null; + +export function setHttp(http: HttpStart) { _http = http; } export function getHttp() { + if (!_http) { + throw new Error('Rollup http is not defined'); + } return _http; } diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js b/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js index 74ed8d8c325c0..790770b9b6a9f 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js @@ -11,13 +11,14 @@ export { showApiError, showApiWarning } from './api_errors'; export { listBreadcrumb, createBreadcrumb } from './breadcrumbs'; export { - logisticalDetailsUrl, - dateHistogramDetailsUrl, - dateHistogramAggregationUrl, - termsDetailsUrl, - histogramDetailsUrl, - metricsDetailsUrl, - cronUrl, + setEsBaseAndXPackBase, + getLogisticalDetailsUrl, + getDateHistogramDetailsUrl, + getDateHistogramAggregationUrl, + getTermsDetailsUrl, + getHistogramDetailsUrl, + getMetricsDetailsUrl, + getCronUrl, } from './documentation_links'; export { filterItems } from './filter_items'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js b/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js index 163860b7f24c6..c85b4c55f665e 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js @@ -5,7 +5,6 @@ */ import { i18n } from '@kbn/i18n'; -import { fatalError } from 'ui/notify'; import { CRUD_APP_BASE_PATH } from '../../constants'; import { @@ -24,6 +23,8 @@ import { CLEAR_CREATE_JOB_ERRORS, } from '../action_types'; +import { getFatalErrors } from '../../../kibana_services'; + export const createJob = jobConfig => async dispatch => { dispatch({ type: CREATE_JOB_START, @@ -39,12 +40,13 @@ export const createJob = jobConfig => async dispatch => { ]); } catch (error) { if (error) { - const { statusCode, data } = error; + const { body } = error; + const statusCode = error.statusCode || (body && body.statusCode); - // Expect an error in the shape provided by Angular's $http service. - if (data) { + // Expect an error in the shape provided by http service. + if (body) { // Some errors have statusCode directly available but some are under a data property. - if ((statusCode || (data && data.statusCode)) === 409) { + if (statusCode === 409) { return dispatch({ type: CREATE_JOB_FAILURE, payload: { @@ -67,9 +69,9 @@ export const createJob = jobConfig => async dispatch => { error: { message: i18n.translate('xpack.rollupJobs.createAction.failedDefaultErrorMessage', { defaultMessage: 'Request failed with a {statusCode} error. {message}', - values: { statusCode, message: data.message }, + values: { statusCode, message: body.message }, }), - cause: data.cause, + cause: body.cause, }, }, }); @@ -78,7 +80,7 @@ export const createJob = jobConfig => async dispatch => { // This error isn't an HTTP error, so let the fatal error screen tell the user something // unexpected happened. - return fatalError( + return getFatalErrors().add( error, i18n.translate('xpack.rollupJobs.createAction.errorTitle', { defaultMessage: 'Error creating rollup job', @@ -86,7 +88,7 @@ export const createJob = jobConfig => async dispatch => { ); } - const deserializedJob = deserializeJob(newJob.data); + const deserializedJob = deserializeJob(newJob); dispatch({ type: CREATE_JOB_SUCCESS, diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js b/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js index d700ec69839be..0cfc8c24d46e9 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js @@ -5,7 +5,6 @@ */ import { i18n } from '@kbn/i18n'; -import { toastNotifications } from 'ui/notify'; import { deleteJobs as sendDeleteJobsRequest, @@ -19,6 +18,8 @@ import { UPDATE_JOB_START, UPDATE_JOB_SUCCESS, UPDATE_JOB_FAILURE } from '../act import { refreshJobs } from './refresh_jobs'; import { closeDetailPanel } from './detail_panel'; +import { getNotifications } from '../../../kibana_services'; + export const deleteJobs = jobIds => async (dispatch, getState) => { dispatch({ type: UPDATE_JOB_START, @@ -40,14 +41,14 @@ export const deleteJobs = jobIds => async (dispatch, getState) => { } if (jobIds.length === 1) { - toastNotifications.addSuccess( + getNotifications().toasts.addSuccess( i18n.translate('xpack.rollupJobs.deleteAction.successSingleNotificationTitle', { defaultMessage: `Rollup job '{jobId}' was deleted`, values: { jobId: jobIds[0] }, }) ); } else { - toastNotifications.addSuccess( + getNotifications().toasts.addSuccess( i18n.translate('xpack.rollupJobs.deleteAction.successMultipleNotificationTitle', { defaultMessage: '{count} rollup jobs were deleted', values: { count: jobIds.length }, diff --git a/x-pack/legacy/plugins/rollup/public/extend_index_management/index.js b/x-pack/legacy/plugins/rollup/public/extend_index_management/index.ts similarity index 76% rename from x-pack/legacy/plugins/rollup/public/extend_index_management/index.js rename to x-pack/legacy/plugins/rollup/public/extend_index_management/index.ts index 5e14d3eabc9a6..1a34811901bbe 100644 --- a/x-pack/legacy/plugins/rollup/public/extend_index_management/index.js +++ b/x-pack/legacy/plugins/rollup/public/extend_index_management/index.ts @@ -4,15 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ import { i18n } from '@kbn/i18n'; -import { - addToggleExtension, - addBadgeExtension, -} from '../../../index_management/public/index_management_extensions'; import { get } from 'lodash'; const propertyPath = 'isRollupIndex'; export const rollupToggleExtension = { - matchIndex: index => { + matchIndex: (index: { isRollupIndex: boolean }) => { return get(index, propertyPath); }, label: i18n.translate('xpack.rollupJobs.indexMgmtToggle.toggleLabel', { @@ -20,8 +16,9 @@ export const rollupToggleExtension = { }), name: 'rollupToggle', }; + export const rollupBadgeExtension = { - matchIndex: index => { + matchIndex: (index: { isRollupIndex: boolean }) => { return get(index, propertyPath); }, label: i18n.translate('xpack.rollupJobs.indexMgmtBadge.rollupLabel', { @@ -30,6 +27,3 @@ export const rollupBadgeExtension = { color: 'secondary', filterExpression: 'isRollupIndex:true', }; - -addBadgeExtension(rollupBadgeExtension); -addToggleExtension(rollupToggleExtension); diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/index.js b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/index.js deleted file mode 100644 index 1add469e073bd..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; - -import { initIndexPatternCreation } from './register'; -import { CONFIG_ROLLUPS } from '../../common'; - -const uiSettings = chrome.getUiSettingsClient(); -const isRollupIndexPatternsEnabled = uiSettings.get(CONFIG_ROLLUPS); - -if (isRollupIndexPatternsEnabled) { - initIndexPatternCreation(); -} diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/register.js b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/register.js deleted file mode 100644 index 9a3aed548dcc9..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/register.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { setup as managementSetup } from '../../../../../../src/legacy/core_plugins/management/public/legacy'; -import { RollupIndexPatternCreationConfig } from './rollup_index_pattern_creation_config'; - -export function initIndexPatternCreation() { - managementSetup.indexPattern.creation.add(RollupIndexPatternCreationConfig); -} diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js index 07f2a674decc5..82a4c5a888594 100644 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js +++ b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js @@ -6,10 +6,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { npSetup } from 'ui/new_platform'; import { RollupPrompt } from './components/rollup_prompt'; -import { setHttpClient, getRollupIndices } from '../services/api'; import { IndexPatternCreationConfig } from '../../../../../../src/legacy/core_plugins/management/public'; const rollupIndexPatternTypeName = i18n.translate( @@ -54,7 +52,6 @@ export class RollupIndexPatternCreationConfig extends IndexPatternCreationConfig ...options, }); - setHttpClient(this.httpClient); this.rollupIndex = null; this.rollupJobs = []; this.rollupIndicesCapabilities = {}; @@ -67,9 +64,10 @@ export class RollupIndexPatternCreationConfig extends IndexPatternCreationConfig // This is a hack intended to prevent the getRollupIndices() request from being sent if // we're on /logout. There is a race condition that can arise on that page, whereby this // request resolves after the logout request resolves, and un-clears the session ID. - const isAnonymous = npSetup.core.http.anonymousPaths.isAnonymous(window.location.pathname); + const isAnonymous = this.httpClient.anonymousPaths.isAnonymous(window.location.pathname); if (!isAnonymous) { - this.rollupIndicesCapabilities = await getRollupIndices(); + const response = await this.httpClient.get('/api/rollup/indices'); + this.rollupIndicesCapabilities = response || {}; } this.rollupIndices = Object.keys(this.rollupIndicesCapabilities); diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_list/index.js b/x-pack/legacy/plugins/rollup/public/index_pattern_list/index.js deleted file mode 100644 index 63a3149faaadb..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_list/index.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -import { initIndexPatternList } from './register'; -import { CONFIG_ROLLUPS } from '../../common'; - -const uiSettings = chrome.getUiSettingsClient(); -const isRollupIndexPatternsEnabled = uiSettings.get(CONFIG_ROLLUPS); - -if (isRollupIndexPatternsEnabled) { - initIndexPatternList(); -} diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_list/register.js b/x-pack/legacy/plugins/rollup/public/index_pattern_list/register.js deleted file mode 100644 index 173c28826436b..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_list/register.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { setup as managementSetup } from '../../../../../../src/legacy/core_plugins/management/public/legacy'; -import { RollupIndexPatternListConfig } from './rollup_index_pattern_list_config'; - -export function initIndexPatternList() { - managementSetup.indexPattern.list.add(RollupIndexPatternListConfig); -} diff --git a/x-pack/legacy/plugins/rollup/public/kibana_services.ts b/x-pack/legacy/plugins/rollup/public/kibana_services.ts new file mode 100644 index 0000000000000..335eeb90282ca --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/kibana_services.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { NotificationsStart, FatalErrorsSetup } from 'src/core/public'; + +let notifications: NotificationsStart | null = null; +let fatalErrors: FatalErrorsSetup | null = null; + +export function getNotifications() { + if (!notifications) { + throw new Error('Rollup notifications is not defined'); + } + return notifications; +} +export function setNotifications(newNotifications: NotificationsStart) { + notifications = newNotifications; +} + +export function getFatalErrors() { + if (!fatalErrors) { + throw new Error('Rollup fatalErrors is not defined'); + } + return fatalErrors; +} +export function setFatalErrors(newFatalErrors: FatalErrorsSetup) { + fatalErrors = newFatalErrors; +} diff --git a/x-pack/legacy/plugins/rollup/public/legacy.ts b/x-pack/legacy/plugins/rollup/public/legacy.ts new file mode 100644 index 0000000000000..a2738372ff346 --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/legacy.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { npSetup, npStart } from 'ui/new_platform'; +import { editorConfigProviders } from 'ui/vis/config'; +import { aggTypeFilters } from 'ui/agg_types/filter'; +import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; +import { addSearchStrategy } from '../../../../../src/plugins/data/public'; +import { RollupPlugin } from './plugin'; +import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy'; +import { addBadgeExtension, addToggleExtension } from '../../index_management/public'; + +const plugin = new RollupPlugin(); + +export const setup = plugin.setup(npSetup.core, { + ...npSetup.plugins, + __LEGACY: { + aggTypeFilters, + aggTypeFieldFilters, + editorConfigProviders, + addSearchStrategy, + addBadgeExtension, + addToggleExtension, + managementLegacy: management, + }, +}); +export const start = plugin.start(npStart.core); diff --git a/x-pack/legacy/plugins/rollup/public/legacy_imports.ts b/x-pack/legacy/plugins/rollup/public/legacy_imports.ts new file mode 100644 index 0000000000000..981f97963591e --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/legacy_imports.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// @ts-ignore +export { findIllegalCharactersInIndexName, INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; + +export { AggTypeFilters } from 'ui/agg_types/filter'; +export { AggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; +export { EditorConfigProviderRegistry } from 'ui/vis/config'; diff --git a/x-pack/legacy/plugins/rollup/public/plugin.ts b/x-pack/legacy/plugins/rollup/public/plugin.ts new file mode 100644 index 0000000000000..97c03fd1fdfc2 --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/plugin.ts @@ -0,0 +1,128 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { + EditorConfigProviderRegistry, + AggTypeFilters, + AggTypeFieldFilters, +} from './legacy_imports'; +import { SearchStrategyProvider } from '../../../../../src/plugins/data/public'; +import { ManagementSetup as ManagementSetupLegacy } from '../../../../../src/legacy/core_plugins/management/public/np_ready'; +import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management'; +// @ts-ignore +import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config'; +// @ts-ignore +import { RollupIndexPatternListConfig } from './index_pattern_list/rollup_index_pattern_list_config'; +import { getRollupSearchStrategy } from './search/rollup_search_strategy'; +// @ts-ignore +import { initAggTypeFilter } from './visualize/agg_type_filter'; +// @ts-ignore +import { initAggTypeFieldFilter } from './visualize/agg_type_field_filter'; +// @ts-ignore +import { initEditorConfig } from './visualize/editor_config'; +import { CONFIG_ROLLUPS } from '../common'; +import { + FeatureCatalogueCategory, + HomePublicPluginSetup, +} from '../../../../../src/plugins/home/public'; +// @ts-ignore +import { CRUD_APP_BASE_PATH } from './crud_app/constants'; +import { ManagementSetup } from '../../../../../src/plugins/management/public'; +// @ts-ignore +import { setEsBaseAndXPackBase, setHttp } from './crud_app/services'; +import { setNotifications, setFatalErrors } from './kibana_services'; +import { renderApp } from './application'; + +export interface RollupPluginSetupDependencies { + __LEGACY: { + aggTypeFilters: AggTypeFilters; + aggTypeFieldFilters: AggTypeFieldFilters; + editorConfigProviders: EditorConfigProviderRegistry; + addSearchStrategy: (searchStrategy: SearchStrategyProvider) => void; + managementLegacy: ManagementSetupLegacy; + addBadgeExtension: (badgeExtension: any) => void; + addToggleExtension: (toggleExtension: any) => void; + }; + home?: HomePublicPluginSetup; + management: ManagementSetup; +} + +export class RollupPlugin implements Plugin { + setup( + core: CoreSetup, + { + __LEGACY: { + aggTypeFilters, + aggTypeFieldFilters, + editorConfigProviders, + addSearchStrategy, + managementLegacy, + addBadgeExtension, + addToggleExtension, + }, + home, + management, + }: RollupPluginSetupDependencies + ) { + setFatalErrors(core.fatalErrors); + addBadgeExtension(rollupBadgeExtension); + addToggleExtension(rollupToggleExtension); + + const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS); + + if (isRollupIndexPatternsEnabled) { + managementLegacy.indexPattern.creation.add(RollupIndexPatternCreationConfig); + managementLegacy.indexPattern.list.add(RollupIndexPatternListConfig); + addSearchStrategy(getRollupSearchStrategy(core.http.fetch)); + initAggTypeFilter(aggTypeFilters); + initAggTypeFieldFilter(aggTypeFieldFilters); + initEditorConfig(editorConfigProviders); + } + + if (home) { + home.featureCatalogue.register({ + id: 'rollup_jobs', + title: 'Rollups', + description: i18n.translate('xpack.rollupJobs.featureCatalogueDescription', { + defaultMessage: + 'Summarize and store historical data in a smaller index for future analysis.', + }), + icon: 'indexRollupApp', + path: `#${CRUD_APP_BASE_PATH}/job_list`, + showOnHomePage: true, + category: FeatureCatalogueCategory.ADMIN, + }); + } + + const esSection = management.sections.getSection('elasticsearch'); + if (esSection) { + esSection.registerApp({ + id: 'rollup_jobs', + title: i18n.translate('xpack.rollupJobs.appTitle', { defaultMessage: 'Rollup Jobs' }), + order: 3, + mount(params) { + params.setBreadcrumbs([ + { + text: i18n.translate('xpack.rollupJobs.breadcrumbsTitle', { + defaultMessage: 'Rollup Jobs', + }), + }, + ]); + + return renderApp(core, params); + }, + }); + } + } + + start(core: CoreStart) { + setHttp(core.http); + setNotifications(core.notifications); + setEsBaseAndXPackBase(core.docLinks.ELASTIC_WEBSITE_URL, core.docLinks.DOC_LINK_VERSION); + } +} diff --git a/x-pack/legacy/plugins/rollup/public/search/index.js b/x-pack/legacy/plugins/rollup/public/search/index.js deleted file mode 100644 index e76ba4817d72c..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/search/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; - -import { initSearch } from './register'; -import { CONFIG_ROLLUPS } from '../../common'; - -const uiSettings = chrome.getUiSettingsClient(); -const isRollupIndexPatternsEnabled = uiSettings.get(CONFIG_ROLLUPS); - -if (isRollupIndexPatternsEnabled) { - initSearch(); -} diff --git a/x-pack/legacy/plugins/rollup/public/search/register.js b/x-pack/legacy/plugins/rollup/public/search/register.js deleted file mode 100644 index 05db100088e8a..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/search/register.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { addSearchStrategy } from '../../../../../../src/plugins/data/public'; -import { rollupSearchStrategy } from './rollup_search_strategy'; - -export function initSearch() { - addSearchStrategy(rollupSearchStrategy); -} diff --git a/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.js b/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts similarity index 74% rename from x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.js rename to x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts index 18e72cdf0fd3d..4709c0aa498f8 100644 --- a/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.js +++ b/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts @@ -4,10 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { kfetch } from 'ui/kfetch'; -import { SearchError, getSearchErrorType } from '../../../../../../src/plugins/data/public'; +import { HttpSetup } from 'src/core/public'; +import { + SearchError, + getSearchErrorType, + IIndexPattern, + SearchStrategyProvider, + SearchResponse, + SearchRequest, +} from '../../../../../../src/plugins/data/public'; -function serializeFetchParams(searchRequests) { +function serializeFetchParams(searchRequests: SearchRequest[]) { return JSON.stringify( searchRequests.map(searchRequestWithFetchParams => { const indexPattern = @@ -17,7 +24,7 @@ function serializeFetchParams(searchRequests) { } = searchRequestWithFetchParams; const query = { - size: size, + size, aggregations: aggs, query: _query, }; @@ -30,7 +37,7 @@ function serializeFetchParams(searchRequests) { // Rollup search always returns 0 hits, but visualizations expect search responses // to return hits > 0, otherwise they do not render. We fake the number of hits here // by counting the number of aggregation buckets/values returned by rollup search. -function shimHitsInFetchResponse(response) { +function shimHitsInFetchResponse(response: SearchResponse[]) { return response.map(result => { const buckets = result.aggregations ? Object.keys(result.aggregations).reduce((allBuckets, agg) => { @@ -51,17 +58,16 @@ function shimHitsInFetchResponse(response) { }); } -export const rollupSearchStrategy = { +export const getRollupSearchStrategy = (fetch: HttpSetup['fetch']): SearchStrategyProvider => ({ id: 'rollup', - search: ({ searchRequests, Promise }) => { + search: ({ searchRequests }) => { // Serialize the fetch params into a format suitable for the body of an ES query. const serializedFetchParams = serializeFetchParams(searchRequests); const controller = new AbortController(); - const promise = kfetch({ + const promise = fetch('../api/rollup/search', { signal: controller.signal, - pathname: '../api/rollup/search', method: 'POST', body: serializedFetchParams, }); @@ -69,17 +75,17 @@ export const rollupSearchStrategy = { return { searching: promise.then(shimHitsInFetchResponse).catch(error => { const { - body: { statusText, error: title, message }, + body: { statusCode, error: title, message }, res: { url }, } = error; - // Format kfetch error as a SearchError. + // Format fetch error as a SearchError. const searchError = new SearchError({ - status: statusText, + status: statusCode, title, message: `Rollup search error: ${message}`, path: url, - type: getSearchErrorType({ message }), + type: getSearchErrorType({ message }) || '', }); return Promise.reject(searchError); @@ -88,11 +94,11 @@ export const rollupSearchStrategy = { }; }, - isViable: indexPattern => { + isViable: (indexPattern: IIndexPattern) => { if (!indexPattern) { return false; } return indexPattern.type === 'rollup'; }, -}; +}); diff --git a/x-pack/legacy/plugins/rollup/public/services/api.js b/x-pack/legacy/plugins/rollup/public/services/api.js deleted file mode 100644 index ae9e8756c7efc..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/services/api.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -let httpClient; -export const setHttpClient = client => { - httpClient = client; -}; - -export async function getRollupIndices() { - const response = await httpClient.get('/api/rollup/indices'); - return response || {}; -} diff --git a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js b/x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js index 9d19dff648667..6f44e0ef90efd 100644 --- a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js +++ b/x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js @@ -4,9 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter'; - -export function initAggTypeFieldFilter() { +export function initAggTypeFieldFilter(aggTypeFieldFilters) { /** * If rollup index pattern, check its capabilities * and limit available fields for a given aggType based on that. diff --git a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js b/x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js index 75b11dac06cf5..5f9fab3061a19 100644 --- a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js +++ b/x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js @@ -4,9 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { aggTypeFilters } from 'ui/agg_types/filter'; - -export function initAggTypeFilter() { +export function initAggTypeFilter(aggTypeFilters) { /** * If rollup index pattern, check its capabilities * and limit available aggregations based on that. diff --git a/x-pack/legacy/plugins/rollup/public/visualize/editor_config.js b/x-pack/legacy/plugins/rollup/public/visualize/editor_config.js index 8f5072e8a9866..5c1eb7c8ee3b7 100644 --- a/x-pack/legacy/plugins/rollup/public/visualize/editor_config.js +++ b/x-pack/legacy/plugins/rollup/public/visualize/editor_config.js @@ -5,9 +5,8 @@ */ import { i18n } from '@kbn/i18n'; -import { editorConfigProviders } from 'ui/vis/config'; -export function initEditorConfig() { +export function initEditorConfig(editorConfigProviders) { // Limit agg params based on rollup capabilities editorConfigProviders.register((indexPattern, aggConfig) => { if (indexPattern.type !== 'rollup') { diff --git a/x-pack/legacy/plugins/rollup/public/visualize/index.js b/x-pack/legacy/plugins/rollup/public/visualize/index.js deleted file mode 100644 index e5a9c63c91a92..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/visualize/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; - -import { initAggTypeFilter } from './agg_type_filter'; -import { initAggTypeFieldFilter } from './agg_type_field_filter'; -import { initEditorConfig } from './editor_config'; -import { CONFIG_ROLLUPS } from '../../common'; - -const uiSettings = chrome.getUiSettingsClient(); -const isRollupIndexPatternsEnabled = uiSettings.get(CONFIG_ROLLUPS); - -if (isRollupIndexPatternsEnabled) { - initAggTypeFilter(); - initAggTypeFieldFilter(); - initEditorConfig(); -} diff --git a/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.js b/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.js index 537c5cf45ad61..284151d404a47 100644 --- a/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.js +++ b/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.js @@ -8,10 +8,10 @@ import { once } from 'lodash'; import { elasticsearchJsPlugin } from '../../client/elasticsearch_rollup'; const callWithRequest = once(server => { - const config = { plugins: [elasticsearchJsPlugin] }; - const cluster = server.plugins.elasticsearch.createCluster('rollup', config); - - return cluster.callWithRequest; + const client = server.newPlatform.setup.core.elasticsearch.createClient('rollup', { + plugins: [elasticsearchJsPlugin], + }); + return (request, ...args) => client.asScoped(request).callAsCurrentUser(...args); }); export const callWithRequestFactory = (server, request) => { diff --git a/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.js b/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.js index 5d732c8e7fbaa..fe65a7f1f30e9 100644 --- a/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.js +++ b/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.js @@ -6,19 +6,19 @@ import { getRollupSearchStrategy } from './rollup_search_strategy'; import { getRollupSearchRequest } from './rollup_search_request'; import { getRollupSearchCapabilities } from './rollup_search_capabilities'; +import { + AbstractSearchRequest, + DefaultSearchCapabilities, + AbstractSearchStrategy, +} from '../../../../../../../src/plugins/vis_type_timeseries/server'; -export const registerRollupSearchStrategy = (kbnServer, server) => +export const registerRollupSearchStrategy = kbnServer => kbnServer.afterPluginsInit(() => { - if (!server.plugins.metrics) { + if (!kbnServer.newPlatform.setup.plugins.metrics) { return; } - const { - addSearchStrategy, - AbstractSearchRequest, - AbstractSearchStrategy, - DefaultSearchCapabilities, - } = server.plugins.metrics; + const { addSearchStrategy } = kbnServer.newPlatform.setup.plugins.metrics; const RollupSearchRequest = getRollupSearchRequest(AbstractSearchRequest); const RollupSearchCapabilities = getRollupSearchCapabilities(DefaultSearchCapabilities); @@ -28,5 +28,5 @@ export const registerRollupSearchStrategy = (kbnServer, server) => RollupSearchCapabilities ); - addSearchStrategy(new RollupSearchStrategy(server)); + addSearchStrategy(new RollupSearchStrategy(kbnServer)); }); diff --git a/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.test.js b/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.test.js index 5a1e4f27b1453..acd016d75f97e 100644 --- a/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.test.js +++ b/x-pack/legacy/plugins/rollup/server/lib/search_strategies/register_rollup_search_strategy.test.js @@ -14,6 +14,9 @@ describe('Register Rollup Search Strategy', () => { kbnServer = { afterPluginsInit, + newPlatform: { + setup: { plugins: {} }, + }, }; metrics = { @@ -25,27 +28,22 @@ describe('Register Rollup Search Strategy', () => { }); test('should run initialization on "afterPluginsInit" hook', () => { - registerRollupSearchStrategy(kbnServer, { - plugins: {}, - }); + registerRollupSearchStrategy(kbnServer); expect(kbnServer.afterPluginsInit).toHaveBeenCalled(); }); test('should run initialization if metrics plugin available', () => { - registerRollupSearchStrategy(kbnServer, { - plugins: { - metrics, - }, + registerRollupSearchStrategy({ + ...kbnServer, + newPlatform: { setup: { plugins: { metrics } } }, }); expect(metrics.addSearchStrategy).toHaveBeenCalled(); }); test('should not run initialization if metrics plugin unavailable', () => { - registerRollupSearchStrategy(kbnServer, { - plugins: {}, - }); + registerRollupSearchStrategy(kbnServer); expect(metrics.addSearchStrategy).not.toHaveBeenCalled(); }); diff --git a/x-pack/legacy/plugins/siem/public/components/link_to/redirect_to_detection_engine.tsx b/x-pack/legacy/plugins/siem/public/components/link_to/redirect_to_detection_engine.tsx index e4a6a799fdcf3..3701069389b72 100644 --- a/x-pack/legacy/plugins/siem/public/components/link_to/redirect_to_detection_engine.tsx +++ b/x-pack/legacy/plugins/siem/public/components/link_to/redirect_to_detection_engine.tsx @@ -57,9 +57,7 @@ export const RedirectToEditRulePage = ({ location: { search }, }: DetectionEngineComponentProps) => { return ( - + ); }; diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts index 6b3578bacf24c..8f4abeb31c226 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts @@ -217,6 +217,8 @@ export const duplicateRules = async ({ rules }: DuplicateRulesProps): Promise { if (field === 'queryBar') { - const filters = addFilterStateIfNotThere(get('queryBar.filters', value)); + const filters = addFilterStateIfNotThere(get('queryBar.filters', value) ?? []); const query = get('queryBar.query', value) as Query; const savedId = get('queryBar.saved_id', value); return buildQueryBarDescription({ diff --git a/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts b/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts index 296df279b8eec..7f5699eb7e8a4 100644 --- a/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts +++ b/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts @@ -4,14 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HistogramDataPoint } from '../graphql/types'; - export interface UMGqlRange { dateRangeStart: string; dateRangeEnd: string; } - -export interface HistogramResult { - histogram: HistogramDataPoint[]; - interval: number; -} diff --git a/x-pack/legacy/plugins/uptime/common/graphql/introspection.json b/x-pack/legacy/plugins/uptime/common/graphql/introspection.json index 19d9cf19cc7f8..e5d9816ebd28e 100644 --- a/x-pack/legacy/plugins/uptime/common/graphql/introspection.json +++ b/x-pack/legacy/plugins/uptime/common/graphql/introspection.json @@ -166,65 +166,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "getSnapshotHistogram", - "description": "", - "args": [ - { - "name": "dateRangeStart", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { "kind": "SCALAR", "name": "String", "ofType": null } - }, - "defaultValue": null - }, - { - "name": "dateRangeEnd", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { "kind": "SCALAR", "name": "String", "ofType": null } - }, - "defaultValue": null - }, - { - "name": "filters", - "description": "", - "type": { "kind": "SCALAR", "name": "String", "ofType": null }, - "defaultValue": null - }, - { - "name": "statusFilter", - "description": "", - "type": { "kind": "SCALAR", "name": "String", "ofType": null }, - "defaultValue": null - }, - { - "name": "monitorId", - "description": "", - "type": { "kind": "SCALAR", "name": "String", "ofType": null }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { "kind": "OBJECT", "name": "HistogramDataPoint", "ofType": null } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "getMonitorChartsData", "description": "", @@ -2172,57 +2113,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "HistogramDataPoint", - "description": "", - "fields": [ - { - "name": "upCount", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "Int", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "downCount", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "Int", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "x", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "x0", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "y", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "MonitorChart", @@ -3944,33 +3834,6 @@ ], "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "DataPoint", - "description": "", - "fields": [ - { - "name": "x", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "y", - "description": "", - "args": [], - "type": { "kind": "SCALAR", "name": "Float", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "MonitorDurationAreaPoint", diff --git a/x-pack/legacy/plugins/uptime/common/graphql/types.ts b/x-pack/legacy/plugins/uptime/common/graphql/types.ts index 92e27d20323a7..c58dd9111cc3f 100644 --- a/x-pack/legacy/plugins/uptime/common/graphql/types.ts +++ b/x-pack/legacy/plugins/uptime/common/graphql/types.ts @@ -24,8 +24,6 @@ export interface Query { getSnapshot?: Snapshot | null; - getSnapshotHistogram: HistogramDataPoint[]; - getMonitorChartsData?: MonitorChart | null; /** Fetch the most recent event data for a monitor ID, date range, location. */ getLatestMonitors: Ping[]; @@ -419,17 +417,7 @@ export interface SnapshotCount { total: number; } -export interface HistogramDataPoint { - upCount?: number | null; - - downCount?: number | null; - - x?: UnsignedInteger | null; - - x0?: UnsignedInteger | null; - y?: UnsignedInteger | null; -} /** The data used to populate the monitor charts. */ export interface MonitorChart { /** The average values for the monitor duration. */ @@ -616,47 +604,6 @@ export interface StatesIndexStatus { docCount?: DocCount | null; } -export interface DataPoint { - x?: UnsignedInteger | null; - - y?: number | null; -} -/** Represents a monitor's duration performance in microseconds at a point in time. */ -export interface MonitorDurationAreaPoint { - /** The timeseries value for this point in time. */ - x: UnsignedInteger; - /** The min duration value in microseconds at this time. */ - yMin?: number | null; - /** The max duration value in microseconds at this point. */ - yMax?: number | null; -} - -export interface MonitorSummaryUrl { - domain?: string | null; - - fragment?: string | null; - - full?: string | null; - - original?: string | null; - - password?: string | null; - - path?: string | null; - - port?: number | null; - - query?: string | null; - - scheme?: string | null; - - username?: string | null; -} - -// ==================================================== -// Arguments -// ==================================================== - export interface AllPingsQueryArgs { /** Optional: the direction to sort by. Accepts 'asc' and 'desc'. Defaults to 'desc'. */ sort?: string | null; @@ -673,35 +620,7 @@ export interface AllPingsQueryArgs { /** Optional: agent location to filter by. */ location?: string | null; } -export interface GetMonitorsQueryArgs { - dateRangeStart: string; - - dateRangeEnd: string; - - filters?: string | null; - - statusFilter?: string | null; -} -export interface GetSnapshotQueryArgs { - dateRangeStart: string; - - dateRangeEnd: string; - - filters?: string | null; - statusFilter?: string | null; -} -export interface GetSnapshotHistogramQueryArgs { - dateRangeStart: string; - - dateRangeEnd: string; - - filters?: string | null; - - statusFilter?: string | null; - - monitorId?: string | null; -} export interface GetMonitorChartsDataQueryArgs { monitorId: string; @@ -711,11 +630,6 @@ export interface GetMonitorChartsDataQueryArgs { location?: string | null; } -export interface GetFilterBarQueryArgs { - dateRangeStart: string; - - dateRangeEnd: string; -} export interface GetMonitorStatesQueryArgs { dateRangeStart: string; diff --git a/x-pack/legacy/plugins/ml/server/models/calendar/index.js b/x-pack/legacy/plugins/uptime/common/types/index.ts similarity index 81% rename from x-pack/legacy/plugins/ml/server/models/calendar/index.js rename to x-pack/legacy/plugins/uptime/common/types/index.ts index 11f99bc8fd922..34bfbc540672f 100644 --- a/x-pack/legacy/plugins/ml/server/models/calendar/index.js +++ b/x-pack/legacy/plugins/uptime/common/types/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { CalendarManager } from './calendar_manager'; +export * from './ping/histogram'; diff --git a/x-pack/legacy/plugins/uptime/common/types/ping/histogram.ts b/x-pack/legacy/plugins/uptime/common/types/ping/histogram.ts new file mode 100644 index 0000000000000..7ac8d1f7b0151 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/common/types/ping/histogram.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export type UnsignedInteger = any; + +export interface HistogramDataPoint { + upCount?: number | null; + + downCount?: number | null; + + x?: UnsignedInteger | null; + + x0?: UnsignedInteger | null; + + y?: UnsignedInteger | null; +} + +export interface GetPingHistogramParams { + dateStart: string; + dateEnd: string; + filters?: string; + monitorId?: string; + statusFilter?: string; +} + +export interface HistogramResult { + histogram: HistogramDataPoint[]; + interval: string; +} diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx new file mode 100644 index 0000000000000..a6607ca81fc18 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx @@ -0,0 +1,76 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useEffect } from 'react'; +import { connect } from 'react-redux'; +import { AppState } from '../../../state'; +import { + PingHistogramComponent, + PingHistogramComponentProps, +} from '../../functional/charts/ping_histogram'; +import { getPingHistogram } from '../../../state/actions'; +import { selectPingHistogram } from '../../../state/selectors'; +import { withResponsiveWrapper, ResponsiveWrapperProps } from '../../higher_order'; +import { GetPingHistogramParams, HistogramResult } from '../../../../common/types'; + +type Props = GetPingHistogramParams & + ResponsiveWrapperProps & + PingHistogramComponentProps & + DispatchProps & { lastRefresh: number }; + +const PingHistogramContainer: React.FC = ({ + data, + loadData, + statusFilter, + filters, + dateStart, + dateEnd, + absoluteStartDate, + absoluteEndDate, + monitorId, + lastRefresh, + ...props +}) => { + useEffect(() => { + loadData({ monitorId, dateStart, dateEnd, statusFilter, filters }); + }, [loadData, dateStart, dateEnd, monitorId, filters, statusFilter, lastRefresh]); + return ( + + ); +}; + +interface StateProps { + data: HistogramResult | null; + loading: boolean; + lastRefresh: number; +} + +interface DispatchProps { + loadData: typeof getPingHistogram; +} + +const mapStateToProps = (state: AppState): StateProps => ({ ...selectPingHistogram(state) }); + +const mapDispatchToProps = (dispatch: any): DispatchProps => ({ + loadData: (params: GetPingHistogramParams) => { + return dispatch(getPingHistogram(params)); + }, +}); + +export const PingHistogram = connect< + StateProps, + DispatchProps, + PingHistogramComponentProps, + AppState +>( + mapStateToProps, + mapDispatchToProps +)(withResponsiveWrapper(PingHistogramContainer)); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx new file mode 100644 index 0000000000000..2d1c21d1c997d --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx @@ -0,0 +1,93 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useEffect } from 'react'; +import { connect } from 'react-redux'; +import { useUrlParams } from '../../../hooks'; +import { parseFiltersMap } from '../../functional/filter_group/parse_filter_map'; +import { AppState } from '../../../state'; +import { fetchOverviewFilters, GetOverviewFiltersPayload } from '../../../state/actions'; +import { FilterGroupComponent } from '../../functional/filter_group'; +import { OverviewFilters } from '../../../../common/runtime_types/overview_filters'; + +interface OwnProps { + esFilters?: string; +} + +interface StoreProps { + esKuery: string; + lastRefresh: number; + loading: boolean; + overviewFilters: OverviewFilters; +} + +interface DispatchProps { + loadFilterGroup: typeof fetchOverviewFilters; +} + +type Props = OwnProps & StoreProps & DispatchProps; + +export const Container: React.FC = ({ + esKuery, + esFilters, + loading, + loadFilterGroup, + overviewFilters, +}: Props) => { + const [getUrlParams, updateUrl] = useUrlParams(); + + const { dateRangeStart, dateRangeEnd, statusFilter, filters: urlFilters } = getUrlParams(); + + useEffect(() => { + const filterSelections = parseFiltersMap(urlFilters); + loadFilterGroup({ + dateRangeStart, + dateRangeEnd, + locations: filterSelections.locations ?? [], + ports: filterSelections.ports ?? [], + schemes: filterSelections.schemes ?? [], + search: esKuery, + statusFilter, + tags: filterSelections.tags ?? [], + }); + }, [dateRangeStart, dateRangeEnd, esKuery, esFilters, statusFilter, urlFilters, loadFilterGroup]); + + // update filters in the URL from filter group + const onFilterUpdate = (filtersKuery: string) => { + if (urlFilters !== filtersKuery) { + updateUrl({ filters: filtersKuery, pagination: '' }); + } + }; + + return ( + + ); +}; + +const mapStateToProps = ({ + overviewFilters: { loading, filters }, + ui: { esKuery, lastRefresh }, +}: AppState): StoreProps => ({ + esKuery, + overviewFilters: filters, + lastRefresh, + loading, +}); + +const mapDispatchToProps = (dispatch: any): DispatchProps => ({ + loadFilterGroup: (payload: GetOverviewFiltersPayload) => dispatch(fetchOverviewFilters(payload)), +}); + +export const FilterGroup = connect( + // @ts-ignore connect is expecting null | undefined for some reason + mapStateToProps, + mapDispatchToProps +)(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/index.ts b/x-pack/legacy/plugins/uptime/public/components/connected/index.ts new file mode 100644 index 0000000000000..5bb0d1ae8468f --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/connected/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { PingHistogram } from './charts/ping_histogram'; +export { KueryBar } from './kuerybar/kuery_bar_container'; +export { OverviewPage } from './pages/overview_container'; +export { FilterGroup } from './filter_group/filter_group_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx new file mode 100644 index 0000000000000..d0f160b2c5540 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { connect } from 'react-redux'; +import { AppState } from '../../../state'; +import { selectIndexPattern } from '../../../state/selectors'; +import { getIndexPattern } from '../../../state/actions'; +import { KueryBarComponent } from '../../functional'; + +const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); + +const mapDispatchToProps = (dispatch: any) => ({ + loadIndexPattern: () => { + dispatch(getIndexPattern({})); + }, +}); + +export const KueryBar = connect(mapStateToProps, mapDispatchToProps)(KueryBarComponent); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts b/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts new file mode 100644 index 0000000000000..406fab8f5bf01 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { connect } from 'react-redux'; +import { OverviewPageComponent } from '../../../pages/overview'; +import { selectIndexPattern } from '../../../state/selectors'; +import { AppState } from '../../../state'; + +const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); + +export const OverviewPage = connect(mapStateToProps)(OverviewPageComponent); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap index 4b9c169b3d9b3..653b739145f30 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap @@ -4,6 +4,11 @@ exports[`OverviewPageParsingErrorCallout renders without errors when a valid err

    @@ -26,6 +31,11 @@ exports[`OverviewPageParsingErrorCallout renders without errors when an error wi

    diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap index 3f3e6b0b929e1..c1b5970f6456c 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ChartWrapper component renders the component with loading false 1`] = ` - +

    - + `; exports[`ChartWrapper component renders the component with loading true 1`] = ` - +
    - + `; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/ping_histogram.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/ping_histogram.test.tsx.snap new file mode 100644 index 0000000000000..8ee4dc3575469 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/ping_histogram.test.tsx.snap @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PingHistogram component renders the component without errors 1`] = ` + + +
    + +
    +
    + + + +

    + } + title={ + +
    + +
    +
    + } + /> +
    +
    +`; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/snapshot_histogram.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/snapshot_histogram.test.tsx.snap deleted file mode 100644 index a725f97d3e0fb..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/snapshot_histogram.test.tsx.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`SnapshotHistogram component renders the component without errors 1`] = ` - - - -`; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/snapshot_histogram.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/ping_histogram.test.tsx similarity index 64% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/snapshot_histogram.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/ping_histogram.test.tsx index db78c063b7ed5..de7cfc86abc0c 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/snapshot_histogram.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/ping_histogram.test.tsx @@ -6,17 +6,16 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { SnapshotHistogram, SnapshotHistogramProps } from '../snapshot_histogram'; +import { PingHistogramComponent, PingHistogramComponentProps } from '../ping_histogram'; -describe('SnapshotHistogram component', () => { - const props: SnapshotHistogramProps = { +describe('PingHistogram component', () => { + const props: PingHistogramComponentProps = { absoluteStartDate: 1548697920000, absoluteEndDate: 1548700920000, - isResponsive: false, }; it('renders the component without errors', () => { - const component = shallowWithIntl(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx index deeb1411052c3..7286c59956887 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { FC, Fragment, HTMLAttributes } from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiLoadingChart } from '@elastic/eui'; +import React, { FC, HTMLAttributes } from 'react'; +import { EuiErrorBoundary, EuiFlexGroup, EuiFlexItem, EuiLoadingChart } from '@elastic/eui'; interface Props { /** @@ -31,7 +31,7 @@ export const ChartWrapper: FC = ({ const opacity = loading === true ? 0.3 : 1; return ( - +
    = ({ )} - + ); }; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts b/x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts index f7c1283dc9e07..2cbd9a2b3aa32 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts @@ -7,4 +7,4 @@ export { DonutChart } from './donut_chart'; export { DurationChart } from './duration_chart'; export { MonitorBarSeries } from './monitor_bar_series'; -export { SnapshotHistogram } from './snapshot_histogram'; +export { PingHistogramComponent } from './ping_histogram'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/snapshot_histogram.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/charts/ping_histogram.tsx similarity index 76% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/snapshot_histogram.tsx rename to x-pack/legacy/plugins/uptime/public/components/functional/charts/ping_histogram.tsx index 92b04534b7331..2d44cff0108cd 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/snapshot_histogram.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/charts/ping_histogram.tsx @@ -4,21 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Axis, BarSeries, Chart, Position, timeFormatter, Settings } from '@elastic/charts'; -import { EuiEmptyPrompt, EuiTitle, EuiPanel } from '@elastic/eui'; +import { Axis, BarSeries, Chart, Position, Settings, timeFormatter } from '@elastic/charts'; +import { EuiEmptyPrompt, EuiPanel, EuiTitle } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useContext } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import moment from 'moment'; import { getChartDateLabel } from '../../../lib/helper'; -import { withUptimeGraphQL, UptimeGraphQLQueryProps } from '../../higher_order'; -import { snapshotHistogramQuery } from '../../../queries/snapshot_histogram_query'; import { ChartWrapper } from './chart_wrapper'; import { UptimeThemeContext } from '../../../contexts'; -import { ResponsiveWrapperProps, withResponsiveWrapper } from '../../higher_order'; -import { HistogramResult } from '../../../../common/domain_types'; +import { HistogramResult } from '../../../../common/types'; -interface HistogramProps { +export interface PingHistogramComponentProps { /** * The date/time for the start of the timespan. */ @@ -32,29 +29,23 @@ interface HistogramProps { * Height is needed, since by default charts takes height of 100% */ height?: string; -} -export type SnapshotHistogramProps = HistogramProps & ResponsiveWrapperProps; + data?: HistogramResult; -interface SnapshotHistogramQueryResult { - queryResult?: HistogramResult; + loading?: boolean; } -type Props = UptimeGraphQLQueryProps & - SnapshotHistogramProps & - ResponsiveWrapperProps; - -export const SnapshotHistogramComponent: React.FC = ({ +export const PingHistogramComponent: React.FC = ({ absoluteStartDate, absoluteEndDate, data, loading = false, height, -}: Props) => { +}) => { const { colors: { danger, gray }, } = useContext(UptimeThemeContext); - if (!data || !data.queryResult) + if (!data || !data.histogram) /** * TODO: the Fragment, EuiTitle, and EuiPanel should be extracted to a dumb component * that we can reuse in the subsequent return statement at the bottom of this function. @@ -93,19 +84,15 @@ export const SnapshotHistogramComponent: React.FC = ({ ); - const { - queryResult: { histogram, interval }, - } = data; + const { histogram } = data; - const downMonitorsId = i18n.translate('xpack.uptime.snapshotHistogram.downMonitorsId', { + const downSpecId = i18n.translate('xpack.uptime.snapshotHistogram.downMonitorsId', { defaultMessage: 'Down Monitors', }); - const downSpecId = downMonitorsId; const upMonitorsId = i18n.translate('xpack.uptime.snapshotHistogram.series.upLabel', { defaultMessage: 'Up', }); - const upSpecId = upMonitorsId; return ( <> @@ -131,7 +118,6 @@ export const SnapshotHistogramComponent: React.FC = ({ = ({ /> = ({ /> = ({ [x, upCount || 0])} - id={upSpecId} + id={upMonitorsId} name={upMonitorsId} stackAccessors={[0]} timeZone="local" @@ -187,8 +173,3 @@ export const SnapshotHistogramComponent: React.FC = ({ ); }; - -export const SnapshotHistogram = withUptimeGraphQL< - SnapshotHistogramQueryResult, - SnapshotHistogramProps ->(withResponsiveWrapper(SnapshotHistogramComponent), snapshotHistogramQuery); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx index 351302fb38356..ff73554c8f07c 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx @@ -4,44 +4,21 @@ * you may not use this file except in compliance with the Elastic License. */ +import React from 'react'; import { EuiFilterGroup } from '@elastic/eui'; -import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; -import { connect } from 'react-redux'; import { FilterPopoverProps, FilterPopover } from './filter_popover'; import { FilterStatusButton } from './filter_status_button'; -import { OverviewFilters } from '../../../../common/runtime_types'; -import { fetchOverviewFilters, GetOverviewFiltersPayload } from '../../../state/actions'; -import { AppState } from '../../../state'; -import { useUrlParams } from '../../../hooks'; -import { parseFiltersMap } from './parse_filter_map'; +import { OverviewFilters } from '../../../../common/runtime_types/overview_filters'; -interface OwnProps { - currentFilter: any; - onFilterUpdate: any; - dateRangeStart: string; - dateRangeEnd: string; - filters?: string; - statusFilter?: string; -} - -interface StoreProps { - esKuery: string; - lastRefresh: number; +interface PresentationalComponentProps { loading: boolean; overviewFilters: OverviewFilters; + currentFilter: string; + onFilterUpdate: (filtersKuery: string) => void; } -interface DispatchProps { - loadFilterGroup: typeof fetchOverviewFilters; -} - -type Props = OwnProps & StoreProps & DispatchProps; - -type PresentationalComponentProps = Pick & - Pick; - -export const PresentationalComponent: React.FC = ({ +export const FilterGroupComponent: React.FC = ({ currentFilter, overviewFilters, loading, @@ -151,60 +128,3 @@ export const PresentationalComponent: React.FC = ( ); }; - -export const Container: React.FC = ({ - currentFilter, - esKuery, - filters, - loading, - loadFilterGroup, - dateRangeStart, - dateRangeEnd, - overviewFilters, - statusFilter, - onFilterUpdate, -}: Props) => { - const [getUrlParams] = useUrlParams(); - const { filters: urlFilters } = getUrlParams(); - useEffect(() => { - const filterSelections = parseFiltersMap(urlFilters); - loadFilterGroup({ - dateRangeStart, - dateRangeEnd, - locations: filterSelections.locations ?? [], - ports: filterSelections.ports ?? [], - schemes: filterSelections.schemes ?? [], - search: esKuery, - statusFilter, - tags: filterSelections.tags ?? [], - }); - }, [dateRangeStart, dateRangeEnd, esKuery, filters, statusFilter, urlFilters, loadFilterGroup]); - return ( - - ); -}; - -const mapStateToProps = ({ - overviewFilters: { loading, filters }, - ui: { esKuery, lastRefresh }, -}: AppState): StoreProps => ({ - esKuery, - overviewFilters: filters, - lastRefresh, - loading, -}); - -const mapDispatchToProps = (dispatch: any): DispatchProps => ({ - loadFilterGroup: (payload: GetOverviewFiltersPayload) => dispatch(fetchOverviewFilters(payload)), -}); - -export const FilterGroup = connect( - // @ts-ignore connect is expecting null | undefined for some reason - mapStateToProps, - mapDispatchToProps -)(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts b/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts index 285972fb34eaa..2aae026144d8f 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { FilterGroup } from './filter_group'; +export { FilterGroupComponent } from './filter_group'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/index.ts b/x-pack/legacy/plugins/uptime/public/components/functional/index.ts index 7370faa12f393..6af17cfd67c46 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/functional/index.ts @@ -7,13 +7,12 @@ export { DonutChart } from './charts/donut_chart'; export { EmptyState } from './empty_state'; export { MonitorStatusBar } from './monitor_status_details'; -export { FilterGroup } from './filter_group'; export { IntegrationLink } from './integration_link'; -export { KueryBar } from './kuery_bar'; +export { KueryBarComponent } from './kuery_bar/kuery_bar'; export { MonitorCharts } from './monitor_charts'; export { MonitorList } from './monitor_list'; export { OverviewPageParsingErrorCallout } from './overview_page_parsing_error_callout'; export { PingList } from './ping_list'; export { Snapshot } from './snapshot'; -export { SnapshotHistogram } from './charts'; +export { PingHistogramComponent } from './charts'; export { StatusPanel } from './status_panel'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/index.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/kuery_bar.tsx similarity index 91% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/index.tsx rename to x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/kuery_bar.tsx index 679106f7e19b4..63c8885fe5864 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/index.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/kuery_bar.tsx @@ -11,14 +11,12 @@ import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; import { Typeahead } from './typeahead'; import { useUrlParams } from '../../../hooks'; -import { toStaticIndexPattern } from '../../../lib/helper'; import { esKuery, IIndexPattern, autocomplete, DataPublicPluginStart, } from '../../../../../../../../src/plugins/data/public'; -import { useIndexPattern } from '../../../hooks'; const Container = styled.div` margin-bottom: 10px; @@ -36,20 +34,29 @@ function convertKueryToEsQuery(kuery: string, indexPattern: IIndexPattern) { interface Props { autocomplete: DataPublicPluginStart['autocomplete']; + loadIndexPattern: any; + indexPattern: any; } -export function KueryBar({ autocomplete: autocompleteService }: Props) { +export function KueryBarComponent({ + autocomplete: autocompleteService, + loadIndexPattern, + indexPattern, +}: Props) { + useEffect(() => { + if (!indexPattern) { + loadIndexPattern(); + } + }, [indexPattern, loadIndexPattern]); + const [state, setState] = useState({ suggestions: [], isLoadingIndexPattern: true, }); - const [indexPattern, setIndexPattern] = useState(undefined); const [isLoadingIndexPattern, setIsLoadingIndexPattern] = useState(true); const [isLoadingSuggestions, setIsLoadingSuggestions] = useState(false); let currentRequestCheck: string; - useIndexPattern((result: any) => setIndexPattern(toStaticIndexPattern(result))); - useEffect(() => { if (indexPattern !== undefined) { setIsLoadingIndexPattern(false); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap index a03a89be35ec2..2ed3512c9c21a 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap @@ -143,6 +143,45 @@ exports[`LocationMap component renders correctly against snapshot 1`] = ` `; +exports[`LocationMap component renders named locations that have missing geo data 1`] = ` + + + + + + + + + + + + + +`; + exports[`LocationMap component shows warning if geo information is missing 1`] = ` diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap index fb949c7f3b4c2..7862fe03163dc 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap @@ -3,6 +3,7 @@ exports[`LocationMissingWarning component renders correctly against snapshot 1`] = `
    { const warningComponent = component.find(LocationMissingWarning); expect(warningComponent).toHaveLength(0); }); + + it('renders named locations that have missing geo data', () => { + monitorLocations = { + monitorId: 'wapo', + locations: [ + { + summary: { up: 4, down: 0 }, + geo: { name: 'New York', location: undefined }, + timestamp: '2020-01-13T22:50:06.536Z', + }, + ], + }; + + const component = shallowWithIntl(); + expect(component).toMatchSnapshot(); + }); }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx index 3a3319208ea3c..f8efe42d0ce71 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx @@ -31,7 +31,7 @@ export const LocationMissingWarning = () => { ); return ( - + - diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx index 3d38ce42dd1f0..b71a4f2f8646a 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx @@ -26,6 +26,7 @@ export const OverviewPageParsingErrorCallout = ({ })} color="danger" iconType="alert" + style={{ width: '100%' }} >

    ( @@ -42,12 +40,15 @@ export const StatusPanel = ({ /> - diff --git a/x-pack/legacy/plugins/uptime/public/hooks/index.ts b/x-pack/legacy/plugins/uptime/public/hooks/index.ts index aa7bb0a220357..cfb8d71f783a6 100644 --- a/x-pack/legacy/plugins/uptime/public/hooks/index.ts +++ b/x-pack/legacy/plugins/uptime/public/hooks/index.ts @@ -5,5 +5,5 @@ */ export { useUrlParams } from './use_url_params'; -export { useIndexPattern } from './use_index_pattern'; export * from './use_telemetry'; +export * from './update_kuery_string'; diff --git a/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts b/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts new file mode 100644 index 0000000000000..d02a6fc2afb5d --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts @@ -0,0 +1,65 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { combineFiltersAndUserSearch, stringifyKueries } from '../lib/helper'; +import { esKuery } from '../../../../../../src/plugins/data/common/es_query'; +import { store } from '../state'; +import { setEsKueryString } from '../state/actions'; +import { IIndexPattern } from '../../../../../../src/plugins/data/common/index_patterns'; + +const updateEsQueryForFilterGroup = (filterQueryString: string, indexPattern: IIndexPattern) => { + // Update EsQuery in Redux to be used in FilterGroup + const searchDSL: string = filterQueryString + ? JSON.stringify( + esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(filterQueryString), indexPattern) + ) + : ''; + store.dispatch(setEsKueryString(searchDSL)); +}; + +const getKueryString = (urlFilters: string): string => { + let kueryString = ''; + // We are using try/catch here because this is user entered value + // and JSON.parse and stringifyKueries can have hard time parsing + // all possible scenarios, we can safely ignore if we can't parse them + try { + if (urlFilters !== '') { + const filterMap = new Map>(JSON.parse(urlFilters)); + kueryString = stringifyKueries(filterMap); + } + } catch { + kueryString = ''; + } + return kueryString; +}; + +export const useUpdateKueryString = ( + indexPattern: IIndexPattern, + filterQueryString = '', + urlFilters: string +): [string?, Error?] => { + const kueryString = getKueryString(urlFilters); + + const combinedFilterString = combineFiltersAndUserSearch(filterQueryString, kueryString); + + let esFilters: string | undefined; + // this try catch is necessary to evaluate user input in kuery bar, + // this error will be actually shown in UI for user to see + try { + if ((filterQueryString || urlFilters) && indexPattern) { + const ast = esKuery.fromKueryExpression(combinedFilterString); + + const elasticsearchQuery = esKuery.toElasticsearchQuery(ast, indexPattern); + + esFilters = JSON.stringify(elasticsearchQuery); + + updateEsQueryForFilterGroup(filterQueryString, indexPattern); + } + return [esFilters]; + } catch (err) { + return [urlFilters, err]; + } +}; diff --git a/x-pack/legacy/plugins/uptime/public/hooks/use_index_pattern.ts b/x-pack/legacy/plugins/uptime/public/hooks/use_index_pattern.ts deleted file mode 100644 index f2b586b27dba6..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/hooks/use_index_pattern.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { useEffect, Dispatch } from 'react'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; - -export const useIndexPattern = (setIndexPattern: Dispatch) => { - const core = useKibana(); - useEffect(() => { - const fetch = core.services.http?.fetch; - async function getIndexPattern() { - if (!fetch) throw new Error('Http core services are not defined'); - setIndexPattern(await fetch('/api/uptime/index_pattern', { method: 'GET' })); - } - getIndexPattern(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [core.services.http]); -}; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/to_static_index_pattern.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/to_static_index_pattern.test.ts.snap deleted file mode 100644 index bc02e1054b6f7..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/to_static_index_pattern.test.ts.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`toStaticIndexPattern provides the required fields 1`] = ` -Object { - "attributes": Object { - "fields": "[{\\"name\\":\\"@timestamp\\",\\"type\\":\\"date\\",\\"scripted\\":false,\\"searchable\\":true}]", - }, - "fields": Array [ - Object { - "name": "@timestamp", - "scripted": false, - "searchable": true, - "type": "date", - }, - ], - "id": "foo", - "title": "foo", -} -`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/to_static_index_pattern.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/to_static_index_pattern.test.ts deleted file mode 100644 index c8015a678c726..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/to_static_index_pattern.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { toStaticIndexPattern } from '../to_static_index_pattern'; - -describe('toStaticIndexPattern', () => { - it('provides the required fields', () => { - const pattern = { - attributes: { - fields: '[{"name":"@timestamp","type":"date","scripted":false,"searchable":true}]', - }, - id: 'foo', - }; - expect(toStaticIndexPattern(pattern)).toMatchSnapshot(); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/combine_filters_and_user_search.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/combine_filters_and_user_search.ts index f3dfbb7d3b529..45aff24f0449e 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/combine_filters_and_user_search.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/combine_filters_and_user_search.ts @@ -5,6 +5,9 @@ */ export const combineFiltersAndUserSearch = (filters: string, search: string) => { + if (!filters && !search) { + return ''; + } if (!filters) return search; if (!search) return filters; return `(${filters}) and (${search})`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/index.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/index.ts index ced06ce7a1d7b..ef191ce32e532 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/index.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/index.ts @@ -12,5 +12,4 @@ export { getChartDateLabel } from './charts'; export { parameterizeValues } from './parameterize_values'; export { seriesHasDownValues } from './series_has_down_values'; export { stringifyKueries } from './stringify_kueries'; -export { toStaticIndexPattern } from './to_static_index_pattern'; export { UptimeUrlParams, getSupportedUrlParams } from './url_params'; diff --git a/x-pack/legacy/plugins/uptime/public/pages/index.ts b/x-pack/legacy/plugins/uptime/public/pages/index.ts index a96be42eb0dee..17f083ca023ed 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/index.ts +++ b/x-pack/legacy/plugins/uptime/public/pages/index.ts @@ -5,6 +5,6 @@ */ export { MonitorPage } from './monitor'; -export { OverviewPage } from './overview'; export { NotFoundPage } from './not_found'; export { PageHeader } from './page_header'; +export { OverviewPage } from '../components/connected/'; diff --git a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx index 36abee673b682..0f6195c5f4c66 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx @@ -5,30 +5,28 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import React, { Fragment, useContext, useState } from 'react'; +import React, { useContext } from 'react'; import styled from 'styled-components'; import { EmptyState, - FilterGroup, - KueryBar, MonitorList, OverviewPageParsingErrorCallout, StatusPanel, } from '../components/functional'; import { UMUpdateBreadcrumbs } from '../lib/lib'; -import { useIndexPattern, useUrlParams, useUptimeTelemetry, UptimePage } from '../hooks'; +import { useUrlParams, useUptimeTelemetry, UptimePage } from '../hooks'; import { stringifyUrlParams } from '../lib/helper/stringify_url_params'; import { useTrackPageview } from '../../../infra/public'; -import { combineFiltersAndUserSearch, stringifyKueries, toStaticIndexPattern } from '../lib/helper'; -import { store } from '../state'; -import { setEsKueryString } from '../state/actions'; import { PageHeader } from './page_header'; -import { esKuery, DataPublicPluginStart } from '../../../../../../src/plugins/data/public'; -import { UptimeThemeContext } from '../contexts/uptime_theme_context'; +import { DataPublicPluginStart, IIndexPattern } from '../../../../../../src/plugins/data/public'; +import { UptimeThemeContext } from '../contexts'; +import { FilterGroup, KueryBar } from '../components/connected'; +import { useUpdateKueryString } from '../hooks'; interface OverviewPageProps { autocomplete: DataPublicPluginStart['autocomplete']; setBreadcrumbs: UMUpdateBreadcrumbs; + indexPattern: IIndexPattern; } type Props = OverviewPageProps; @@ -42,72 +40,37 @@ const EuiFlexItemStyled = styled(EuiFlexItem)` } `; -export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { +export const OverviewPageComponent = ({ autocomplete, setBreadcrumbs, indexPattern }: Props) => { const { colors } = useContext(UptimeThemeContext); - const [getUrlParams, updateUrl] = useUrlParams(); + const [getUrlParams] = useUrlParams(); const { absoluteDateRangeStart, absoluteDateRangeEnd, ...params } = getUrlParams(); const { dateRangeStart, dateRangeEnd, - search, pagination, statusFilter, + search, filters: urlFilters, } = params; - const [indexPattern, setIndexPattern] = useState(undefined); + useUptimeTelemetry(UptimePage.Overview); - useIndexPattern(setIndexPattern); useTrackPageview({ app: 'uptime', path: 'overview' }); useTrackPageview({ app: 'uptime', path: 'overview', delay: 15000 }); - let error: any; - let kueryString: string = ''; - try { - if (urlFilters !== '') { - const filterMap = new Map>(JSON.parse(urlFilters)); - kueryString = stringifyKueries(filterMap); - } - } catch { - kueryString = ''; - } - - const filterQueryString = search || ''; - let filters: any | undefined; - try { - if (filterQueryString || urlFilters) { - if (indexPattern) { - const staticIndexPattern = toStaticIndexPattern(indexPattern); - const combinedFilterString = combineFiltersAndUserSearch(filterQueryString, kueryString); - const ast = esKuery.fromKueryExpression(combinedFilterString); - const elasticsearchQuery = esKuery.toElasticsearchQuery(ast, staticIndexPattern); - filters = JSON.stringify(elasticsearchQuery); - const searchDSL: string = filterQueryString - ? JSON.stringify( - esKuery.toElasticsearchQuery( - esKuery.fromKueryExpression(filterQueryString), - staticIndexPattern - ) - ) - : ''; - store.dispatch(setEsKueryString(searchDSL)); - } - } - } catch (e) { - error = e; - } + const [esFilters, error] = useUpdateKueryString(indexPattern, search, urlFilters); const sharedProps = { dateRangeStart, dateRangeEnd, - filters, statusFilter, + filters: esFilters, }; const linkParameters = stringifyUrlParams(params, true); return ( - + <> @@ -115,15 +78,7 @@ export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { - { - if (urlFilters !== filtersKuery) { - updateUrl({ filters: filtersKuery, pagination: '' }); - } - }} - /> + {error && } @@ -133,16 +88,15 @@ export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { absoluteDateRangeEnd={absoluteDateRangeEnd} dateRangeStart={dateRangeStart} dateRangeEnd={dateRangeEnd} - filters={filters} + filters={esFilters} statusFilter={statusFilter} - sharedProps={sharedProps} /> { }} /> - + ); }; diff --git a/x-pack/legacy/plugins/uptime/public/queries/snapshot_histogram_query.ts b/x-pack/legacy/plugins/uptime/public/queries/snapshot_histogram_query.ts deleted file mode 100644 index 7eb56ea4e9dd1..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/queries/snapshot_histogram_query.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import gql from 'graphql-tag'; - -export const snapshotHistogramQueryString = ` - query SnapshotHistogram( - $dateRangeStart: String! - $dateRangeEnd: String! - $filters: String - $monitorId: String - $statusFilter: String - ) { - queryResult: getSnapshotHistogram( - dateRangeStart: $dateRangeStart - dateRangeEnd: $dateRangeEnd - filters: $filters - statusFilter: $statusFilter - monitorId: $monitorId - ) { - histogram { - upCount - downCount - x - x0 - y - } - interval - } - } -`; - -export const snapshotHistogramQuery = gql` - ${snapshotHistogramQueryString} -`; diff --git a/x-pack/legacy/plugins/uptime/public/routes.tsx b/x-pack/legacy/plugins/uptime/public/routes.tsx index 07bba5163922e..c318a82ab7f19 100644 --- a/x-pack/legacy/plugins/uptime/public/routes.tsx +++ b/x-pack/legacy/plugins/uptime/public/routes.tsx @@ -6,7 +6,7 @@ import React, { FC } from 'react'; import { Route, Switch } from 'react-router-dom'; -import { MonitorPage, OverviewPage, NotFoundPage } from './pages'; +import { MonitorPage, NotFoundPage, OverviewPage } from './pages'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { UMUpdateBreadcrumbs } from './lib/lib'; diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/index.ts b/x-pack/legacy/plugins/uptime/public/state/actions/index.ts index 9874da1839c2f..df707584bd844 100644 --- a/x-pack/legacy/plugins/uptime/public/state/actions/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/actions/index.ts @@ -8,3 +8,5 @@ export * from './overview_filters'; export * from './snapshot'; export * from './ui'; export * from './monitor_status'; +export * from './index_patternts'; +export * from './ping'; diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/index_patternts.ts b/x-pack/legacy/plugins/uptime/public/state/actions/index_patternts.ts new file mode 100644 index 0000000000000..f52dac805a199 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/actions/index_patternts.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { createAction } from 'redux-actions'; +import { QueryParams } from './types'; + +export const getIndexPattern = createAction('GET_INDEX_PATTERN'); +export const getIndexPatternSuccess = createAction('GET_INDEX_PATTERN_SUCCESS'); +export const getIndexPatternFail = createAction('GET_INDEX_PATTERN_FAIL'); diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/ping.ts b/x-pack/legacy/plugins/uptime/public/state/actions/ping.ts new file mode 100644 index 0000000000000..bb7258d9a54b2 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/actions/ping.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { createAction } from 'redux-actions'; +import { GetPingHistogramParams, HistogramResult } from '../../../common/types'; + +export const getPingHistogram = createAction('GET_PING_HISTOGRAM'); +export const getPingHistogramSuccess = createAction('GET_PING_HISTOGRAM_SUCCESS'); +export const getPingHistogramFail = createAction('GET_PING_HISTOGRAM_FAIL'); diff --git a/x-pack/legacy/plugins/uptime/public/state/api/index.ts b/x-pack/legacy/plugins/uptime/public/state/api/index.ts index 1d0cac5f87854..2d20638832335 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/index.ts @@ -8,3 +8,5 @@ export * from './monitor'; export * from './overview_filters'; export * from './snapshot'; export * from './monitor_status'; +export * from './index_pattern'; +export * from './ping'; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/index_pattern.ts b/x-pack/legacy/plugins/uptime/public/state/api/index_pattern.ts new file mode 100644 index 0000000000000..2669376d728ab --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/api/index_pattern.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getApiPath } from '../../lib/helper'; + +interface APIParams { + basePath: string; +} + +export const fetchIndexPattern = async ({ basePath }: APIParams) => { + const url = getApiPath(`/api/uptime/index_pattern`, basePath); + + const response = await fetch(url); + if (!response.ok) { + throw new Error(response.statusText); + } + return await response.json(); +}; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts b/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts index 8b1220830f091..80fd311c3ec7e 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ThrowReporter } from 'io-ts/lib/ThrowReporter'; +import { PathReporter } from 'io-ts/lib/PathReporter'; import { getApiPath } from '../../lib/helper'; import { BaseParams } from './types'; import { @@ -41,7 +41,7 @@ export const fetchMonitorDetails = async ({ throw new Error(response.statusText); } return response.json().then(data => { - ThrowReporter.report(MonitorDetailsType.decode(data)); + PathReporter.report(MonitorDetailsType.decode(data)); return data; }); }; @@ -68,7 +68,7 @@ export const fetchMonitorLocations = async ({ throw new Error(response.statusText); } return response.json().then(data => { - ThrowReporter.report(MonitorLocationsType.decode(data)); + PathReporter.report(MonitorLocationsType.decode(data)); return data; }); }; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/ping.ts b/x-pack/legacy/plugins/uptime/public/state/api/ping.ts new file mode 100644 index 0000000000000..e0c358fe40e71 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/api/ping.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import qs from 'querystring'; +import { getApiPath } from '../../lib/helper'; +import { APIFn } from './types'; +import { GetPingHistogramParams, HistogramResult } from '../../../common/types'; + +export const fetchPingHistogram: APIFn = async ({ + basePath, + monitorId, + dateStart, + dateEnd, + statusFilter, + filters, +}) => { + const url = getApiPath(`/api/uptime/ping/histogram`, basePath); + const params = { + dateStart, + dateEnd, + ...(monitorId && { monitorId }), + ...(statusFilter && { statusFilter }), + ...(filters && { filters }), + }; + const urlParams = qs.stringify(params).toString(); + const response = await fetch(`${url}?${urlParams}`); + if (!response.ok) { + throw new Error(response.statusText); + } + const responseData = await response.json(); + return responseData; +}; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/types.ts b/x-pack/legacy/plugins/uptime/public/state/api/types.ts index 278cfce29986f..c88e111d778d5 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/types.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/types.ts @@ -12,3 +12,5 @@ export interface BaseParams { statusFilter?: string; location?: string; } + +export type APIFn = (params: { basePath: string } & P) => Promise; diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/index.ts b/x-pack/legacy/plugins/uptime/public/state/effects/index.ts index 41dda145edb4e..f809454cefb39 100644 --- a/x-pack/legacy/plugins/uptime/public/state/effects/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/effects/index.ts @@ -9,10 +9,14 @@ import { fetchMonitorDetailsEffect } from './monitor'; import { fetchOverviewFiltersEffect } from './overview_filters'; import { fetchSnapshotCountEffect } from './snapshot'; import { fetchMonitorStatusEffect } from './monitor_status'; +import { fetchIndexPatternEffect } from './index_pattern'; +import { fetchPingHistogramEffect } from './ping'; export function* rootEffect() { yield fork(fetchMonitorDetailsEffect); yield fork(fetchSnapshotCountEffect); yield fork(fetchOverviewFiltersEffect); yield fork(fetchMonitorStatusEffect); + yield fork(fetchIndexPatternEffect); + yield fork(fetchPingHistogramEffect); } diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/index_pattern.ts b/x-pack/legacy/plugins/uptime/public/state/effects/index_pattern.ts new file mode 100644 index 0000000000000..a6f9256d5ccd9 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/effects/index_pattern.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { takeLatest } from 'redux-saga/effects'; +import { getIndexPattern, getIndexPatternSuccess, getIndexPatternFail } from '../actions'; +import { fetchIndexPattern } from '../api'; +import { fetchEffectFactory } from './fetch_effect'; + +export function* fetchIndexPatternEffect() { + yield takeLatest( + getIndexPattern, + fetchEffectFactory(fetchIndexPattern, getIndexPatternSuccess, getIndexPatternFail) + ); +} diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/ping.ts b/x-pack/legacy/plugins/uptime/public/state/effects/ping.ts new file mode 100644 index 0000000000000..acb9b31915fa9 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/effects/ping.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { takeLatest } from 'redux-saga/effects'; +import { getPingHistogram, getPingHistogramSuccess, getPingHistogramFail } from '../actions'; +import { fetchPingHistogram } from '../api'; +import { fetchEffectFactory } from './fetch_effect'; + +export function* fetchPingHistogramEffect() { + yield takeLatest( + String(getPingHistogram), + fetchEffectFactory(fetchPingHistogram, getPingHistogramSuccess, getPingHistogramFail) + ); +} diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts index 5f915d970e543..842cb1e937108 100644 --- a/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts @@ -10,6 +10,8 @@ import { overviewFiltersReducer } from './overview_filters'; import { snapshotReducer } from './snapshot'; import { uiReducer } from './ui'; import { monitorStatusReducer } from './monitor_status'; +import { indexPatternReducer } from './index_pattern'; +import { pingReducer } from './ping'; export const rootReducer = combineReducers({ monitor: monitorReducer, @@ -17,4 +19,6 @@ export const rootReducer = combineReducers({ snapshot: snapshotReducer, ui: uiReducer, monitorStatus: monitorStatusReducer, + indexPattern: indexPatternReducer, + ping: pingReducer, }); diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/index_pattern.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/index_pattern.ts new file mode 100644 index 0000000000000..dff043f81b95c --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/index_pattern.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { handleActions, Action } from 'redux-actions'; +import { getIndexPattern, getIndexPatternSuccess, getIndexPatternFail } from '../actions'; + +export interface IndexPatternState { + index_pattern: any; + errors: any[]; + loading: boolean; +} + +const initialState: IndexPatternState = { + index_pattern: null, + loading: false, + errors: [], +}; + +export const indexPatternReducer = handleActions( + { + [String(getIndexPattern)]: state => ({ + ...state, + loading: true, + }), + + [String(getIndexPatternSuccess)]: (state, action: Action) => ({ + ...state, + loading: false, + index_pattern: { ...action.payload }, + }), + + [String(getIndexPatternFail)]: (state, action: Action) => ({ + ...state, + errors: [...state.errors, action.payload], + loading: false, + }), + }, + initialState +); diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/ping.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/ping.ts new file mode 100644 index 0000000000000..76775e6a0a355 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/ping.ts @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { handleActions, Action } from 'redux-actions'; +import { getPingHistogram, getPingHistogramSuccess, getPingHistogramFail } from '../actions'; +import { HistogramResult } from '../../../common/types'; + +export interface PingState { + pingHistogram: HistogramResult | null; + errors: any[]; + loading: boolean; +} + +const initialState: PingState = { + pingHistogram: null, + loading: false, + errors: [], +}; + +type MonitorStatusPayload = HistogramResult & Error; + +export const pingReducer = handleActions( + { + [String(getPingHistogram)]: state => ({ + ...state, + loading: true, + }), + + [String(getPingHistogramSuccess)]: (state: PingState, action: Action) => ({ + ...state, + loading: false, + pingHistogram: { ...action.payload }, + }), + + [String(getPingHistogramFail)]: (state, action: Action) => ({ + ...state, + errors: [...state.errors, action.payload], + loading: false, + }), + }, + initialState +); diff --git a/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts index 38fb3edea4768..2e27431a5ff14 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts @@ -45,6 +45,16 @@ describe('state selectors', () => { monitor: null, loading: false, }, + indexPattern: { + index_pattern: null, + loading: false, + errors: [], + }, + ping: { + pingHistogram: null, + loading: false, + errors: [], + }, }; it('selects base path from state', () => { diff --git a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts index 337e99f6ede16..fe6a7a1b7eade 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts @@ -28,3 +28,11 @@ export const selectSelectedMonitor = (state: AppState) => { export const selectMonitorStatus = (state: AppState) => { return state.monitorStatus.status; }; + +export const selectIndexPattern = ({ indexPattern }: AppState) => { + return indexPattern.index_pattern; +}; + +export const selectPingHistogram = ({ ping, ui }: AppState) => { + return { data: ping.pingHistogram, loading: ping.loading, lastRefresh: ui.lastRefresh }; +}; diff --git a/x-pack/legacy/plugins/uptime/server/graphql/monitors/resolvers.ts b/x-pack/legacy/plugins/uptime/server/graphql/monitors/resolvers.ts index 897d67dde807e..cc5744eac6ea1 100644 --- a/x-pack/legacy/plugins/uptime/server/graphql/monitors/resolvers.ts +++ b/x-pack/legacy/plugins/uptime/server/graphql/monitors/resolvers.ts @@ -4,19 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { UMGqlRange } from '../../../common/domain_types'; import { UMResolver } from '../../../common/graphql/resolver_types'; -import { - GetFilterBarQueryArgs, - GetMonitorChartsDataQueryArgs, - MonitorChart, - GetSnapshotHistogramQueryArgs, -} from '../../../common/graphql/types'; +import { GetMonitorChartsDataQueryArgs, MonitorChart } from '../../../common/graphql/types'; import { UMServerLibs } from '../../lib/lib'; import { CreateUMGraphQLResolvers, UMContext } from '../types'; -import { HistogramResult } from '../../../common/domain_types'; - -export type UMMonitorsResolver = UMResolver, any, UMGqlRange, UMContext>; export type UMGetMonitorChartsResolver = UMResolver< any | Promise, @@ -25,49 +16,20 @@ export type UMGetMonitorChartsResolver = UMResolver< UMContext >; -export type UMGetFilterBarResolver = UMResolver< - any | Promise, - any, - GetFilterBarQueryArgs, - UMContext ->; - -export type UMGetSnapshotHistogram = UMResolver< - HistogramResult | Promise, - any, - GetSnapshotHistogramQueryArgs, - UMContext ->; - export const createMonitorsResolvers: CreateUMGraphQLResolvers = ( libs: UMServerLibs ): { Query: { - getSnapshotHistogram: UMGetSnapshotHistogram; getMonitorChartsData: UMGetMonitorChartsResolver; }; } => ({ Query: { - async getSnapshotHistogram( - _resolver, - { dateRangeStart, dateRangeEnd, filters, monitorId, statusFilter }, - { APICaller } - ): Promise { - return await libs.pings.getPingHistogram({ - callES: APICaller, - dateRangeStart, - dateRangeEnd, - filters, - monitorId, - statusFilter, - }); - }, async getMonitorChartsData( _resolver, { monitorId, dateRangeStart, dateRangeEnd, location }, { APICaller } ): Promise { - return await libs.monitors.getMonitorChartsData({ + return libs.monitors.getMonitorChartsData({ callES: APICaller, monitorId, dateRangeStart, diff --git a/x-pack/legacy/plugins/uptime/server/graphql/monitors/schema.gql.ts b/x-pack/legacy/plugins/uptime/server/graphql/monitors/schema.gql.ts index 8a86d97b4cd8e..6b8a896c4c60b 100644 --- a/x-pack/legacy/plugins/uptime/server/graphql/monitors/schema.gql.ts +++ b/x-pack/legacy/plugins/uptime/server/graphql/monitors/schema.gql.ts @@ -7,19 +7,6 @@ import gql from 'graphql-tag'; export const monitorsSchema = gql` - type HistogramDataPoint { - upCount: Int - downCount: Int - x: UnsignedInteger - x0: UnsignedInteger - y: UnsignedInteger - } - - type DataPoint { - x: UnsignedInteger - y: Float - } - "Represents a bucket of monitor status information." type StatusData { "The timeseries point for this status data." @@ -93,11 +80,6 @@ export const monitorsSchema = gql` monitors: [LatestMonitor!] } - type HistogramResult { - histogram: [HistogramDataPoint]! - interval: UnsignedInteger! - } - extend type Query { getMonitors( dateRangeStart: String! @@ -106,14 +88,6 @@ export const monitorsSchema = gql` statusFilter: String ): LatestMonitorsResult - getSnapshotHistogram( - dateRangeStart: String! - dateRangeEnd: String! - filters: String - statusFilter: String - monitorId: String - ): HistogramResult - getMonitorChartsData( monitorId: String! dateRangeStart: String! diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts index 2f72081a70988..fb2052bb4c87f 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts @@ -8,26 +8,12 @@ import { GraphQLSchema } from 'graphql'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { SavedObjectsLegacyService, - RequestHandler, IRouter, CallAPIOptions, SavedObjectsClientContract, } from 'src/core/server'; -import { ObjectType } from '@kbn/config-schema'; import { UMKibanaRoute } from '../../../rest_api'; -export interface UMFrameworkRouteOptions< - P extends ObjectType, - Q extends ObjectType, - B extends ObjectType -> { - path: string; - method: string; - handler: RequestHandler; - config?: any; - validate: any; -} - type APICaller = ( endpoint: string, clientParams: Record, diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/index.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/index.ts index f5ff3b8c62ba9..fbef70f106dd8 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/index.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/index.ts @@ -8,5 +8,5 @@ export * from './framework'; export * from './monitor_states'; export * from './monitors'; export * from './pings'; -export * from './saved_objects'; +export * from './stub_index_pattern'; export * from './telemetry'; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/__snapshots__/elasticsearch_pings_adapter.test.ts.snap b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/__snapshots__/elasticsearch_pings_adapter.test.ts.snap index b73595d539e93..1b31f44557df0 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/__snapshots__/elasticsearch_pings_adapter.test.ts.snap +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/__snapshots__/elasticsearch_pings_adapter.test.ts.snap @@ -22,7 +22,7 @@ Object { "y": 1, }, ], - "interval": 36000, + "interval": "1m", } `; @@ -48,7 +48,7 @@ Object { "y": 1, }, ], - "interval": 5609564928000, + "interval": "1h", } `; @@ -68,7 +68,7 @@ Object { "y": 1, }, ], - "interval": 5609564928000, + "interval": "1d", } `; @@ -88,7 +88,7 @@ Object { "y": 1, }, ], - "interval": 5609564928000, + "interval": "1s", } `; @@ -102,7 +102,7 @@ Object { "y": 1, }, ], - "interval": 36000, + "interval": "10s", } `; @@ -122,6 +122,6 @@ Object { "y": 1, }, ], - "interval": 36000, + "interval": "1m", } `; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/elasticsearch_pings_adapter.test.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/elasticsearch_pings_adapter.test.ts index e1e39ac9b2637..866ab110928b4 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/elasticsearch_pings_adapter.test.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/__tests__/elasticsearch_pings_adapter.test.ts @@ -5,8 +5,7 @@ */ import { set } from 'lodash'; -import { elasticsearchPingsAdapter as adapter } from '../elasticsearch_pings_adapter'; -import { assertCloseTo } from '../../../helper'; +import { elasticsearchPingsAdapter as adapter } from '../es_pings'; describe('ElasticsearchPingsAdapter class', () => { let mockHits: any[]; @@ -35,6 +34,7 @@ describe('ElasticsearchPingsAdapter class', () => { }, }, ], + interval: '1s', }, }, }; @@ -98,12 +98,11 @@ describe('ElasticsearchPingsAdapter class', () => { }); const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: 'now-15m', - dateRangeEnd: 'now', - filters: null, + dateStart: 'now-15m', + dateEnd: 'now', + filters: '', }); - assertCloseTo(result.interval, 36000, 100); - result.interval = 36000; + result.interval = '10s'; expect(mockEsClient).toHaveBeenCalledTimes(1); expect(result).toMatchSnapshot(); }); @@ -116,12 +115,11 @@ describe('ElasticsearchPingsAdapter class', () => { const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: 'now-15m', - dateRangeEnd: 'now', - filters: null, + dateStart: 'now-15m', + dateEnd: 'now', + filters: '', }); - assertCloseTo(result.interval, 36000, 100); - result.interval = 36000; + result.interval = '1m'; expect(mockEsClient).toHaveBeenCalledTimes(1); expect(result).toMatchSnapshot(); @@ -175,14 +173,13 @@ describe('ElasticsearchPingsAdapter class', () => { }; const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: '1234', - dateRangeEnd: '5678', + dateStart: '1234', + dateEnd: '5678', filters: JSON.stringify(searchFilter), monitorId: undefined, statusFilter: 'down', }); - assertCloseTo(result.interval, 5609564928000, 1000); - result.interval = 5609564928000; + result.interval = '1h'; expect(mockEsClient).toHaveBeenCalledTimes(1); expect(result).toMatchSnapshot(); @@ -229,13 +226,12 @@ describe('ElasticsearchPingsAdapter class', () => { const filters = `{"bool":{"must":[{"simple_query_string":{"query":"http"}}]}}`; const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: 'now-15m', - dateRangeEnd: 'now', + dateStart: 'now-15m', + dateEnd: 'now', filters, }); - assertCloseTo(result.interval, 36000, 100); - result.interval = 36000; + result.interval = '1m'; expect(mockEsClient).toHaveBeenCalledTimes(1); expect(result).toMatchSnapshot(); }); @@ -246,14 +242,14 @@ describe('ElasticsearchPingsAdapter class', () => { mockEsClient.mockReturnValue(standardMockResponse); const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: '1234', - dateRangeEnd: '5678', + dateStart: '1234', + dateEnd: '5678', filters: '', monitorId: undefined, statusFilter: 'down', }); - assertCloseTo(result.interval, 5609564928000, 1000); - result.interval = 5609564928000; + + result.interval = '1d'; expect(mockEsClient).toHaveBeenCalledTimes(1); expect(result).toMatchSnapshot(); @@ -267,8 +263,8 @@ describe('ElasticsearchPingsAdapter class', () => { const result = await adapter.getPingHistogram({ callES: mockEsClient, - dateRangeStart: '1234', - dateRangeEnd: '5678', + dateStart: '1234', + dateEnd: '5678', filters: '', monitorId: undefined, statusFilter: 'up', diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_get_ping_historgram.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_get_ping_historgram.ts new file mode 100644 index 0000000000000..66cae497eb081 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_get_ping_historgram.ts @@ -0,0 +1,82 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { get } from 'lodash'; +import { INDEX_NAMES, QUERY } from '../../../../common/constants'; +import { parseFilterQuery, getFilterClause } from '../../helper'; +import { UMElasticsearchQueryFn } from '../framework'; +import { GetPingHistogramParams, HistogramResult } from '../../../../common/types'; +import { HistogramQueryResult } from './types'; + +export const esGetPingHistogram: UMElasticsearchQueryFn< + GetPingHistogramParams, + HistogramResult +> = async ({ callES, dateStart, dateEnd, filters, monitorId, statusFilter }) => { + const boolFilters = parseFilterQuery(filters); + const additionalFilters = []; + if (monitorId) { + additionalFilters.push({ match: { 'monitor.id': monitorId } }); + } + if (boolFilters) { + additionalFilters.push(boolFilters); + } + const filter = getFilterClause(dateStart, dateEnd, additionalFilters); + + const params = { + index: INDEX_NAMES.HEARTBEAT, + body: { + query: { + bool: { + filter, + }, + }, + size: 0, + aggs: { + timeseries: { + auto_date_histogram: { + field: '@timestamp', + buckets: QUERY.DEFAULT_BUCKET_COUNT, + }, + aggs: { + down: { + filter: { + term: { + 'monitor.status': 'down', + }, + }, + }, + up: { + filter: { + term: { + 'monitor.status': 'up', + }, + }, + }, + }, + }, + }, + }, + }; + + const result = await callES('search', params); + const interval = result.aggregations.timeseries?.interval; + const buckets: HistogramQueryResult[] = get(result, 'aggregations.timeseries.buckets', []); + const histogram = buckets.map(bucket => { + const x: number = get(bucket, 'key'); + const downCount: number = get(bucket, 'down.doc_count'); + const upCount: number = get(bucket, 'up.doc_count'); + return { + x, + downCount: statusFilter && statusFilter !== 'down' ? 0 : downCount, + upCount: statusFilter && statusFilter !== 'up' ? 0 : upCount, + y: 1, + }; + }); + return { + histogram, + interval, + }; +}; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/elasticsearch_pings_adapter.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_pings.ts similarity index 67% rename from x-pack/legacy/plugins/uptime/server/lib/adapters/pings/elasticsearch_pings_adapter.ts rename to x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_pings.ts index adabffcb1ea4a..93e3a1bd9397b 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/elasticsearch_pings_adapter.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/es_pings.ts @@ -7,9 +7,8 @@ import { get } from 'lodash'; import { INDEX_NAMES } from '../../../../common/constants'; import { HttpBody, Ping, PingResults } from '../../../../common/graphql/types'; -import { parseFilterQuery, getFilterClause, getHistogramIntervalFormatted } from '../../helper'; -import { UMPingsAdapter, HistogramQueryResult } from './adapter_types'; -import { getHistogramInterval } from '../../helper/get_histogram_interval'; +import { UMPingsAdapter } from './types'; +import { esGetPingHistogram } from './es_get_ping_historgram'; export const elasticsearchPingsAdapter: UMPingsAdapter = { getAll: async ({ @@ -174,80 +173,7 @@ export const elasticsearchPingsAdapter: UMPingsAdapter = { return result.hits.hits[0]?._source; }, - getPingHistogram: async ({ - callES, - dateRangeStart, - dateRangeEnd, - filters, - monitorId, - statusFilter, - }) => { - const boolFilters = parseFilterQuery(filters); - const additionalFilters = []; - if (monitorId) { - additionalFilters.push({ match: { 'monitor.id': monitorId } }); - } - if (boolFilters) { - additionalFilters.push(boolFilters); - } - const filter = getFilterClause(dateRangeStart, dateRangeEnd, additionalFilters); - const interval = getHistogramInterval(dateRangeStart, dateRangeEnd); - const intervalFormatted = getHistogramIntervalFormatted(dateRangeStart, dateRangeEnd); - - const params = { - index: INDEX_NAMES.HEARTBEAT, - body: { - query: { - bool: { - filter, - }, - }, - size: 0, - aggs: { - timeseries: { - date_histogram: { - field: '@timestamp', - fixed_interval: intervalFormatted, - }, - aggs: { - down: { - filter: { - term: { - 'monitor.status': 'down', - }, - }, - }, - up: { - filter: { - term: { - 'monitor.status': 'up', - }, - }, - }, - }, - }, - }, - }, - }; - - const result = await callES('search', params); - const buckets: HistogramQueryResult[] = get(result, 'aggregations.timeseries.buckets', []); - const histogram = buckets.map(bucket => { - const x: number = get(bucket, 'key'); - const downCount: number = get(bucket, 'down.doc_count'); - const upCount: number = get(bucket, 'up.doc_count'); - return { - x, - downCount: statusFilter && statusFilter !== 'down' ? 0 : downCount, - upCount: statusFilter && statusFilter !== 'up' ? 0 : upCount, - y: 1, - }; - }); - return { - histogram, - interval, - }; - }, + getPingHistogram: esGetPingHistogram, getDocCount: async ({ callES }) => { const { count } = await callES('count', { index: INDEX_NAMES.HEARTBEAT }); diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/index.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/index.ts index 6d93785e01527..37324a8f521f6 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/index.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/index.ts @@ -4,5 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './adapter_types'; -export { elasticsearchPingsAdapter } from './elasticsearch_pings_adapter'; +export * from './types'; +export { elasticsearchPingsAdapter } from './es_pings'; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/adapter_types.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/types.ts similarity index 79% rename from x-pack/legacy/plugins/uptime/server/lib/adapters/pings/adapter_types.ts rename to x-pack/legacy/plugins/uptime/server/lib/adapters/pings/types.ts index 8b2a49c0c9ffe..b1b1589af2ca7 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/adapter_types.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/pings/types.ts @@ -5,8 +5,8 @@ */ import { DocCount, Ping, PingResults } from '../../../../common/graphql/types'; -import { HistogramResult } from '../../../../common/domain_types'; import { UMElasticsearchQueryFn } from '../framework'; +import { GetPingHistogramParams, HistogramResult } from '../../../../common/types'; export interface GetAllParams { /** @member dateRangeStart timestamp bounds */ @@ -42,19 +42,6 @@ export interface GetLatestMonitorDocsParams { monitorId?: string | null; } -export interface GetPingHistogramParams { - /** @member dateRangeStart timestamp bounds */ - dateRangeStart: string; - /** @member dateRangeEnd timestamp bounds */ - dateRangeEnd: string; - /** @member filters user-defined filters */ - filters?: string | null; - /** @member monitorId optional limit to monitorId */ - monitorId?: string | null; - /** @member statusFilter special filter targeting the latest status of each monitor */ - statusFilter?: string | null; -} - /** * Count the number of documents in heartbeat indices */ diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/heartbeat_index_pattern.json b/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/heartbeat_index_pattern.json deleted file mode 100644 index 444c7510c6a6d..0000000000000 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/heartbeat_index_pattern.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "attributes": { - "fields": "[{\"name\":\"@timestamp\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"agent.ephemeral_id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"agent.hostname\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"agent.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"agent.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"agent.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"agent.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.address\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.domain\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.packets\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.port\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"client.user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.account.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.availability_zone\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.image.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.instance.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.instance.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.machine.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.project.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.provider\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"cloud.region\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"container.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"container.image.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"container.image.tag\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"container.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"container.runtime\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.address\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.domain\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.packets\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.port\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"destination.user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"ecs.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"error.code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"error.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"error.message\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"error.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.action\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.category\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.created\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.dataset\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.duration\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.end\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.kind\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.module\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.original\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.outcome\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.risk_score\",\"type\":\"number\",\"esTypes\":[\"float\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.risk_score_norm\",\"type\":\"number\",\"esTypes\":[\"float\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.severity\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.start\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.timezone\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"event.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.ctime\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.device\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.extension\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.gid\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.group\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.inode\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.mode\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.mtime\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.owner\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.path\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.size\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.target_path\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"file.uid\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.architecture\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.containerized\",\"type\":\"boolean\",\"esTypes\":[\"boolean\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.hostname\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.build\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.codename\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.family\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.full\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.kernel\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.platform\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.os.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host.user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.request.body.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.request.body.content\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.request.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.request.method\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.request.referrer\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.response.body.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.response.body.content\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.response.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.response.status_code\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.content.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.response_header.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.total.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.validate.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.validate_body.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.rtt.write_request.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"http.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"icmp.requests\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"icmp.rtt.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.agent.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.agent.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.secured\",\"type\":\"boolean\",\"esTypes\":[\"boolean\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.server.product\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.server.vendor\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.server.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"jolokia.url\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.container.image\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.container.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.deployment.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.namespace\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.node.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.pod.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.pod.uid\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.replicaset.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"kubernetes.statefulset.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"log.level\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"log.original\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"message\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"monitor.check_group\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"monitor.duration.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"monitor.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"monitor.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"monitor.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"monitor.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.application\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.community_id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.direction\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.forwarded_ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.iana_number\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.packets\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.protocol\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.transport\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"network.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.hostname\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.family\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.full\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.kernel\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.platform\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.os.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.serial_number\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.vendor\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"observer.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"organization.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"organization.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.family\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.full\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.kernel\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.platform\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"os.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.args\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.executable\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.pid\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.ppid\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.start\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.thread.id\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.title\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"process.working_directory\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"related.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"resolve.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"resolve.rtt.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.address\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.domain\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.packets\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.port\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"server.user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.ephemeral_id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.state\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"service.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"socks5.rtt.connect.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.address\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.domain\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.city_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.continent_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.country_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.country_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.location\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.region_iso_code\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.geo.region_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.mac\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.packets\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.port\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"source.user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"summary.down\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"summary.up\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tags\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tcp.rtt.connect.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tcp.rtt.validate.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"timeseries.instance\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tls.certificate_not_valid_after\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tls.certificate_not_valid_before\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tls.rtt.handshake.us\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.domain\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.fragment\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.full\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.original\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.password\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.path\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.port\",\"type\":\"number\",\"esTypes\":[\"long\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.query\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.scheme\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url.username\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.email\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.full_name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.group.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.group.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.hash\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.id\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.device.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.original\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.family\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.full\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.kernel\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.name\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.platform\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.os.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"user_agent.version\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", - "timeFieldName": "@timestamp", - "title": "heartbeat-8*" - }, - "id": "heartbeat-8*", - "migrationVersion": { "index-pattern": "6.5.0" }, - "references": [], - "type": "index-pattern", - "updated_at": "2019-08-20T17:45:34.286Z", - "version": "1" -} diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/kibana_saved_objects_adapter.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/kibana_saved_objects_adapter.ts deleted file mode 100644 index 7628c5bac0660..0000000000000 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/kibana_saved_objects_adapter.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UMSavedObjectsAdapter } from './types'; -import uptimeIndexPattern from './heartbeat_index_pattern.json'; - -export const savedObjectsAdapter: UMSavedObjectsAdapter = { - getUptimeIndexPattern: async client => { - try { - return await client.get('index-pattern', uptimeIndexPattern.id); - } catch (error) { - return await client.create( - 'index-pattern', - { - ...uptimeIndexPattern.attributes, - title: 'UptimeIndexPattern', - }, - { id: uptimeIndexPattern.id, overwrite: false } - ); - } - }, -}; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/types.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/index.ts similarity index 62% rename from x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/types.ts rename to x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/index.ts index 0fef1e1428e97..4ef6e3fa8a6bd 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/types.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/index.ts @@ -4,8 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import { UMSavedObjectsQueryFn } from '../framework'; - -export interface UMSavedObjectsAdapter { - getUptimeIndexPattern: UMSavedObjectsQueryFn; -} +export { StubIndexPatternAdapter, stubIndexPatternAdapter } from './stub_index_pattern'; diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/stub_index_pattern.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/stub_index_pattern.ts new file mode 100644 index 0000000000000..49ec86af25040 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/stub_index_pattern.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { APICaller } from 'kibana/server'; +import { + IndexPatternsFetcher, + IIndexPattern, +} from '../../../../../../../../src/plugins/data/server'; +import { INDEX_NAMES } from '../../../../common/constants'; +import { UMElasticsearchQueryFn } from '../framework'; + +export interface StubIndexPatternAdapter { + getUptimeIndexPattern: UMElasticsearchQueryFn; +} + +export const stubIndexPatternAdapter: StubIndexPatternAdapter = { + getUptimeIndexPattern: async callES => { + const indexPatternsFetcher = new IndexPatternsFetcher((...rest: Parameters) => + callES(...rest) + ); + + // Since `getDynamicIndexPattern` is called in setup_request (and thus by every endpoint) + // and since `getFieldsForWildcard` will throw if the specified indices don't exist, + // we have to catch errors here to avoid all endpoints returning 500 for users without APM data + // (would be a bad first time experience) + try { + const fields = await indexPatternsFetcher.getFieldsForWildcard({ + pattern: INDEX_NAMES.HEARTBEAT, + }); + + const indexPattern: IIndexPattern = { + fields, + title: INDEX_NAMES.HEARTBEAT, + }; + + return indexPattern; + } catch (e) { + const notExists = e.output?.statusCode === 404; + if (notExists) { + // eslint-disable-next-line no-console + console.error( + `Could not get dynamic index pattern because indices "${INDEX_NAMES.HEARTBEAT}" don't exist` + ); + return; + } + + // re-throw + throw e; + } + }, +}; diff --git a/x-pack/legacy/plugins/uptime/server/lib/compose/kibana.ts b/x-pack/legacy/plugins/uptime/server/lib/compose/kibana.ts index cc11bf90da5f3..b44a890de3819 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/compose/kibana.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/compose/kibana.ts @@ -10,7 +10,7 @@ import { elasticsearchPingsAdapter } from '../adapters/pings'; import { licenseCheck } from '../domains'; import { UMDomainLibs, UMServerLibs } from '../lib'; import { elasticsearchMonitorStatesAdapter } from '../adapters/monitor_states'; -import { savedObjectsAdapter } from '../adapters/saved_objects'; +import { stubIndexPatternAdapter } from '../adapters/stub_index_pattern'; import { UptimeCorePlugins, UptimeCoreSetup } from '../adapters/framework'; export function compose(server: UptimeCoreSetup, plugins: UptimeCorePlugins): UMServerLibs { @@ -21,7 +21,7 @@ export function compose(server: UptimeCoreSetup, plugins: UptimeCorePlugins): UM monitors: elasticsearchMonitorsAdapter, monitorStates: elasticsearchMonitorStatesAdapter, pings: elasticsearchPingsAdapter, - savedObjects: savedObjectsAdapter, + stubIndexPattern: stubIndexPatternAdapter, }; return { diff --git a/x-pack/legacy/plugins/uptime/server/lib/helper/assert_close_to.ts b/x-pack/legacy/plugins/uptime/server/lib/helper/assert_close_to.ts index 13b6f3688809c..45b76ba25470b 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/helper/assert_close_to.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/helper/assert_close_to.ts @@ -8,4 +8,9 @@ export const assertCloseTo = (actual: number, expected: number, precision: numbe if (Math.abs(expected - actual) > precision) { throw new Error(`expected [${expected}] to be within ${precision} of ${actual}`); } + + // if actual is undefined above math condition will be NAN and it will be always false + if (actual === undefined) { + throw new Error(`expected close to [${expected}] but got [${actual}]`); + } }; diff --git a/x-pack/legacy/plugins/uptime/server/lib/helper/index.ts b/x-pack/legacy/plugins/uptime/server/lib/helper/index.ts index f9a8de81332d5..eae8023b66ff4 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/helper/index.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/helper/index.ts @@ -5,7 +5,6 @@ */ export { getFilterClause } from './get_filter_clause'; -export { getHistogramInterval } from './get_histogram_interval'; export { getHistogramIntervalFormatted } from './get_histogram_interval_formatted'; export { parseFilterQuery } from './parse_filter_query'; export { assertCloseTo } from './assert_close_to'; diff --git a/x-pack/legacy/plugins/uptime/server/lib/lib.ts b/x-pack/legacy/plugins/uptime/server/lib/lib.ts index da87c3ebfe301..e5ab9940d482d 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/lib.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/lib.ts @@ -9,7 +9,7 @@ import { UMMonitorsAdapter, UMMonitorStatesAdapter, UMPingsAdapter, - UMSavedObjectsAdapter, + StubIndexPatternAdapter, } from './adapters'; import { UMLicenseCheck } from './domains'; @@ -18,7 +18,7 @@ export interface UMDomainLibs { monitors: UMMonitorsAdapter; monitorStates: UMMonitorStatesAdapter; pings: UMPingsAdapter; - savedObjects: UMSavedObjectsAdapter; + stubIndexPattern: StubIndexPatternAdapter; } export interface UMServerLibs extends UMDomainLibs { diff --git a/x-pack/legacy/plugins/uptime/server/rest_api/index.ts b/x-pack/legacy/plugins/uptime/server/rest_api/index.ts index e64b317e67f98..91936b499d8e6 100644 --- a/x-pack/legacy/plugins/uptime/server/rest_api/index.ts +++ b/x-pack/legacy/plugins/uptime/server/rest_api/index.ts @@ -16,6 +16,7 @@ import { createGetMonitorLocationsRoute, createGetStatusBarRoute, } from './monitors'; +import { createGetPingHistogramRoute } from './pings/get_ping_histogram'; export * from './types'; export { createRouteWithAuth } from './create_route_with_auth'; @@ -31,4 +32,5 @@ export const restApiRoutes: UMRestApiRouteFactory[] = [ createGetSnapshotCount, createLogMonitorPageRoute, createLogOverviewPageRoute, + createGetPingHistogramRoute, ]; diff --git a/x-pack/legacy/plugins/uptime/server/rest_api/index_pattern/get_index_pattern.ts b/x-pack/legacy/plugins/uptime/server/rest_api/index_pattern/get_index_pattern.ts index f061307807a42..cee8eaf3f9cae 100644 --- a/x-pack/legacy/plugins/uptime/server/rest_api/index_pattern/get_index_pattern.ts +++ b/x-pack/legacy/plugins/uptime/server/rest_api/index_pattern/get_index_pattern.ts @@ -14,11 +14,11 @@ export const createGetIndexPatternRoute: UMRestApiRouteFactory = (libs: UMServer options: { tags: ['access:uptime'], }, - handler: async ({ savedObjectsClient: client }, _context, _request, response): Promise => { + handler: async ({ callES }, _context, _request, response): Promise => { try { return response.ok({ body: { - ...(await libs.savedObjects.getUptimeIndexPattern(client, undefined)), + ...(await libs.stubIndexPattern.getUptimeIndexPattern(callES)), }, }); } catch (e) { diff --git a/x-pack/legacy/plugins/uptime/server/rest_api/pings/get_ping_histogram.ts b/x-pack/legacy/plugins/uptime/server/rest_api/pings/get_ping_histogram.ts new file mode 100644 index 0000000000000..c8eb2a1e40ad4 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/server/rest_api/pings/get_ping_histogram.ts @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { schema } from '@kbn/config-schema'; +import { UMServerLibs } from '../../lib/lib'; +import { UMRestApiRouteFactory } from '../types'; + +export const createGetPingHistogramRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({ + method: 'GET', + path: '/api/uptime/ping/histogram', + validate: { + query: schema.object({ + dateStart: schema.string(), + dateEnd: schema.string(), + monitorId: schema.maybe(schema.string()), + statusFilter: schema.maybe(schema.string()), + filters: schema.maybe(schema.string()), + }), + }, + options: { + tags: ['access:uptime'], + }, + handler: async ({ callES }, _context, request, response): Promise => { + const { dateStart, dateEnd, statusFilter, monitorId, filters } = request.query; + + const result = await libs.pings.getPingHistogram({ + callES, + dateStart, + dateEnd, + monitorId, + statusFilter, + filters, + }); + + return response.ok({ + body: { + ...result, + }, + }); + }, +}); diff --git a/x-pack/plugins/console_extensions/kibana.json b/x-pack/plugins/console_extensions/kibana.json new file mode 100644 index 0000000000000..9411523d3f6dd --- /dev/null +++ b/x-pack/plugins/console_extensions/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "consoleExtensions", + "version": "1.0.0", + "kibanaVersion": "kibana", + "requiredPlugins": ["console"], + "server": true, + "ui": false +} diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/to_static_index_pattern.ts b/x-pack/plugins/console_extensions/server/config.ts similarity index 56% rename from x-pack/legacy/plugins/uptime/public/lib/helper/to_static_index_pattern.ts rename to x-pack/plugins/console_extensions/server/config.ts index b8a12c1e578e3..c429e0fce13fa 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/to_static_index_pattern.ts +++ b/x-pack/plugins/console_extensions/server/config.ts @@ -3,9 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { schema, TypeOf } from '@kbn/config-schema'; -export const toStaticIndexPattern = (indexPattern: any) => ({ - ...indexPattern, - fields: JSON.parse(indexPattern.attributes.fields), - title: indexPattern.id, +export type ConfigType = TypeOf; + +export const config = schema.object({ + enabled: schema.boolean({ defaultValue: true }), }); diff --git a/x-pack/plugins/console_extensions/server/index.ts b/x-pack/plugins/console_extensions/server/index.ts new file mode 100644 index 0000000000000..7fc16d4507da9 --- /dev/null +++ b/x-pack/plugins/console_extensions/server/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { PluginInitializerContext, PluginConfigDescriptor } from 'kibana/server'; + +import { config as configSchema, ConfigType } from './config'; +import { ConsoleExtensionsServerPlugin } from './plugin'; + +export const plugin = (ctx: PluginInitializerContext) => new ConsoleExtensionsServerPlugin(ctx); + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; diff --git a/x-pack/plugins/console_extensions/server/plugin.ts b/x-pack/plugins/console_extensions/server/plugin.ts new file mode 100644 index 0000000000000..f4c41aa0a0ad5 --- /dev/null +++ b/x-pack/plugins/console_extensions/server/plugin.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { join } from 'path'; +import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; + +import { ConsoleSetup } from '../../../../src/plugins/console/server'; + +import { processors } from './spec/ingest/index'; + +interface SetupDependencies { + console: ConsoleSetup; +} + +export class ConsoleExtensionsServerPlugin implements Plugin { + log: Logger; + constructor(private readonly ctx: PluginInitializerContext) { + this.log = this.ctx.logger.get(); + } + + setup( + core: CoreSetup, + { console: { addProcessorDefinition, addExtensionSpecFilePath } }: SetupDependencies + ) { + addExtensionSpecFilePath(join(__dirname, 'spec/')); + processors.forEach(processor => addProcessorDefinition(processor)); + this.log.debug('Installed console autocomplete extensions.'); + } + start() {} +} diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.delete_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.delete_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.delete_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.delete_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.follow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow_info.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_info.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow_info.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_info.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.follow_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.follow_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.forget_follower.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.forget_follower.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.forget_follower.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.forget_follower.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.get_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.get_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.get_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.get_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.pause_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.pause_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.pause_follow.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_follow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.pause_follow.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.pause_follow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.put_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.put_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.put_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.put_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.resume_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.resume_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.resume_follow.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_follow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.resume_follow.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.resume_follow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ccr.unfollow.json b/x-pack/plugins/console_extensions/server/spec/generated/ccr.unfollow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ccr.unfollow.json rename to x-pack/plugins/console_extensions/server/spec/generated/ccr.unfollow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/enrich.delete_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/enrich.delete_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/enrich.delete_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/enrich.delete_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/enrich.execute_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/enrich.execute_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/enrich.execute_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/enrich.execute_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/enrich.get_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/enrich.get_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/enrich.get_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/enrich.get_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/enrich.put_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/enrich.put_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/enrich.put_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/enrich.put_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/enrich.stats.json b/x-pack/plugins/console_extensions/server/spec/generated/enrich.stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/enrich.stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/enrich.stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/graph.explore.json b/x-pack/plugins/console_extensions/server/spec/generated/graph.explore.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/graph.explore.json rename to x-pack/plugins/console_extensions/server/spec/generated/graph.explore.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.delete_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.delete_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.delete_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.delete_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.explain_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.explain_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.explain_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.explain_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.get_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.get_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.get_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.get_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.get_status.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.get_status.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.get_status.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.get_status.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.move_to_step.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.move_to_step.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.move_to_step.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.move_to_step.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.put_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.put_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.remove_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.remove_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.remove_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.remove_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.retry.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.retry.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.retry.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.retry.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.set_policy.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.set_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.set_policy.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.set_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.start.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.start.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.start.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.start.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ilm.stop.json b/x-pack/plugins/console_extensions/server/spec/generated/ilm.stop.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ilm.stop.json rename to x-pack/plugins/console_extensions/server/spec/generated/ilm.stop.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/indices.freeze.json b/x-pack/plugins/console_extensions/server/spec/generated/indices.freeze.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/indices.freeze.json rename to x-pack/plugins/console_extensions/server/spec/generated/indices.freeze.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/indices.reload_search_analyzers.json b/x-pack/plugins/console_extensions/server/spec/generated/indices.reload_search_analyzers.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/indices.reload_search_analyzers.json rename to x-pack/plugins/console_extensions/server/spec/generated/indices.reload_search_analyzers.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/indices.unfreeze.json b/x-pack/plugins/console_extensions/server/spec/generated/indices.unfreeze.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/indices.unfreeze.json rename to x-pack/plugins/console_extensions/server/spec/generated/indices.unfreeze.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.delete.json b/x-pack/plugins/console_extensions/server/spec/generated/license.delete.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.delete.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.delete.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.get.json b/x-pack/plugins/console_extensions/server/spec/generated/license.get.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.get.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.get.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.get_basic_status.json b/x-pack/plugins/console_extensions/server/spec/generated/license.get_basic_status.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.get_basic_status.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.get_basic_status.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.get_trial_status.json b/x-pack/plugins/console_extensions/server/spec/generated/license.get_trial_status.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.get_trial_status.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.get_trial_status.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.post.json b/x-pack/plugins/console_extensions/server/spec/generated/license.post.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.post.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.post.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.post_start_basic.json b/x-pack/plugins/console_extensions/server/spec/generated/license.post_start_basic.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.post_start_basic.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.post_start_basic.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/license.post_start_trial.json b/x-pack/plugins/console_extensions/server/spec/generated/license.post_start_trial.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/license.post_start_trial.json rename to x-pack/plugins/console_extensions/server/spec/generated/license.post_start_trial.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/migration.deprecations.json b/x-pack/plugins/console_extensions/server/spec/generated/migration.deprecations.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/migration.deprecations.json rename to x-pack/plugins/console_extensions/server/spec/generated/migration.deprecations.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/migration.get_assistance.json b/x-pack/plugins/console_extensions/server/spec/generated/migration.get_assistance.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/migration.get_assistance.json rename to x-pack/plugins/console_extensions/server/spec/generated/migration.get_assistance.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/migration.upgrade.json b/x-pack/plugins/console_extensions/server/spec/generated/migration.upgrade.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/migration.upgrade.json rename to x-pack/plugins/console_extensions/server/spec/generated/migration.upgrade.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.close_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.close_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.close_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.close_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar_event.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_event.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar_event.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_event.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_calendar_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_calendar_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_expired_data.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_expired_data.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_expired_data.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_expired_data.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_filter.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_filter.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_filter.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_filter.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_forecast.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_forecast.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_forecast.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_forecast.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_model_snapshot.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_model_snapshot.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_model_snapshot.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_model_snapshot.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_trained_model.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.delete_trained_model.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.delete_trained_model.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.delete_trained_model.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.estimate_memory_usage.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.estimate_memory_usage.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.estimate_memory_usage.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.estimate_memory_usage.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.evaluate_data_frame.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.evaluate_data_frame.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.evaluate_data_frame.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.evaluate_data_frame.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.explain_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.explain_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.explain_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.explain_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.find_file_structure.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.find_file_structure.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.find_file_structure.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.find_file_structure.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.flush_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.flush_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.flush_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.flush_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.forecast.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.forecast.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.forecast.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.forecast.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_buckets.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_buckets.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_buckets.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_buckets.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_calendar_events.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendar_events.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_calendar_events.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendar_events.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_calendars.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendars.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_calendars.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_calendars.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_categories.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_categories.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_categories.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_categories.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_data_frame_analytics_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_data_frame_analytics_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_data_frame_analytics_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_datafeed_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeed_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_datafeed_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeed_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_datafeeds.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeeds.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_datafeeds.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_datafeeds.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_filters.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_filters.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_filters.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_filters.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_influencers.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_influencers.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_influencers.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_influencers.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_job_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_job_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_job_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_job_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_jobs.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_jobs.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_jobs.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_jobs.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_model_snapshots.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_model_snapshots.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_model_snapshots.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_model_snapshots.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_overall_buckets.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_overall_buckets.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_overall_buckets.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_overall_buckets.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_records.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_records.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_records.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_records.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_trained_models.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_trained_models.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_trained_models_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.get_trained_models_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.get_trained_models_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.info.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.info.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.info.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.info.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.open_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.open_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.open_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.open_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.post_calendar_events.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.post_calendar_events.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.post_calendar_events.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.post_calendar_events.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.post_data.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.post_data.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.post_data.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.post_data.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.preview_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.preview_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.preview_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.preview_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_calendar.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_calendar.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_calendar_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_calendar_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_calendar_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_filter.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_filter.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_filter.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_filter.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_trained_model.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.put_trained_model.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.put_trained_model.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.put_trained_model.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.revert_model_snapshot.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.revert_model_snapshot.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.revert_model_snapshot.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.revert_model_snapshot.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.set_upgrade_mode.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.set_upgrade_mode.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.set_upgrade_mode.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.set_upgrade_mode.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.start_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.start_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.start_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.start_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.start_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.start_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.start_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.start_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.stop_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.stop_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.stop_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.stop_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.stop_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.stop_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.stop_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.stop_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_datafeed.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.update_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.update_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_filter.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.update_filter.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_filter.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.update_filter.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_job.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.update_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.update_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_model_snapshot.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.update_model_snapshot.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.update_model_snapshot.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.update_model_snapshot.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.upgrade.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.upgrade.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.upgrade.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.upgrade.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.validate.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.validate.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.validate.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.validate.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ml.validate_detector.json b/x-pack/plugins/console_extensions/server/spec/generated/ml.validate_detector.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ml.validate_detector.json rename to x-pack/plugins/console_extensions/server/spec/generated/ml.validate_detector.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/monitoring.bulk.json b/x-pack/plugins/console_extensions/server/spec/generated/monitoring.bulk.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/monitoring.bulk.json rename to x-pack/plugins/console_extensions/server/spec/generated/monitoring.bulk.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.delete_job.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.delete_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.delete_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.delete_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_jobs.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_jobs.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_jobs.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.get_jobs.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_rollup_caps.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_caps.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_rollup_caps.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_caps.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_rollup_index_caps.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_index_caps.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.get_rollup_index_caps.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.get_rollup_index_caps.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.put_job.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.put_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.put_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.put_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.rollup_search.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.rollup_search.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.rollup_search.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.rollup_search.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.start_job.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.start_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.start_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.start_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/rollup.stop_job.json b/x-pack/plugins/console_extensions/server/spec/generated/rollup.stop_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/rollup.stop_job.json rename to x-pack/plugins/console_extensions/server/spec/generated/rollup.stop_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.authenticate.json b/x-pack/plugins/console_extensions/server/spec/generated/security.authenticate.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.authenticate.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.authenticate.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.change_password.json b/x-pack/plugins/console_extensions/server/spec/generated/security.change_password.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.change_password.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.change_password.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.clear_cached_realms.json b/x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_realms.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.clear_cached_realms.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_realms.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.clear_cached_roles.json b/x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_roles.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.clear_cached_roles.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.clear_cached_roles.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.create_api_key.json b/x-pack/plugins/console_extensions/server/spec/generated/security.create_api_key.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.create_api_key.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.create_api_key.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.delete_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.delete_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_role.json b/x-pack/plugins/console_extensions/server/spec/generated/security.delete_role.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_role.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.delete_role.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_role_mapping.json b/x-pack/plugins/console_extensions/server/spec/generated/security.delete_role_mapping.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_role_mapping.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.delete_role_mapping.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_user.json b/x-pack/plugins/console_extensions/server/spec/generated/security.delete_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.delete_user.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.delete_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.disable_user.json b/x-pack/plugins/console_extensions/server/spec/generated/security.disable_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.disable_user.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.disable_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.enable_user.json b/x-pack/plugins/console_extensions/server/spec/generated/security.enable_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.enable_user.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.enable_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_api_key.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_api_key.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_api_key.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_api_key.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_builtin_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_builtin_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_builtin_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_builtin_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_role.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_role.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_role.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_role.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_role_mapping.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_role_mapping.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_role_mapping.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_role_mapping.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_token.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_token.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_user.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_user.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.get_user_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.get_user_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.get_user_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.get_user_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.has_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.has_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.has_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.has_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.invalidate_api_key.json b/x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_api_key.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.invalidate_api_key.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_api_key.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.invalidate_token.json b/x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.invalidate_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.put_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json similarity index 89% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.put_privileges.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json index 7ecffc780c066..a42d5eb6c953e 100644 --- a/x-pack/legacy/plugins/console_extensions/spec/generated/security.put_privileges.json +++ b/x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json @@ -12,7 +12,7 @@ "POST" ], "patterns": [ - "_security/privilege/" + "_security/privilege" ], "documentation": "TODO" } diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.put_role.json b/x-pack/plugins/console_extensions/server/spec/generated/security.put_role.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.put_role.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.put_role.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/spec/generated/security.put_role_mapping.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.put_role_mapping.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/security.put_user.json b/x-pack/plugins/console_extensions/server/spec/generated/security.put_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/security.put_user.json rename to x-pack/plugins/console_extensions/server/spec/generated/security.put_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.delete_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.delete_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.delete_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.delete_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.execute_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.execute_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.execute_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.execute_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.execute_retention.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.execute_retention.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.execute_retention.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.execute_retention.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.get_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.get_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.get_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.get_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_status.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.get_status.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.get_status.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.get_status.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.put_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.put_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.start.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.start.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.start.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.start.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/slm.stop.json b/x-pack/plugins/console_extensions/server/spec/generated/slm.stop.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/slm.stop.json rename to x-pack/plugins/console_extensions/server/spec/generated/slm.stop.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/sql.clear_cursor.json b/x-pack/plugins/console_extensions/server/spec/generated/sql.clear_cursor.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/sql.clear_cursor.json rename to x-pack/plugins/console_extensions/server/spec/generated/sql.clear_cursor.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/sql.query.json b/x-pack/plugins/console_extensions/server/spec/generated/sql.query.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/sql.query.json rename to x-pack/plugins/console_extensions/server/spec/generated/sql.query.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/sql.translate.json b/x-pack/plugins/console_extensions/server/spec/generated/sql.translate.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/sql.translate.json rename to x-pack/plugins/console_extensions/server/spec/generated/sql.translate.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/ssl.certificates.json b/x-pack/plugins/console_extensions/server/spec/generated/ssl.certificates.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/ssl.certificates.json rename to x-pack/plugins/console_extensions/server/spec/generated/ssl.certificates.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.delete_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.delete_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.delete_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.delete_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.get_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.get_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.get_transform_stats.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.get_transform_stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.get_transform_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.preview_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.preview_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.preview_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.preview_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.put_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.put_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.put_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.put_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.start_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.start_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.start_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.start_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.stop_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.stop_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.stop_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.stop_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/transform.update_transform.json b/x-pack/plugins/console_extensions/server/spec/generated/transform.update_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/transform.update_transform.json rename to x-pack/plugins/console_extensions/server/spec/generated/transform.update_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.ack_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.ack_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.ack_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.ack_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.activate_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.activate_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.activate_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.activate_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.deactivate_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.deactivate_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.deactivate_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.deactivate_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.delete_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.delete_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.delete_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.delete_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.execute_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.execute_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.execute_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.execute_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.get_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.get_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.get_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.get_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.put_watch.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.put_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.put_watch.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.put_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.start.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.start.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.start.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.start.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.stats.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.stats.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/watcher.stop.json b/x-pack/plugins/console_extensions/server/spec/generated/watcher.stop.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/watcher.stop.json rename to x-pack/plugins/console_extensions/server/spec/generated/watcher.stop.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/xpack.info.json b/x-pack/plugins/console_extensions/server/spec/generated/xpack.info.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/xpack.info.json rename to x-pack/plugins/console_extensions/server/spec/generated/xpack.info.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/xpack.ssl.certificates.json b/x-pack/plugins/console_extensions/server/spec/generated/xpack.ssl.certificates.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/xpack.ssl.certificates.json rename to x-pack/plugins/console_extensions/server/spec/generated/xpack.ssl.certificates.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/generated/xpack.usage.json b/x-pack/plugins/console_extensions/server/spec/generated/xpack.usage.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/generated/xpack.usage.json rename to x-pack/plugins/console_extensions/server/spec/generated/xpack.usage.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/ingest/index.js b/x-pack/plugins/console_extensions/server/spec/ingest/index.ts similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/ingest/index.js rename to x-pack/plugins/console_extensions/server/spec/ingest/index.ts diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.follow.json b/x-pack/plugins/console_extensions/server/spec/overrides/ccr.follow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.follow.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ccr.follow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.forget_follower.json b/x-pack/plugins/console_extensions/server/spec/overrides/ccr.forget_follower.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.forget_follower.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ccr.forget_follower.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.put_auto_follow_pattern.json b/x-pack/plugins/console_extensions/server/spec/overrides/ccr.put_auto_follow_pattern.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.put_auto_follow_pattern.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ccr.put_auto_follow_pattern.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.resume_follow.json b/x-pack/plugins/console_extensions/server/spec/overrides/ccr.resume_follow.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ccr.resume_follow.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ccr.resume_follow.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/enrich.put_policy.json b/x-pack/plugins/console_extensions/server/spec/overrides/enrich.put_policy.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/enrich.put_policy.json rename to x-pack/plugins/console_extensions/server/spec/overrides/enrich.put_policy.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ilm.move_to_step.json b/x-pack/plugins/console_extensions/server/spec/overrides/ilm.move_to_step.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ilm.move_to_step.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ilm.move_to_step.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ilm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/overrides/ilm.put_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ilm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ilm.put_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.estimate_memory_usage.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.estimate_memory_usage.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.estimate_memory_usage.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.estimate_memory_usage.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.evaluate_data_frame.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.evaluate_data_frame.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.evaluate_data_frame.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.evaluate_data_frame.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.explain_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.explain_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.explain_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.explain_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_buckets.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_buckets.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_buckets.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_buckets.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_calendar_events.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendar_events.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_calendar_events.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendar_events.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_calendars.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendars.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_calendars.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_calendars.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_categories.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_categories.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_categories.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_categories.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_influencers.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_influencers.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_influencers.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_influencers.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_model_snapshots.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_model_snapshots.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_model_snapshots.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_model_snapshots.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_overall_buckets.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_overall_buckets.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_overall_buckets.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_overall_buckets.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_records.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.get_records.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.get_records.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.get_records.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.post_calendar_events.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.post_calendar_events.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.post_calendar_events.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.post_calendar_events.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_calendar.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_calendar.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_calendar.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.put_calendar.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_data_frame_analytics.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_data_frame_analytics.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_data_frame_analytics.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.put_data_frame_analytics.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_datafeed.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.put_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_job.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_job.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.put_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_trained_model.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.put_trained_model.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.put_trained_model.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.put_trained_model.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.revert_model_snapshot.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.revert_model_snapshot.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.revert_model_snapshot.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.revert_model_snapshot.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_datafeed.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_datafeed.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_datafeed.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.update_datafeed.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_job.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_job.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.update_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_model_snapshot.json b/x-pack/plugins/console_extensions/server/spec/overrides/ml.update_model_snapshot.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/ml.update_model_snapshot.json rename to x-pack/plugins/console_extensions/server/spec/overrides/ml.update_model_snapshot.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.authenticate.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.authenticate.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.authenticate.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.authenticate.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.change_password.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.change_password.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.change_password.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.change_password.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.create_api_key.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.create_api_key.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.create_api_key.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.create_api_key.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.delete_privileges.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.delete_privileges.json similarity index 76% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.delete_privileges.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.delete_privileges.json index 35fb78c532c12..5486098ff7bd8 100644 --- a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.delete_privileges.json +++ b/x-pack/plugins/console_extensions/server/spec/overrides/security.delete_privileges.json @@ -1,3 +1,5 @@ { + "security.delete_privileges": { "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html" + } } diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.get_token.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.get_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.get_token.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.get_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.has_privileges.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.has_privileges.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.has_privileges.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.has_privileges.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.invalidate_api_key.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_api_key.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.invalidate_api_key.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_api_key.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.invalidate_token.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.invalidate_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_privileges.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_privileges.json similarity index 77% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_privileges.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.put_privileges.json index ae37d9a889543..9ebb1046047a7 100644 --- a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_privileges.json +++ b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_privileges.json @@ -1,3 +1,5 @@ { + "security.put_privileges": { "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html" + } } diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_role.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_role.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_role.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.put_role.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_role_mapping.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.put_role_mapping.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_user.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/security.put_user.json rename to x-pack/plugins/console_extensions/server/spec/overrides/security.put_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/slm.put_lifecycle.json b/x-pack/plugins/console_extensions/server/spec/overrides/slm.put_lifecycle.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/slm.put_lifecycle.json rename to x-pack/plugins/console_extensions/server/spec/overrides/slm.put_lifecycle.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/slm.start.json b/x-pack/plugins/console_extensions/server/spec/overrides/slm.start.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/slm.start.json rename to x-pack/plugins/console_extensions/server/spec/overrides/slm.start.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/slm.stop.json b/x-pack/plugins/console_extensions/server/spec/overrides/slm.stop.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/slm.stop.json rename to x-pack/plugins/console_extensions/server/spec/overrides/slm.stop.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/sql.query.json b/x-pack/plugins/console_extensions/server/spec/overrides/sql.query.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/sql.query.json rename to x-pack/plugins/console_extensions/server/spec/overrides/sql.query.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/transform.get_transform_stats.json b/x-pack/plugins/console_extensions/server/spec/overrides/transform.get_transform_stats.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/transform.get_transform_stats.json rename to x-pack/plugins/console_extensions/server/spec/overrides/transform.get_transform_stats.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/transform.preview_transform.json b/x-pack/plugins/console_extensions/server/spec/overrides/transform.preview_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/transform.preview_transform.json rename to x-pack/plugins/console_extensions/server/spec/overrides/transform.preview_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/transform.put_transform.json b/x-pack/plugins/console_extensions/server/spec/overrides/transform.put_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/transform.put_transform.json rename to x-pack/plugins/console_extensions/server/spec/overrides/transform.put_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/transform.stop_transform.json b/x-pack/plugins/console_extensions/server/spec/overrides/transform.stop_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/transform.stop_transform.json rename to x-pack/plugins/console_extensions/server/spec/overrides/transform.stop_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/transform.update_transform.json b/x-pack/plugins/console_extensions/server/spec/overrides/transform.update_transform.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/transform.update_transform.json rename to x-pack/plugins/console_extensions/server/spec/overrides/transform.update_transform.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.graph.explore.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.graph.explore.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.graph.explore.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.graph.explore.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.info.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.info.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.info.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.info.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.license.post.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.license.post.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.license.post.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.license.post.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.delete_job.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.delete_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.delete_job.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.delete_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.put_job.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.put_job.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.put_job.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.put_job.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.rollup_search.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.rollup_search.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.rollup.rollup_search.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.rollup.rollup_search.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.authenticate.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.authenticate.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.authenticate.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.authenticate.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.change_password.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.change_password.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.change_password.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.change_password.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.get_token.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.get_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.get_token.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.get_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.invalidate_token.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.invalidate_token.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.invalidate_token.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.invalidate_token.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_role.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_role.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_role_mapping.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role_mapping.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_role_mapping.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_role_mapping.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_user.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_user.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.security.put_user.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.security.put_user.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.watcher.execute_watch.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.execute_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.watcher.execute_watch.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.execute_watch.json diff --git a/x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.watcher.put_watch.json b/x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.put_watch.json similarity index 100% rename from x-pack/legacy/plugins/console_extensions/spec/overrides/xpack.watcher.put_watch.json rename to x-pack/plugins/console_extensions/server/spec/overrides/xpack.watcher.put_watch.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram.json deleted file mode 100644 index cf88ccae9cb99..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram.json +++ /dev/null @@ -1,188 +0,0 @@ -{ - "queryResult": { - "histogram": [ - { - "upCount": 93, - "downCount": 7, - "x": 1568172657286, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172680087, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172702888, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172725689, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172748490, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172771291, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568172794092, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172816893, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172839694, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172862495, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172885296, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172908097, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172930898, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172953699, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568172976500, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172999301, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173022102, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173044903, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173067704, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173090505, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173113306, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173136107, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568173158908, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173181709, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173204510, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173227311, - "x0": null, - "y": 1 - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_filter.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_filter.json deleted file mode 100644 index 383d4acd96340..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_filter.json +++ /dev/null @@ -1,188 +0,0 @@ -{ - "queryResult": { - "histogram": [ - { - "upCount": 93, - "downCount": 0, - "x": 1568172657286, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172680087, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172702888, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172725689, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172748490, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172771291, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 0, - "x": 1568172794092, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172816893, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172839694, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172862495, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172885296, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172908097, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172930898, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568172953699, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 0, - "x": 1568172976500, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172999301, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173022102, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173044903, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173067704, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173090505, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173113306, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173136107, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 0, - "x": 1568173158908, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173181709, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173204510, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 0, - "x": 1568173227311, - "x0": null, - "y": 1 - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_id.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_id.json deleted file mode 100644 index cf88ccae9cb99..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_histogram_by_id.json +++ /dev/null @@ -1,188 +0,0 @@ -{ - "queryResult": { - "histogram": [ - { - "upCount": 93, - "downCount": 7, - "x": 1568172657286, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172680087, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172702888, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172725689, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172748490, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172771291, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568172794092, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172816893, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172839694, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172862495, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172885296, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172908097, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172930898, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568172953699, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568172976500, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568172999301, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173022102, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173044903, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173067704, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173090505, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173113306, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173136107, - "x0": null, - "y": 1 - }, - { - "upCount": 92, - "downCount": 8, - "x": 1568173158908, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173181709, - "x0": null, - "y": 1 - }, - { - "upCount": 0, - "downCount": 0, - "x": 1568173204510, - "x0": null, - "y": 1 - }, - { - "upCount": 93, - "downCount": 7, - "x": 1568173227311, - "x0": null, - "y": 1 - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/index.js b/x-pack/test/api_integration/apis/uptime/graphql/index.js index 64999761fde4e..54284377ec430 100644 --- a/x-pack/test/api_integration/apis/uptime/graphql/index.js +++ b/x-pack/test/api_integration/apis/uptime/graphql/index.js @@ -14,6 +14,5 @@ export default function({ loadTestFile }) { loadTestFile(require.resolve('./monitor_charts')); loadTestFile(require.resolve('./monitor_states')); loadTestFile(require.resolve('./ping_list')); - loadTestFile(require.resolve('./snapshot_histogram')); }); } diff --git a/x-pack/test/api_integration/apis/uptime/graphql/snapshot_histogram.ts b/x-pack/test/api_integration/apis/uptime/graphql/snapshot_histogram.ts deleted file mode 100644 index 02fd3fd630d4b..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/snapshot_histogram.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { snapshotHistogramQueryString } from '../../../../../legacy/plugins/uptime/public/queries/snapshot_histogram_query'; -import { expectFixtureEql } from './helpers/expect_fixture_eql'; -import { FtrProviderContext } from '../../../ftr_provider_context'; -import { assertCloseTo } from '../../../../../legacy/plugins/uptime/server/lib/helper'; - -export default function({ getService }: FtrProviderContext) { - describe('snapshotHistogram', () => { - before('load heartbeat data', () => getService('esArchiver').load('uptime/full_heartbeat')); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/full_heartbeat')); - - const supertest = getService('supertest'); - - it('will fetch histogram data for all monitors', async () => { - const getSnapshotHistogramQuery = { - operationName: 'SnapshotHistogram', - query: snapshotHistogramQueryString, - variables: { - dateRangeStart: '2019-09-11T03:31:04.380Z', - dateRangeEnd: '2019-09-11T03:40:34.410Z', - }, - }; - - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...getSnapshotHistogramQuery }); - // manually testing this value and then removing it to avoid flakiness - const { interval } = data.queryResult; - assertCloseTo(interval, 22801, 100); - delete data.queryResult.interval; - expectFixtureEql(data, 'snapshot_histogram'); - }); - - it('will fetch histogram data for a given monitor id', async () => { - const getSnapshotHistogramQuery = { - operationName: 'SnapshotHistogram', - query: snapshotHistogramQueryString, - variables: { - dateRangeStart: '2019-09-11T03:31:04.380Z', - dateRangeEnd: '2019-09-11T03:40:34.410Z', - }, - }; - - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...getSnapshotHistogramQuery }); - const { interval } = data.queryResult; - assertCloseTo(interval, 22801, 100); - delete data.queryResult.interval; - expectFixtureEql(data, 'snapshot_histogram_by_id'); - }); - - it('will fetch histogram data for a given filter', async () => { - const getSnapshotHistogramQuery = { - operationName: 'SnapshotHistogram', - query: snapshotHistogramQueryString, - variables: { - dateRangeStart: '2019-09-11T03:31:04.380Z', - dateRangeEnd: '2019-09-11T03:40:34.410Z', - filters: - '{"bool":{"must":[{"match":{"monitor.status":{"query":"up","operator":"and"}}}]}}', - }, - }; - - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...getSnapshotHistogramQuery }); - const { interval } = data.queryResult; - assertCloseTo(interval, 22801, 100); - delete data.queryResult.interval; - expectFixtureEql(data, 'snapshot_histogram_by_filter'); - }); - }); -} diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram.json new file mode 100644 index 0000000000000..972d1fd51760c --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram.json @@ -0,0 +1,24 @@ +{ + "histogram": [ + { "x": 1568172664000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172694000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172724000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172754000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172784000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172814000, "downCount": 8, "upCount": 92, "y": 1 }, + { "x": 1568172844000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172874000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172904000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172934000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172964000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568172994000, "downCount": 8, "upCount": 92, "y": 1 }, + { "x": 1568173024000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173054000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173084000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173114000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173144000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173174000, "downCount": 8, "upCount": 92, "y": 1 }, + { "x": 1568173204000, "downCount": 7, "upCount": 93, "y": 1 }, + { "x": 1568173234000, "downCount": 7, "upCount": 93, "y": 1 } + ] +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_filter.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_filter.json new file mode 100644 index 0000000000000..72b2d5276e025 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_filter.json @@ -0,0 +1,24 @@ +{ + "histogram": [ + { "x": 1568172664000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172694000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172724000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172754000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172784000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172814000, "downCount": 0, "upCount": 92, "y": 1 }, + { "x": 1568172844000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172874000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172904000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172934000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172964000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568172994000, "downCount": 0, "upCount": 92, "y": 1 }, + { "x": 1568173024000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173054000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173084000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173114000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173144000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173174000, "downCount": 0, "upCount": 92, "y": 1 }, + { "x": 1568173204000, "downCount": 0, "upCount": 93, "y": 1 }, + { "x": 1568173234000, "downCount": 0, "upCount": 93, "y": 1 } + ] +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_id.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_id.json new file mode 100644 index 0000000000000..8e184b247ab52 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/ping_histogram_by_id.json @@ -0,0 +1,24 @@ +{ + "histogram": [ + { "x": 1568172664000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172694000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172724000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172754000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172784000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172814000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172844000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172874000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172904000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172934000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172964000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568172994000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173024000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173054000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173084000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173114000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173144000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173174000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173204000, "downCount": 0, "upCount": 1, "y": 1 }, + { "x": 1568173234000, "downCount": 0, "upCount": 1, "y": 1 } + ] +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/index.ts b/x-pack/test/api_integration/apis/uptime/rest/index.ts index a86411f7c49ec..30c301c5ecb17 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/index.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/index.ts @@ -19,6 +19,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { after('unload', () => esArchiver.unload('uptime/full_heartbeat')); loadTestFile(require.resolve('./monitor_latest_status')); loadTestFile(require.resolve('./selected_monitor')); + loadTestFile(require.resolve('./ping_histogram')); }); }); } diff --git a/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts b/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts new file mode 100644 index 0000000000000..429f50ec0aa5b --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts @@ -0,0 +1,64 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { assertCloseTo } from '../../../../../legacy/plugins/uptime/server/lib/helper'; + +export default function({ getService }: FtrProviderContext) { + describe('pingHistogram', () => { + const supertest = getService('supertest'); + + it('will fetch histogram data for all monitors', async () => { + const dateStart = '2019-09-11T03:31:04.380Z'; + const dateEnd = '2019-09-11T03:40:34.410Z'; + + const apiResponse = await supertest.get( + `/api/uptime/ping/histogram?dateStart=${dateStart}&dateEnd=${dateEnd}` + ); + const data = apiResponse.body; + + // manually testing this value and then removing it to avoid flakiness + const { interval } = data; + assertCloseTo(interval, 22801, 100); + delete data.interval; + expectFixtureEql(data, 'ping_histogram'); + }); + + it('will fetch histogram data for a given monitor id', async () => { + const dateStart = '2019-09-11T03:31:04.380Z'; + const dateEnd = '2019-09-11T03:40:34.410Z'; + const monitorId = '0002-up'; + + const apiResponse = await supertest.get( + `/api/uptime/ping/histogram?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}` + ); + const data = apiResponse.body; + + const { interval } = data; + assertCloseTo(interval, 22801, 100); + delete data.interval; + expectFixtureEql(data, 'ping_histogram_by_id'); + }); + + it('will fetch histogram data for a given filter', async () => { + const dateStart = '2019-09-11T03:31:04.380Z'; + const dateEnd = '2019-09-11T03:40:34.410Z'; + const filters = + '{"bool":{"must":[{"match":{"monitor.status":{"query":"up","operator":"and"}}}]}}'; + + const apiResponse = await supertest.get( + `/api/uptime/ping/histogram?dateStart=${dateStart}&dateEnd=${dateEnd}&filters=${filters}` + ); + const data = apiResponse.body; + + const { interval } = data; + assertCloseTo(interval, 22801, 100); + delete data.interval; + expectFixtureEql(data, 'ping_histogram_by_filter'); + }); + }); +} diff --git a/x-pack/test/functional/apps/uptime/index.ts b/x-pack/test/functional/apps/uptime/index.ts index c1bc8f856c467..273b7659b5f46 100644 --- a/x-pack/test/functional/apps/uptime/index.ts +++ b/x-pack/test/functional/apps/uptime/index.ts @@ -13,15 +13,23 @@ export default ({ loadTestFile, getService }: FtrProviderContext) => { const kibanaServer = getService('kibanaServer'); describe('Uptime app', function() { - before(async () => { - await esArchiver.load(ARCHIVE); - await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC' }); - }); - after(async () => await esArchiver.unload(ARCHIVE)); this.tags('ciGroup6'); + describe('with generated data', () => { + before('load heartbeat data', async () => await esArchiver.load('uptime/blank')); + after('unload', async () => await esArchiver.unload('uptime/blank')); + + loadTestFile(require.resolve('./locations')); + }); + describe('with real-world data', () => { + before(async () => { + await esArchiver.load(ARCHIVE); + await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC' }); + }); + after(async () => await esArchiver.unload(ARCHIVE)); - loadTestFile(require.resolve('./feature_controls')); - loadTestFile(require.resolve('./overview')); - loadTestFile(require.resolve('./monitor')); + loadTestFile(require.resolve('./feature_controls')); + loadTestFile(require.resolve('./overview')); + loadTestFile(require.resolve('./monitor')); + }); }); }; diff --git a/x-pack/test/functional/apps/uptime/locations.ts b/x-pack/test/functional/apps/uptime/locations.ts new file mode 100644 index 0000000000000..fe9030109145d --- /dev/null +++ b/x-pack/test/functional/apps/uptime/locations.ts @@ -0,0 +1,48 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { makeChecksWithStatus } from '../../../api_integration/apis/uptime/graphql/helpers/make_checks'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default ({ getPageObjects, getService }: FtrProviderContext) => { + const pageObjects = getPageObjects(['uptime']); + + describe('location', () => { + const start = new Date().toISOString(); + const end = new Date().toISOString(); + + const MONITOR_ID = 'location-testing-id'; + before(async () => { + /** + * This mogrify function will strip the documents of their location + * data (but preserve their location name), which is necessary for + * this test to work as desired. + * @param d current document + */ + const mogrifyNoLocation = (d: any) => { + if (d.observer?.geo?.location) { + d.observer.geo.location = undefined; + } + return d; + }; + await makeChecksWithStatus( + getService('legacyEs'), + MONITOR_ID, + 5, + 2, + 10000, + {}, + 'up', + mogrifyNoLocation + ); + }); + + it('renders the location missing popover when monitor has location name, but no geo data', async () => { + await pageObjects.uptime.loadDataAndGoToMonitorPage(start, end, MONITOR_ID); + await pageObjects.uptime.locationMissingIsDisplayed(); + }); + }); +}; diff --git a/x-pack/test/functional/apps/watcher/watcher_test.js b/x-pack/test/functional/apps/watcher/watcher_test.js index a3b955f8fccee..a2da0aad2d3c5 100644 --- a/x-pack/test/functional/apps/watcher/watcher_test.js +++ b/x-pack/test/functional/apps/watcher/watcher_test.js @@ -18,7 +18,10 @@ export default function({ getService, getPageObjects }) { const esSupertest = getService('esSupertest'); const PageObjects = getPageObjects(['security', 'common', 'header', 'settings', 'watcher']); - describe('watcher_test', function() { + // Still flaky test :c + // https://github.com/elastic/kibana/pull/56361 + // https://github.com/elastic/kibana/pull/56304 + describe.skip('watcher_test', function() { before('initialize tests', async () => { // There may be system watches if monitoring was previously enabled // These cannot be deleted via the UI, so we need to delete via the API diff --git a/x-pack/test/functional/page_objects/uptime_page.ts b/x-pack/test/functional/page_objects/uptime_page.ts index 2ae0ea38c957b..a5bd4cc480287 100644 --- a/x-pack/test/functional/page_objects/uptime_page.ts +++ b/x-pack/test/functional/page_objects/uptime_page.ts @@ -35,12 +35,15 @@ export function UptimePageProvider({ getPageObjects, getService }: FtrProviderCo datePickerStartValue: string, datePickerEndValue: string, monitorId: string, - monitorName: string + monitorName?: string ) { await pageObjects.common.navigateToApp('uptime'); await pageObjects.timePicker.setAbsoluteRange(datePickerStartValue, datePickerEndValue); await uptimeService.navigateToMonitorWithId(monitorId); - if ((await uptimeService.getMonitorNameDisplayedOnPageTitle()) !== monitorName) { + if ( + monitorName && + (await uptimeService.getMonitorNameDisplayedOnPageTitle()) !== monitorName + ) { throw new Error('Expected monitor name not found'); } } @@ -89,5 +92,9 @@ export function UptimePageProvider({ getPageObjects, getService }: FtrProviderCo public async getSnapshotCount() { return await uptimeService.getSnapshotCount(); } + + public locationMissingIsDisplayed() { + return uptimeService.locationMissingExists(); + } })(); } diff --git a/x-pack/test/functional/services/uptime.ts b/x-pack/test/functional/services/uptime.ts index ca38c2e9dd897..ed39f28aabbfa 100644 --- a/x-pack/test/functional/services/uptime.ts +++ b/x-pack/test/functional/services/uptime.ts @@ -27,7 +27,7 @@ export function UptimeProvider({ getService }: FtrProviderContext) { return url.indexOf(expected) >= 0; }, async navigateToMonitorWithId(monitorId: string) { - await testSubjects.click(`monitor-page-link-${monitorId}`); + await testSubjects.click(`monitor-page-link-${monitorId}`, 5000); }, async getMonitorNameDisplayedOnPageTitle() { return await testSubjects.getVisibleText('monitor-page-title'); @@ -64,5 +64,10 @@ export function UptimeProvider({ getService }: FtrProviderContext) { down: await testSubjects.getVisibleText('xpack.uptime.snapshot.donutChart.down'), }; }, + async locationMissingExists() { + return await testSubjects.existOrFail('xpack.uptime.locationMap.locationMissing', { + timeout: 3000, + }); + }, }; } diff --git a/x-pack/test/kerberos_api_integration/config.ts b/x-pack/test/kerberos_api_integration/config.ts index a1e1466ae40ed..5de397a4cca1a 100644 --- a/x-pack/test/kerberos_api_integration/config.ts +++ b/x-pack/test/kerberos_api_integration/config.ts @@ -34,6 +34,7 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) { ...xPackAPITestsConfig.get('esTestCluster.serverArgs'), 'xpack.security.authc.token.enabled=true', 'xpack.security.authc.token.timeout=15s', + 'xpack.security.authc.realms.kerberos.kerb1.order=0', `xpack.security.authc.realms.kerberos.kerb1.keytab.path=${kerberosKeytabPath}`, ], serverEnvVars: {