diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 37ca1ff7bbdec..2e2b20a46baed 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,7 +12,6 @@ /src/legacy/core_plugins/kibana/public/discover/ @elastic/kibana-app /src/legacy/core_plugins/kibana/public/visualize/ @elastic/kibana-app /src/legacy/core_plugins/kibana/public/local_application_service/ @elastic/kibana-app -/src/legacy/core_plugins/kibana/public/home/ @elastic/kibana-app /src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app /src/legacy/core_plugins/metrics/ @elastic/kibana-app /src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app @@ -20,6 +19,10 @@ /src/plugins/home/public @elastic/kibana-app /src/plugins/home/server/*.ts @elastic/kibana-app /src/plugins/home/server/services/ @elastic/kibana-app +# Exclude tutorial resources folder for now because they are not owned by Kibana app and most will move out soon +/src/legacy/core_plugins/kibana/public/home/*.ts @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/home/*.scss @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/home/np_ready/ @elastic/kibana-app /src/plugins/kibana_legacy/ @elastic/kibana-app /src/plugins/timelion/ @elastic/kibana-app /src/plugins/dev_tools/ @elastic/kibana-app diff --git a/.i18nrc.json b/.i18nrc.json index 98c36b43e5d8f..1230151212f57 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -40,7 +40,7 @@ "visTypeMetric": "src/legacy/core_plugins/vis_type_metric", "visTypeTable": "src/legacy/core_plugins/vis_type_table", "visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud", - "visTypeTimeseries": "src/legacy/core_plugins/vis_type_timeseries", + "visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"], "visTypeVega": "src/legacy/core_plugins/vis_type_vega", "visTypeVislib": "src/legacy/core_plugins/vis_type_vislib", "visualizations": [ diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts index d9c0579638047..1a0a99311d06b 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts @@ -19,7 +19,6 @@ import { EuiConfirmModal, EuiIcon } from '@elastic/eui'; import angular, { IModule } from 'angular'; -import { History } from 'history'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; import { AppMountContext, @@ -28,7 +27,7 @@ import { LegacyCoreStart, SavedObjectsClientContract, } from 'kibana/public'; -import { IKbnUrlStateStorage, Storage } from '../../../../../../plugins/kibana_utils/public'; +import { Storage } from '../../../../../../plugins/kibana_utils/public'; import { configureAppAngularModule, confirmModalFactory, @@ -66,8 +65,6 @@ export interface RenderDeps { embeddables: IEmbeddableStart; localStorage: Storage; share: SharePluginStart; - history: History; - kbnUrlStateStorage: IKbnUrlStateStorage; } let angularModuleInstance: IModule | null = null; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx index 367db6644ff57..a48c165116304 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app.tsx @@ -19,6 +19,7 @@ import moment from 'moment'; import { Subscription } from 'rxjs'; +import { History } from 'history'; import { IInjector } from '../legacy_imports'; @@ -35,6 +36,7 @@ import { import { DashboardAppController } from './dashboard_app_controller'; import { RenderDeps } from './application'; +import { IKbnUrlStateStorage } from '../../../../../../plugins/kibana_utils/public/'; export interface DashboardAppScope extends ng.IScope { dash: SavedObjectDashboard; @@ -96,7 +98,9 @@ export function initDashboardAppDirective(app: any, deps: RenderDeps) { $route: any, $routeParams: { id?: string; - } + }, + kbnUrlStateStorage: IKbnUrlStateStorage, + history: History ) => new DashboardAppController({ $route, @@ -105,6 +109,8 @@ export function initDashboardAppDirective(app: any, deps: RenderDeps) { config, confirmModal, indexPatterns: deps.npDataStart.indexPatterns, + kbnUrlStateStorage, + history, ...deps, }), }; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index e85054cd7fb34..a8eec9c2504a7 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -24,6 +24,7 @@ import angular from 'angular'; import { Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; +import { History } from 'history'; import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen'; import { @@ -77,7 +78,11 @@ import { SavedObjectFinderProps, SavedObjectFinderUi, } from '../../../../../../plugins/kibana_react/public'; -import { removeQueryParam, unhashUrl } from '../../../../../../plugins/kibana_utils/public'; +import { + IKbnUrlStateStorage, + removeQueryParam, + unhashUrl, +} from '../../../../../../plugins/kibana_utils/public'; export interface DashboardAppControllerDependencies extends RenderDeps { $scope: DashboardAppScope; @@ -87,6 +92,8 @@ export interface DashboardAppControllerDependencies extends RenderDeps { dashboardConfig: any; config: any; confirmModal: ConfirmModalFn; + history: History; + kbnUrlStateStorage: IKbnUrlStateStorage; } export class DashboardAppController { diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js index 7ba404d52d9a6..2121b51ea78d8 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js @@ -21,11 +21,13 @@ import { i18n } from '@kbn/i18n'; import dashboardTemplate from './dashboard_app.html'; import dashboardListingTemplate from './listing/dashboard_listing_ng_wrapper.html'; +import { createHashHistory } from 'history'; import { ensureDefaultIndexPattern } from '../legacy_imports'; import { initDashboardAppDirective } from './dashboard_app'; import { createDashboardEditUrl, DashboardConstants } from './dashboard_constants'; import { + createKbnUrlStateStorage, InvalidJSONProperty, SavedObjectNotFound, } from '../../../../../../plugins/kibana_utils/public'; @@ -62,6 +64,14 @@ export function initDashboardApp(app, deps) { stateManagementConfigProvider.disable(); }); + app.factory('history', () => createHashHistory()); + app.factory('kbnUrlStateStorage', history => + createKbnUrlStateStorage({ + history, + useHash: deps.uiSettings.get('state:storeInSessionStorage'), + }) + ); + app.config(function($routeProvider) { const defaults = { reloadOnSearch: false, @@ -87,7 +97,7 @@ export function initDashboardApp(app, deps) { .when(DashboardConstants.LANDING_PAGE_PATH, { ...defaults, template: dashboardListingTemplate, - controller($injector, $location, $scope) { + controller($injector, $location, $scope, kbnUrlStateStorage) { const service = deps.savedDashboards; const kbnUrl = $injector.get('kbnUrl'); const dashboardConfig = deps.dashboardConfig; @@ -95,7 +105,7 @@ export function initDashboardApp(app, deps) { // syncs `_g` portion of url with query services const { stop: stopSyncingGlobalStateWithUrl } = syncQuery( deps.npDataStart.query, - deps.kbnUrlStateStorage + kbnUrlStateStorage ); $scope.listingLimit = deps.uiSettings.get('savedObjects:listingLimit'); @@ -189,7 +199,7 @@ export function initDashboardApp(app, deps) { template: dashboardTemplate, controller: createNewDashboardCtrl, resolve: { - dash: function($rootScope, $route, redirectWhenMissing, kbnUrl) { + dash: function($rootScope, $route, redirectWhenMissing, kbnUrl, history) { const id = $route.current.params.id; return ensureDefaultIndexPattern(deps.core, deps.npDataStart, $rootScope, kbnUrl) @@ -216,7 +226,6 @@ export function initDashboardApp(app, deps) { // See https://github.com/elastic/kibana/issues/10951 for more context. if (error instanceof SavedObjectNotFound && id === 'create') { // Note preserve querystring part is necessary so the state is preserved through the redirect. - const history = deps.history; history.replace({ ...history.location, // preserve query, pathname: DashboardConstants.CREATE_NEW_DASHBOARD_URL, diff --git a/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts b/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts index 732fbd525ae37..ca4b18a37504c 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts @@ -25,13 +25,12 @@ import { Plugin, SavedObjectsClientContract, } from 'kibana/public'; -import { createHashHistory } from 'history'; import { i18n } from '@kbn/i18n'; import { RenderDeps } from './np_ready/application'; import { DataStart } from '../../../data/public'; import { DataPublicPluginStart as NpDataStart } from '../../../../../plugins/data/public'; import { IEmbeddableStart } from '../../../../../plugins/embeddable/public'; -import { createKbnUrlStateStorage, Storage } from '../../../../../plugins/kibana_utils/public'; +import { Storage } from '../../../../../plugins/kibana_utils/public'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; import { DashboardConstants } from './np_ready/dashboard_constants'; import { @@ -97,12 +96,6 @@ export class DashboardPlugin implements Plugin { overlays: contextCore.overlays, }); - const history = createHashHistory(); - const kbnUrlStateStorage = createKbnUrlStateStorage({ - history, - useHash: core.uiSettings.get('state:storeInSessionStorage'), - }); - const deps: RenderDeps = { core: contextCore as LegacyCoreStart, ...angularDependencies, @@ -118,8 +111,6 @@ export class DashboardPlugin implements Plugin { embeddables, dashboardCapabilities: contextCore.application.capabilities.dashboard, localStorage: new Storage(localStorage), - history, - kbnUrlStateStorage, }; const { renderApp } = await import('./np_ready/application'); return renderApp(params.element, params.appBasePath, deps); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap index 1275a52eead57..028d0b8016693 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap +++ b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap @@ -38,39 +38,33 @@ exports[`DefaultEditorAggParams component should init with the default set of pa setAggParamValue={[MockFunction]} showValidation={false} /> - + - - - + - - + } + formIsTouched={false} + key="jsonundefined" + onChangeParamsState={[Function]} + setAggParamValue={[MockFunction]} + showValidation={false} + /> + `; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx index 0d83860a1475a..47e98f175ab73 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx @@ -18,7 +18,7 @@ */ import React, { useCallback, useReducer, useEffect, useMemo } from 'react'; -import { EuiForm, EuiAccordion, EuiSpacer, EuiFormRow } from '@elastic/eui'; +import { EuiForm, EuiAccordion, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import useUnmount from 'react-use/lib/useUnmount'; @@ -219,7 +219,8 @@ function DefaultEditorAggParams({ })} {params.advanced.length ? ( - + <> + - + ) : null} ); diff --git a/src/legacy/core_plugins/vis_type_timeseries/index.ts b/src/legacy/core_plugins/vis_type_timeseries/index.ts index a502bb174bc99..3ad8ba3a31c17 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/index.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/index.ts @@ -21,7 +21,6 @@ import { resolve } from 'path'; import { Legacy } from 'kibana'; import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; -import { VisTypeTimeseriesSetup } from '../../../plugins/vis_type_timeseries/server'; const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => new Plugin({ @@ -47,11 +46,6 @@ const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlu }, }, }, - init: (server: Legacy.Server) => { - const visTypeTimeSeriesPlugin = server.newPlatform.setup.plugins - .metrics as VisTypeTimeseriesSetup; - visTypeTimeSeriesPlugin.__legacy.registerLegacyAPI({ server }); - }, config(Joi: any) { return Joi.object({ enabled: Joi.boolean().default(true), diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/filter_ratio.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/filter_ratio.js index 355c4723587d6..5bd7f6557e887 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/filter_ratio.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/filter_ratio.js @@ -36,7 +36,7 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public'; -import { METRIC_TYPES } from '../../../common/metric_types'; +import { METRIC_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/metric_types'; export const FilterRatioAgg = props => { const { series, fields, panel } = props; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/metric_select.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/metric_select.js index 5e2f148ab5a6e..18daecd699903 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/metric_select.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/metric_select.js @@ -23,10 +23,10 @@ import { includes } from 'lodash'; import { injectI18n } from '@kbn/i18n/react'; import { EuiComboBox } from '@elastic/eui'; import { calculateSiblings } from '../lib/calculate_siblings'; -import { calculateLabel } from '../../../common/calculate_label'; -import { basicAggs } from '../../../common/basic_aggs'; -import { toPercentileNumber } from '../../../common/to_percentile_number'; -import { METRIC_TYPES } from '../../../common/metric_types'; +import { calculateLabel } from '../../../../../../plugins/vis_type_timeseries/common/calculate_label'; +import { basicAggs } from '../../../../../../plugins/vis_type_timeseries/common/basic_aggs'; +import { toPercentileNumber } from '../../../../../../plugins/vis_type_timeseries/common/to_percentile_number'; +import { METRIC_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/metric_types'; function createTypeFilter(restrict, exclude) { return metric => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/moving_average.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/moving_average.js index 3b9d0ab282682..5843eab3f4707 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/moving_average.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/moving_average.js @@ -36,7 +36,7 @@ import { EuiFieldNumber, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { MODEL_TYPES } from '../../../common/model_options'; +import { MODEL_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/model_options'; const DEFAULTS = { model_type: MODEL_TYPES.UNWEIGHTED, diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/std_agg.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/std_agg.js index 67fe9403e402b..61e5c60cbd72a 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/std_agg.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/std_agg.js @@ -34,7 +34,7 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public'; -import { METRIC_TYPES } from '../../../common/metric_types'; +import { METRIC_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/metric_types'; export function StandardAgg(props) { const { model, panel, series, fields, uiRestrictions } = props; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/top_hit.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/top_hit.js index fa92713046aca..df13b94394061 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/top_hit.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/top_hit.js @@ -36,7 +36,7 @@ import { } from '@elastic/eui'; import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public'; -import { PANEL_TYPES } from '../../../common/panel_types'; +import { PANEL_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/panel_types'; const isFieldTypeEnabled = (fieldRestrictions, fieldType) => fieldRestrictions.length ? fieldRestrictions.includes(fieldType) : true; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js index 352747013fe29..de8469adfb8a7 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js @@ -42,8 +42,11 @@ import { AUTO_INTERVAL, } from './lib/get_interval'; import { i18n } from '@kbn/i18n'; -import { TIME_RANGE_DATA_MODES, TIME_RANGE_MODE_KEY } from '../../common/timerange_data_modes'; -import { PANEL_TYPES } from '../../common/panel_types'; +import { + TIME_RANGE_DATA_MODES, + TIME_RANGE_MODE_KEY, +} from '../../../../../plugins/vis_type_timeseries/common/timerange_data_modes'; +import { PANEL_TYPES } from '../../../../../plugins/vis_type_timeseries/common/panel_types'; import { isTimerangeModeEnabled } from '../lib/check_ui_restrictions'; import { VisDataContext } from '../contexts/vis_data_context'; @@ -138,8 +141,8 @@ export const IndexPattern = ({ fields, prefix, onChange, disabled, model: _model {i18n.translate('visTypeTimeseries.indexPattern.timeRange.hint', { - defaultMessage: `This setting controls the timespan used for matching documents. - "Entire timerange" will match all the documents selected in the timepicker. + defaultMessage: `This setting controls the timespan used for matching documents. + "Entire timerange" will match all the documents selected in the timepicker. "Last value" will match only the documents for the specified interval from the end of the timerange.`, })} diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/convert_series_to_vars.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/convert_series_to_vars.js index bcab9ec026d9a..73fc8dac2b564 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/convert_series_to_vars.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/convert_series_to_vars.js @@ -18,7 +18,7 @@ */ import _ from 'lodash'; -import { getLastValue } from '../../../common/get_last_value'; +import { getLastValue } from '../../../../../../plugins/vis_type_timeseries/common/get_last_value'; import { createTickFormatter } from './tick_formatter'; import moment from 'moment'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/get_interval.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/get_interval.js index 05d00f6bede1a..a6aefe067dd62 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/get_interval.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/get_interval.js @@ -20,7 +20,7 @@ import moment from 'moment'; import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; import { parseEsInterval } from '../../../../data/public'; -import { GTE_INTERVAL_RE } from '../../../common/interval_regexp'; +import { GTE_INTERVAL_RE } from '../../../../../../plugins/vis_type_timeseries/common/interval_regexp'; export const AUTO_INTERVAL = 'auto'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/series_change_handler.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/series_change_handler.js index b13f89c204292..e773782969d16 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/series_change_handler.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/lib/series_change_handler.js @@ -19,7 +19,7 @@ import _ from 'lodash'; import { newMetricAggFn } from './new_metric_agg_fn'; -import { isBasicAgg } from '../../../common/agg_lookup'; +import { isBasicAgg } from '../../../../../../plugins/vis_type_timeseries/common/agg_lookup'; import { handleAdd, handleChange } from './collection_actions'; export const seriesChangeHandler = (props, items) => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/splits/terms.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/splits/terms.js index 111da86d71ecb..0fddc4f8c1d87 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/splits/terms.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/splits/terms.js @@ -36,7 +36,7 @@ import { EuiFieldText, } from '@elastic/eui'; import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; -import { FIELD_TYPES } from '../../../common/field_types'; +import { FIELD_TYPES } from '../../../../../../plugins/vis_type_timeseries/common/field_types'; import { STACKED_OPTIONS } from '../../visualizations/constants'; const DEFAULTS = { terms_direction: 'desc', terms_size: 10, terms_order_by: '_count' }; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js index ae39d75c7a2d1..3dedb67bd1d99 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js @@ -28,7 +28,7 @@ import { VisPicker } from './vis_picker'; import { PanelConfig } from './panel_config'; import { createBrushHandler } from '../lib/create_brush_handler'; import { fetchFields } from '../lib/fetch_fields'; -import { extractIndexPatterns } from '../../common/extract_index_patterns'; +import { extractIndexPatterns } from '../../../../../plugins/vis_type_timeseries/common/extract_index_patterns'; import { esKuery } from '../../../../../plugins/data/public'; import { npStart } from 'ui/new_platform'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor_visualization.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor_visualization.js index a376905495c52..c45a4d68e8aad 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor_visualization.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor_visualization.js @@ -28,7 +28,7 @@ import { isGteInterval, AUTO_INTERVAL, } from './lib/get_interval'; -import { PANEL_TYPES } from '../../common/panel_types'; +import { PANEL_TYPES } from '../../../../../plugins/vis_type_timeseries/common/panel_types'; import { start as embeddables } from '../../../embeddable_api/public/np_ready/public/legacy'; const MIN_CHART_HEIGHT = 300; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_picker.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_picker.js index 8d2673ea24cb2..2c4a11f8880ff 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_picker.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_picker.js @@ -21,7 +21,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { EuiTabs, EuiTab } from '@elastic/eui'; import { injectI18n } from '@kbn/i18n/react'; -import { PANEL_TYPES } from '../../common/panel_types'; +import { PANEL_TYPES } from '../../../../../plugins/vis_type_timeseries/common/panel_types'; function VisPickerItem(props) { const { label, type, selected } = props; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/gauge/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/gauge/vis.js index 5d6bb55f33db6..7d30a1f0c8df5 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/gauge/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/gauge/vis.js @@ -23,7 +23,7 @@ import { visWithSplits } from '../../vis_with_splits'; import { createTickFormatter } from '../../lib/tick_formatter'; import _, { get, isUndefined, assign, includes } from 'lodash'; import { Gauge } from '../../../visualizations/views/gauge'; -import { getLastValue } from '../../../../common/get_last_value'; +import { getLastValue } from '../../../../../../../plugins/vis_type_timeseries/common/get_last_value'; function getColors(props) { const { model, visData } = props; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/markdown/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/markdown/vis.js index e20f3d3fbaebc..a806339085450 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/markdown/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/markdown/vis.js @@ -26,7 +26,7 @@ import { Markdown } from '../../../../../kibana_react/public'; import { ErrorComponent } from '../../error'; import { replaceVars } from '../../lib/replace_vars'; import { convertSeriesToVars } from '../../lib/convert_series_to_vars'; -import { isBackgroundInverted } from '../../../../common/set_is_reversed'; +import { isBackgroundInverted } from '../../../lib/set_is_reversed'; const getMarkdownId = id => `markdown-${id}`; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/metric/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/metric/vis.js index f463a4494a189..4a907a7b2078d 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/metric/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/metric/vis.js @@ -23,8 +23,8 @@ import { visWithSplits } from '../../vis_with_splits'; import { createTickFormatter } from '../../lib/tick_formatter'; import _, { get, isUndefined, assign, includes, pick } from 'lodash'; import { Metric } from '../../../visualizations/views/metric'; -import { getLastValue } from '../../../../common/get_last_value'; -import { isBackgroundInverted } from '../../../../common/set_is_reversed'; +import { getLastValue } from '../../../../../../../plugins/vis_type_timeseries/common/get_last_value'; +import { isBackgroundInverted } from '../../../lib/set_is_reversed'; function getColors(props) { const { model, visData } = props; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/is_sortable.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/is_sortable.js index 887652a67f406..b44c94131348d 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/is_sortable.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/is_sortable.js @@ -17,7 +17,7 @@ * under the License. */ -import { basicAggs } from '../../../../common/basic_aggs'; +import { basicAggs } from '../../../../../../../plugins/vis_type_timeseries/common/basic_aggs'; export function isSortable(metric) { return basicAggs.includes(metric.type); diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/vis.js index a82d5bdb1588c..94f4506cd0172 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/table/vis.js @@ -22,14 +22,14 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { npStart } from 'ui/new_platform'; import { createTickFormatter } from '../../lib/tick_formatter'; -import { calculateLabel } from '../../../../common/calculate_label'; +import { calculateLabel } from '../../../../../../../plugins/vis_type_timeseries/common/calculate_label'; import { isSortable } from './is_sortable'; import { EuiToolTip, EuiIcon } from '@elastic/eui'; import { replaceVars } from '../../lib/replace_vars'; import { fieldFormats } from '../../../../../../../plugins/data/public'; import { FormattedMessage } from '@kbn/i18n/react'; -import { METRIC_TYPES } from '../../../../common/metric_types'; +import { METRIC_TYPES } from '../../../../../../../plugins/vis_type_timeseries/common/metric_types'; function getColor(rules, colorKey, value) { let color; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/series.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/series.js index 226aded390508..27a84d9ba40b9 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/series.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/series.js @@ -35,7 +35,7 @@ import { import { Split } from '../../split'; import { createTextHandler } from '../../lib/create_text_handler'; import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; -import { PANEL_TYPES } from '../../../../common/panel_types'; +import { PANEL_TYPES } from '../../../../../../../plugins/vis_type_timeseries/common/panel_types'; const TimeseriesSeriesUI = injectI18n(function(props) { const { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/vis.js index d269d7c3546ec..5243f5f92a621 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/timeseries/vis.js @@ -34,7 +34,7 @@ import { getAxisLabelString } from '../../lib/get_axis_label_string'; import { getInterval } from '../../lib/get_interval'; import { areFieldsDifferent } from '../../lib/charts'; import { createXaxisFormatter } from '../../lib/create_xaxis_formatter'; -import { isBackgroundDark } from '../../../../common/set_is_reversed'; +import { isBackgroundDark } from '../../../lib/set_is_reversed'; import { STACKED_OPTIONS } from '../../../visualizations/constants'; export class TimeseriesVisualization extends Component { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/top_n/vis.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/top_n/vis.js index 7d09f33acdecc..2ebc60325a425 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/top_n/vis.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_types/top_n/vis.js @@ -19,8 +19,8 @@ import { createTickFormatter } from '../../lib/tick_formatter'; import { TopN } from '../../../visualizations/views/top_n'; -import { getLastValue } from '../../../../common/get_last_value'; -import { isBackgroundInverted } from '../../../../common/set_is_reversed'; +import { getLastValue } from '../../../../../../../plugins/vis_type_timeseries/common/get_last_value'; +import { isBackgroundInverted } from '../../../lib/set_is_reversed'; import { replaceVars } from '../../lib/replace_vars'; import PropTypes from 'prop-types'; import React from 'react'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_with_splits.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_with_splits.js index 91d53b9c2e1db..e36910d9081b3 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_with_splits.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_with_splits.js @@ -20,7 +20,7 @@ import React from 'react'; import { getDisplayName } from './lib/get_display_name'; import { last, findIndex, first } from 'lodash'; -import { calculateLabel } from '../../common/calculate_label'; +import { calculateLabel } from '../../../../../plugins/vis_type_timeseries/common/calculate_label'; export function visWithSplits(WrappedComponent) { function SplitVisComponent(props) { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/lib/check_ui_restrictions.js b/src/legacy/core_plugins/vis_type_timeseries/public/lib/check_ui_restrictions.js index 1fade6ebe9849..5d18c0a2f09cd 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/lib/check_ui_restrictions.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/lib/check_ui_restrictions.js @@ -18,7 +18,10 @@ */ import { get } from 'lodash'; -import { RESTRICTIONS_KEYS, DEFAULT_UI_RESTRICTION } from '../../common/ui_restrictions'; +import { + RESTRICTIONS_KEYS, + DEFAULT_UI_RESTRICTION, +} from '../../../../../plugins/vis_type_timeseries/common/ui_restrictions'; /** * Generic method for checking all types of the UI Restrictions diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/lib/fetch_fields.js b/src/legacy/core_plugins/vis_type_timeseries/public/lib/fetch_fields.js index 21c12b07ff47f..68e694f23fa7f 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/lib/fetch_fields.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/lib/fetch_fields.js @@ -19,7 +19,7 @@ import { kfetch } from 'ui/kfetch'; import { toastNotifications } from 'ui/notify'; import { i18n } from '@kbn/i18n'; -import { extractIndexPatterns } from '../../common/extract_index_patterns'; +import { extractIndexPatterns } from '../../../../../plugins/vis_type_timeseries/common/extract_index_patterns'; export async function fetchFields(indexPatterns = ['*']) { const patterns = Array.isArray(indexPatterns) ? indexPatterns : [indexPatterns]; diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/set_is_reversed.js b/src/legacy/core_plugins/vis_type_timeseries/public/lib/set_is_reversed.js similarity index 92% rename from src/legacy/core_plugins/vis_type_timeseries/common/set_is_reversed.js rename to src/legacy/core_plugins/vis_type_timeseries/public/lib/set_is_reversed.js index b633d004b9705..9f66bcd161916 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/common/set_is_reversed.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/lib/set_is_reversed.js @@ -18,9 +18,9 @@ */ import color from 'color'; -import chrome from '../../../ui/public/chrome'; +import { getUISettings } from '../services'; -const IS_DARK_THEME = chrome.getUiSettingsClient().get('theme:darkMode'); +const isDarkTheme = () => getUISettings().get('theme:darkMode'); /** * Returns true if the color that is passed has low luminosity @@ -34,7 +34,7 @@ const isColorDark = c => { * Defaults to checking `theme:darkMode`. */ export const isThemeDark = currentTheme => { - let themeIsDark = currentTheme || IS_DARK_THEME; + let themeIsDark = currentTheme || isDarkTheme(); // If passing a string, check the luminosity if (typeof currentTheme === 'string') { diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/lib/validate_interval.js b/src/legacy/core_plugins/vis_type_timeseries/public/lib/validate_interval.js index 2dbcdc4749a66..2992549d38e30 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/lib/validate_interval.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/lib/validate_interval.js @@ -17,7 +17,7 @@ * under the License. */ -import { GTE_INTERVAL_RE } from '../../common/interval_regexp'; +import { GTE_INTERVAL_RE } from '../../../../../plugins/vis_type_timeseries/common/interval_regexp'; import { i18n } from '@kbn/i18n'; import { parseInterval } from '../../../../../plugins/data/public'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts b/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts index e7684cd21b797..22d2b3b10e566 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts @@ -26,7 +26,7 @@ import { metricsRequestHandler } from './request_handler'; // @ts-ignore import { EditorController } from './editor_controller'; // @ts-ignore -import { PANEL_TYPES } from '../common/panel_types'; +import { PANEL_TYPES } from '../../../../plugins/vis_type_timeseries/common/panel_types'; export const metricsVisDefinition = { name: 'metrics', diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/gauge.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/gauge.js index 3be2e9daed58c..b518665e5ece4 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/gauge.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/gauge.js @@ -21,8 +21,8 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import classNames from 'classnames'; -import { isBackgroundInverted, isBackgroundDark } from '../../../common/set_is_reversed'; -import { getLastValue } from '../../../common/get_last_value'; +import { isBackgroundInverted, isBackgroundDark } from '../../lib/set_is_reversed'; +import { getLastValue } from '../../../../../../plugins/vis_type_timeseries/common/get_last_value'; import { getValueBy } from '../lib/get_value_by'; import { GaugeVis } from './gauge_vis'; import reactcss from 'reactcss'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/metric.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/metric.js index 004d59efca333..5524e17d106e4 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/metric.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/metric.js @@ -20,7 +20,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import _ from 'lodash'; -import { getLastValue } from '../../../common/get_last_value'; +import { getLastValue } from '../../../../../../plugins/vis_type_timeseries/common/get_last_value'; import reactcss from 'reactcss'; import { calculateCoordinates } from '../lib/calculate_coordinates'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/top_n.js b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/top_n.js index 5734d101a09d2..99e9cc0b1c218 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/top_n.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/top_n.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { getLastValue } from '../../../common/get_last_value'; +import { getLastValue } from '../../../../../../plugins/vis_type_timeseries/common/get_last_value'; import reactcss from 'reactcss'; const RENDER_MODES = { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/index.ts b/src/legacy/core_plugins/vis_type_timeseries/server/index.ts deleted file mode 100644 index c010628ca04bf..0000000000000 --- a/src/legacy/core_plugins/vis_type_timeseries/server/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { init } from './init'; -export { getVisData, GetVisData, GetVisDataOptions } from './lib/get_vis_data'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/init.ts b/src/legacy/core_plugins/vis_type_timeseries/server/init.ts deleted file mode 100644 index ae6eebc00fc1b..0000000000000 --- a/src/legacy/core_plugins/vis_type_timeseries/server/init.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// @ts-ignore -import { fieldsRoutes } from './routes/fields'; -// @ts-ignore -import { visDataRoutes } from './routes/vis'; -// @ts-ignore -import { SearchStrategiesRegister } from './lib/search_strategies/search_strategies_register'; -// @ts-ignore -import { getVisData } from './lib/get_vis_data'; -import { Framework } from '../../../../plugins/vis_type_timeseries/server'; -import { ValidationTelemetryServiceSetup } from '../../../../plugins/vis_type_timeseries/server'; - -export const init = async ( - framework: Framework, - __LEGACY: any, - validationTelemetry: ValidationTelemetryServiceSetup -) => { - const { core } = framework; - const router = core.http.createRouter(); - - visDataRoutes(router, framework, validationTelemetry); - - // [LEGACY_TODO] - fieldsRoutes(__LEGACY.server); - SearchStrategiesRegister.init(__LEGACY.server); -}; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js deleted file mode 100644 index 361ce132f1735..0000000000000 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_fields.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { SearchStrategiesRegister } from './search_strategies/search_strategies_register'; -import { uniq } from 'lodash'; -import { getIndexPatternObject } from './vis_data/helpers/get_index_pattern'; -import { isNestedField } from '../../../../../plugins/data/server'; - -export async function getFields(req) { - const indexPattern = req.query.index; - const { indexPatternString } = await getIndexPatternObject(req, indexPattern); - const { searchStrategy, capabilities } = await SearchStrategiesRegister.getViableStrategy( - req, - indexPatternString - ); - - const fields = ( - await searchStrategy.getFieldsForWildcard(req, indexPatternString, capabilities) - ).filter(field => field.aggregatable && !isNestedField(field)); - - return uniq(fields, field => field.name); -} diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_index_pattern_service.js b/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_index_pattern_service.js deleted file mode 100644 index 54e90ab7dd9b7..0000000000000 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_index_pattern_service.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { IndexPatternsFetcher } from '../../../../../plugins/data/server/'; -export const getIndexPatternService = { - assign: 'indexPatternsService', - method(req) { - const dataCluster = req.server.plugins.elasticsearch.getCluster('data'); - const callDataCluster = (...args) => { - return dataCluster.callWithRequest(req, ...args); - }; - return new IndexPatternsFetcher(callDataCluster); - }, -}; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.js b/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.js deleted file mode 100644 index 794e92a1954a9..0000000000000 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export class AbstractSearchStrategy { - constructor(server, callWithRequestFactory, SearchRequest) { - this.getCallWithRequestInstance = req => callWithRequestFactory(server, req); - - this.getSearchRequest = req => { - const callWithRequest = this.getCallWithRequestInstance(req); - - return new SearchRequest(req, callWithRequest); - }; - } - - async getFieldsForWildcard(req, indexPattern) { - const { indexPatternsService } = req.pre; - - return await indexPatternsService.getFieldsForWildcard({ - pattern: indexPattern, - }); - } - - checkForViability() { - throw new TypeError('Must override method'); - } -} diff --git a/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts b/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts index 2212827c1f598..2722c7a1665d3 100644 --- a/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts +++ b/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts @@ -51,8 +51,12 @@ export const useDataInit = () => { }); dispatch({ type: 'setCurrentTextObject', payload: newObject }); } else { - // For now, we always take the first text object returned. - dispatch({ type: 'setCurrentTextObject', payload: results[0] }); + dispatch({ + type: 'setCurrentTextObject', + // For backwards compatibility, we sort here according to date created to + // always take the first item created. + payload: results.sort((a, b) => a.createdAt - b.createdAt)[0], + }); } } catch (e) { setError(e); diff --git a/src/plugins/console/public/lib/autocomplete/get_endpoint_from_position.ts b/src/plugins/console/public/lib/autocomplete/get_endpoint_from_position.ts index cb037e29e33f6..8cac8d1208cee 100644 --- a/src/plugins/console/public/lib/autocomplete/get_endpoint_from_position.ts +++ b/src/plugins/console/public/lib/autocomplete/get_endpoint_from_position.ts @@ -30,7 +30,10 @@ export function getEndpointFromPosition(editor: CoreEditor, pos: Position, parse const context = { ...getCurrentMethodAndTokenPaths( editor, - { column: lineValue.length, lineNumber: pos.lineNumber }, + { + column: lineValue.length + 1 /* Go to the very end of the line */, + lineNumber: pos.lineNumber, + }, parser, true ), diff --git a/src/plugins/data/public/ui/filter_bar/filter_bar.tsx b/src/plugins/data/public/ui/filter_bar/filter_bar.tsx index 2f1b1f8588eb9..2aaceddd68f0c 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_bar.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_bar.tsx @@ -96,6 +96,7 @@ function FilterBarUI(props: Props) { withTitle panelPaddingSize="none" ownFocus={true} + initialFocus=".filterEditor__hiddenItem" >
diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx index b058d231b8306..b83c3a8e905dc 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx @@ -95,6 +95,7 @@ class FilterEditorUI extends Component { defaultMessage="Edit filter" /> + {this.state.isCustomEditorOpen ? ( diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/__snapshots__/model_options.test.js.snap b/src/plugins/vis_type_timeseries/common/__snapshots__/model_options.test.js.snap similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/__snapshots__/model_options.test.js.snap rename to src/plugins/vis_type_timeseries/common/__snapshots__/model_options.test.js.snap diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/agg_lookup.js b/src/plugins/vis_type_timeseries/common/agg_lookup.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/agg_lookup.js rename to src/plugins/vis_type_timeseries/common/agg_lookup.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/agg_lookup.test.js b/src/plugins/vis_type_timeseries/common/agg_lookup.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/agg_lookup.test.js rename to src/plugins/vis_type_timeseries/common/agg_lookup.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/basic_aggs.js b/src/plugins/vis_type_timeseries/common/basic_aggs.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/basic_aggs.js rename to src/plugins/vis_type_timeseries/common/basic_aggs.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/calculate_label.js b/src/plugins/vis_type_timeseries/common/calculate_label.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/calculate_label.js rename to src/plugins/vis_type_timeseries/common/calculate_label.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/calculate_label.test.js b/src/plugins/vis_type_timeseries/common/calculate_label.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/calculate_label.test.js rename to src/plugins/vis_type_timeseries/common/calculate_label.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/extract_index_patterns.js b/src/plugins/vis_type_timeseries/common/extract_index_patterns.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/extract_index_patterns.js rename to src/plugins/vis_type_timeseries/common/extract_index_patterns.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/extract_index_patterns.test.js b/src/plugins/vis_type_timeseries/common/extract_index_patterns.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/extract_index_patterns.test.js rename to src/plugins/vis_type_timeseries/common/extract_index_patterns.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/field_types.js b/src/plugins/vis_type_timeseries/common/field_types.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/field_types.js rename to src/plugins/vis_type_timeseries/common/field_types.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/get_last_value.js b/src/plugins/vis_type_timeseries/common/get_last_value.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/get_last_value.js rename to src/plugins/vis_type_timeseries/common/get_last_value.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/get_last_value.test.js b/src/plugins/vis_type_timeseries/common/get_last_value.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/get_last_value.test.js rename to src/plugins/vis_type_timeseries/common/get_last_value.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/interval_regexp.js b/src/plugins/vis_type_timeseries/common/interval_regexp.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/interval_regexp.js rename to src/plugins/vis_type_timeseries/common/interval_regexp.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/interval_regexp.test.js b/src/plugins/vis_type_timeseries/common/interval_regexp.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/interval_regexp.test.js rename to src/plugins/vis_type_timeseries/common/interval_regexp.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/metric_types.js b/src/plugins/vis_type_timeseries/common/metric_types.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/metric_types.js rename to src/plugins/vis_type_timeseries/common/metric_types.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/model_options.js b/src/plugins/vis_type_timeseries/common/model_options.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/model_options.js rename to src/plugins/vis_type_timeseries/common/model_options.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/model_options.test.js b/src/plugins/vis_type_timeseries/common/model_options.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/model_options.test.js rename to src/plugins/vis_type_timeseries/common/model_options.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/panel_types.js b/src/plugins/vis_type_timeseries/common/panel_types.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/panel_types.js rename to src/plugins/vis_type_timeseries/common/panel_types.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/timerange_data_modes.js b/src/plugins/vis_type_timeseries/common/timerange_data_modes.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/timerange_data_modes.js rename to src/plugins/vis_type_timeseries/common/timerange_data_modes.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/to_percentile_number.js b/src/plugins/vis_type_timeseries/common/to_percentile_number.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/to_percentile_number.js rename to src/plugins/vis_type_timeseries/common/to_percentile_number.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/common/ui_restrictions.js b/src/plugins/vis_type_timeseries/common/ui_restrictions.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/common/ui_restrictions.js rename to src/plugins/vis_type_timeseries/common/ui_restrictions.js diff --git a/src/plugins/vis_type_timeseries/server/index.ts b/src/plugins/vis_type_timeseries/server/index.ts index dfb2394af237b..fa74b6e965971 100644 --- a/src/plugins/vis_type_timeseries/server/index.ts +++ b/src/plugins/vis_type_timeseries/server/index.ts @@ -32,6 +32,13 @@ export type VisTypeTimeseriesConfig = TypeOf; export { ValidationTelemetryServiceSetup } from './validation_telemetry'; +// @ts-ignore +export { AbstractSearchStrategy } from './lib/search_strategies/strategies/abstract_search_strategy'; +// @ts-ignore +export { AbstractSearchRequest } from './lib/search_strategies/search_requests/abstract_request'; +// @ts-ignore +export { DefaultSearchCapabilities } from './lib/search_strategies/default_search_capabilities'; + export function plugin(initializerContext: PluginInitializerContext) { return new VisTypeTimeseriesPlugin(initializerContext); } diff --git a/src/plugins/vis_type_timeseries/server/lib/get_fields.ts b/src/plugins/vis_type_timeseries/server/lib/get_fields.ts new file mode 100644 index 0000000000000..8eca30dae7773 --- /dev/null +++ b/src/plugins/vis_type_timeseries/server/lib/get_fields.ts @@ -0,0 +1,89 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { uniq } from 'lodash'; +import { first, map } from 'rxjs/operators'; +import { KibanaRequest, RequestHandlerContext } from 'kibana/server'; + +// @ts-ignore +import { getIndexPatternObject } from './vis_data/helpers/get_index_pattern'; +import { isNestedField } from '../../../data/server'; +import { Framework } from '../plugin'; +import { FieldDescriptor, IndexPatternsFetcher } from '../../../data/server'; +import { ReqFacade } from './search_strategies/strategies/abstract_search_strategy'; + +export async function getFields( + requestContext: RequestHandlerContext, + request: KibanaRequest, + framework: Framework, + indexPattern: string +) { + // NOTE / TODO: This facade has been put in place to make migrating to the New Platform easier. It + // removes the need to refactor many layers of dependencies on "req", and instead just augments the top + // level object passed from here. The layers should be refactored fully at some point, but for now + // this works and we are still using the New Platform services for these vis data portions. + const reqFacade: ReqFacade = { + ...request, + framework, + payload: {}, + pre: { + indexPatternsService: new IndexPatternsFetcher( + requestContext.core.elasticsearch.dataClient.callAsCurrentUser + ), + }, + getUiSettingsService: () => requestContext.core.uiSettings.client, + getSavedObjectsClient: () => requestContext.core.savedObjects.client, + server: { + plugins: { + elasticsearch: { + getCluster: () => { + return { + callWithRequest: async (req: any, endpoint: string, params: any) => { + return await requestContext.core.elasticsearch.dataClient.callAsCurrentUser( + endpoint, + params + ); + }, + }; + }, + }, + }, + }, + getEsShardTimeout: async () => { + return await framework.globalConfig$ + .pipe( + first(), + map(config => config.elasticsearch.shardTimeout.asMilliseconds()) + ) + .toPromise(); + }, + }; + const { indexPatternString } = await getIndexPatternObject(reqFacade, indexPattern); + const { + searchStrategy, + capabilities, + } = (await framework.searchStrategyRegistry.getViableStrategy(reqFacade, indexPatternString))!; + + const fields = ((await searchStrategy.getFieldsForWildcard( + reqFacade, + indexPatternString, + capabilities + )) as FieldDescriptor[]).filter(field => field.aggregatable && !isNestedField(field)); + + return uniq(fields, field => field.name); +} diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_vis_data.ts b/src/plugins/vis_type_timeseries/server/lib/get_vis_data.ts similarity index 87% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/get_vis_data.ts rename to src/plugins/vis_type_timeseries/server/lib/get_vis_data.ts index 58e624fa13442..aef831eaad430 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/get_vis_data.ts +++ b/src/plugins/vis_type_timeseries/server/lib/get_vis_data.ts @@ -17,11 +17,12 @@ * under the License. */ -import { RequestHandlerContext } from 'src/core/server'; +import { FakeRequest, RequestHandlerContext } from 'kibana/server'; import _ from 'lodash'; import { first, map } from 'rxjs/operators'; import { getPanelData } from './vis_data/get_panel_data'; -import { Framework } from '../../../../../plugins/vis_type_timeseries/server'; +import { Framework } from '../index'; +import { ReqFacade } from './search_strategies/strategies/abstract_search_strategy'; interface GetVisDataResponse { [key: string]: GetVisDataPanel; @@ -56,15 +57,18 @@ export type GetVisData = ( export function getVisData( requestContext: RequestHandlerContext, - options: GetVisDataOptions, + request: FakeRequest & { body: GetVisDataOptions }, framework: Framework ): Promise { // NOTE / TODO: This facade has been put in place to make migrating to the New Platform easier. It // removes the need to refactor many layers of dependencies on "req", and instead just augments the top // level object passed from here. The layers should be refactored fully at some point, but for now // this works and we are still using the New Platform services for these vis data portions. - const reqFacade: any = { - payload: options, + const reqFacade: ReqFacade = { + ...request, + framework, + pre: {}, + payload: request.body, getUiSettingsService: () => requestContext.core.uiSettings.client, getSavedObjectsClient: () => requestContext.core.savedObjects.client, server: { @@ -92,7 +96,7 @@ export function getVisData( .toPromise(); }, }; - const promises = reqFacade.payload.panels.map(getPanelData(reqFacade)); + const promises = (reqFacade.payload as GetVisDataOptions).panels.map(getPanelData(reqFacade)); return Promise.all(promises).then(res => { return res.reduce((acc, data) => { return _.assign(acc as any, data); diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/default_search_capabilities.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/index.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/index.ts similarity index 91% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/index.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/index.ts index 512894f30a619..d53683882252b 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/index.js +++ b/src/plugins/vis_type_timeseries/server/lib/search_strategies/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { SearchStrategiesRegister } from './search_strategies_register'; +export { SearchStrategyRegistry } from './search_strategy_registry'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/abstract_request.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/abstract_request.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/abstract_request.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/abstract_request.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/abstract_request.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/abstract_request.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/abstract_request.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/abstract_request.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/multi_search_request.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/multi_search_request.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/multi_search_request.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/multi_search_request.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/multi_search_request.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/multi_search_request.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/multi_search_request.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/multi_search_request.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/search_request.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/search_request.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/search_request.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/search_request.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/search_request.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/search_request.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/search_request.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/search_request.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/single_search_request.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/single_search_request.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/single_search_request.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/single_search_request.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/single_search_request.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/single_search_request.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/searh_requests/single_search_request.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_requests/single_search_request.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_registry.test.ts similarity index 61% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_registry.test.ts index e03d776b8ee0c..ecd09653b3b48 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.test.js +++ b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_registry.test.ts @@ -16,10 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { SearchStrategiesRegister } from './search_strategies_register'; + +import { SearchStrategyRegistry } from './search_strategy_registry'; +// @ts-ignore import { AbstractSearchStrategy } from './strategies/abstract_search_strategy'; +// @ts-ignore import { DefaultSearchStrategy } from './strategies/default_search_strategy'; -import { AbstractSearchRequest } from './searh_requests/abstract_request'; +// @ts-ignore import { DefaultSearchCapabilities } from './default_search_capabilities'; class MockSearchStrategy extends AbstractSearchStrategy { @@ -31,34 +34,21 @@ class MockSearchStrategy extends AbstractSearchStrategy { } } -describe('SearchStrategiesRegister', () => { - let server; - let strategies; - let anotherSearchStrategy; +describe('SearchStrategyRegister', () => { + let registry: SearchStrategyRegistry; beforeAll(() => { - server = { - expose: jest.fn((strategy, func) => { - server[strategy] = func; - }), - }; - strategies = [ - ['AbstractSearchStrategy', AbstractSearchStrategy], - ['AbstractSearchRequest', AbstractSearchRequest], - ['DefaultSearchCapabilities', DefaultSearchCapabilities], - ['addSearchStrategy', expect.any(Function)], - ]; - - SearchStrategiesRegister.init(server); + registry = new SearchStrategyRegistry(); }); test('should init strategies register', () => { - expect(server.expose.mock.calls).toEqual(strategies); - expect(server.addSearchStrategy()[0] instanceof DefaultSearchStrategy).toBe(true); + expect( + registry.addStrategy({} as AbstractSearchStrategy)[0] instanceof DefaultSearchStrategy + ).toBe(true); }); test('should not add a strategy if it is not an instance of AbstractSearchStrategy', () => { - const addedStrategies = server.addSearchStrategy({}); + const addedStrategies = registry.addStrategy({} as AbstractSearchStrategy); expect(addedStrategies.length).toEqual(1); expect(addedStrategies[0] instanceof DefaultSearchStrategy).toBe(true); @@ -68,18 +58,15 @@ describe('SearchStrategiesRegister', () => { const req = {}; const indexPattern = '*'; - const { searchStrategy, capabilities } = await SearchStrategiesRegister.getViableStrategy( - req, - indexPattern - ); + const { searchStrategy, capabilities } = (await registry.getViableStrategy(req, indexPattern))!; expect(searchStrategy instanceof DefaultSearchStrategy).toBe(true); expect(capabilities instanceof DefaultSearchCapabilities).toBe(true); }); test('should add a strategy if it is an instance of AbstractSearchStrategy', () => { - anotherSearchStrategy = new MockSearchStrategy(); - const addedStrategies = server.addSearchStrategy(anotherSearchStrategy); + const anotherSearchStrategy = new MockSearchStrategy({}, {} as any, {}); + const addedStrategies = registry.addStrategy(anotherSearchStrategy); expect(addedStrategies.length).toEqual(2); expect(addedStrategies[0] instanceof AbstractSearchStrategy).toBe(true); @@ -88,13 +75,12 @@ describe('SearchStrategiesRegister', () => { test('should return a MockSearchStrategy instance', async () => { const req = {}; const indexPattern = '*'; + const anotherSearchStrategy = new MockSearchStrategy({}, {} as any, {}); + registry.addStrategy(anotherSearchStrategy); - const { searchStrategy, capabilities } = await SearchStrategiesRegister.getViableStrategy( - req, - indexPattern - ); + const { searchStrategy, capabilities } = (await registry.getViableStrategy(req, indexPattern))!; - expect(searchStrategy instanceof AbstractSearchStrategy).toBe(true); + expect(searchStrategy instanceof MockSearchStrategy).toBe(true); expect(capabilities).toEqual({}); }); }); diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategy_registry.ts similarity index 57% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategy_registry.ts index 5fbb4060862a4..6fbed1ddfba0f 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/search_strategies_register.js +++ b/src/plugins/vis_type_timeseries/server/lib/search_strategies/search_strategy_registry.ts @@ -16,34 +16,32 @@ * specific language governing permissions and limitations * under the License. */ + import { AbstractSearchStrategy } from './strategies/abstract_search_strategy'; -import { AbstractSearchRequest } from './searh_requests/abstract_request'; +// @ts-ignore import { DefaultSearchStrategy } from './strategies/default_search_strategy'; -import { DefaultSearchCapabilities } from './default_search_capabilities'; - +// @ts-ignore import { extractIndexPatterns } from '../../../common/extract_index_patterns'; -const strategies = []; +export type RequestFacade = any; +export type Panel = any; -const addStrategy = searchStrategy => { - if (searchStrategy instanceof AbstractSearchStrategy) { - strategies.unshift(searchStrategy); - } - return strategies; -}; +export class SearchStrategyRegistry { + private strategies: AbstractSearchStrategy[] = []; -export class SearchStrategiesRegister { - static init(server) { - server.expose('AbstractSearchStrategy', AbstractSearchStrategy); - server.expose('AbstractSearchRequest', AbstractSearchRequest); - server.expose('DefaultSearchCapabilities', DefaultSearchCapabilities); - server.expose('addSearchStrategy', searchStrategy => addStrategy(searchStrategy)); + constructor() { + this.addStrategy(new DefaultSearchStrategy()); + } - addStrategy(new DefaultSearchStrategy(server)); + public addStrategy(searchStrategy: AbstractSearchStrategy) { + if (searchStrategy instanceof AbstractSearchStrategy) { + this.strategies.unshift(searchStrategy); + } + return this.strategies; } - static async getViableStrategy(req, indexPattern) { - for (const searchStrategy of strategies) { + async getViableStrategy(req: RequestFacade, indexPattern: string) { + for (const searchStrategy of this.strategies) { const { isViable, capabilities } = await searchStrategy.checkForViability(req, indexPattern); if (isViable) { @@ -55,9 +53,9 @@ export class SearchStrategiesRegister { } } - static async getViableStrategyForPanel(req, panel) { + async getViableStrategyForPanel(req: RequestFacade, panel: Panel) { const indexPattern = extractIndexPatterns(panel).join(','); - return SearchStrategiesRegister.getViableStrategy(req, indexPattern); + return this.getViableStrategy(req, indexPattern); } } diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.test.js diff --git a/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.ts b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.ts new file mode 100644 index 0000000000000..4fd4ac251fa3e --- /dev/null +++ b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/abstract_search_strategy.ts @@ -0,0 +1,87 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { + APICaller, + FakeRequest, + IUiSettingsClient, + SavedObjectsClientContract, +} from 'kibana/server'; +import { Framework } from '../../../plugin'; +import { IndexPatternsFetcher } from '../../../../../data/server'; + +/** + * ReqFacade is a regular KibanaRequest object extended with additional service + * references to ensure backwards compatibility for existing integrations. + * + * This will be replaced by standard KibanaRequest and RequestContext objects in a later version. + */ +export type ReqFacade = FakeRequest & { + framework: Framework; + payload: unknown; + pre: { + indexPatternsService?: IndexPatternsFetcher; + }; + getUiSettingsService: () => IUiSettingsClient; + getSavedObjectsClient: () => SavedObjectsClientContract; + server: { + plugins: { + elasticsearch: { + getCluster: () => { + callWithRequest: (req: ReqFacade, endpoint: string, params: any) => Promise; + }; + }; + }; + }; + getEsShardTimeout: () => Promise; +}; + +export class AbstractSearchStrategy { + public getCallWithRequestInstance: (req: ReqFacade) => APICaller; + public getSearchRequest: (req: ReqFacade) => any; + + constructor( + server: any, + callWithRequestFactory: (server: any, req: ReqFacade) => APICaller, + SearchRequest: any + ) { + this.getCallWithRequestInstance = req => callWithRequestFactory(server, req); + + this.getSearchRequest = req => { + const callWithRequest = this.getCallWithRequestInstance(req); + + return new SearchRequest(req, callWithRequest); + }; + } + + async getFieldsForWildcard(req: ReqFacade, indexPattern: string, capabilities: any) { + const { indexPatternsService } = req.pre; + + return await indexPatternsService!.getFieldsForWildcard({ + pattern: indexPattern, + }); + } + + checkForViability( + req: ReqFacade, + indexPattern: string + ): { isViable: boolean; capabilities: any } { + throw new TypeError('Must override method'); + } +} diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js similarity index 95% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js index fba67f448e784..63f2911ce1118 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js +++ b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.js @@ -17,7 +17,7 @@ * under the License. */ import { AbstractSearchStrategy } from './abstract_search_strategy'; -import { SearchRequest } from '../searh_requests/search_request'; +import { SearchRequest } from '../search_requests/search_request'; import { DefaultSearchCapabilities } from '../default_search_capabilities'; const callWithRequestFactory = (server, request) => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.test.js b/src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.test.js rename to src/plugins/vis_type_timeseries/server/lib/search_strategies/strategies/default_search_strategy.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/annorations/build_request_body.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/annotations/build_request_body.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/annorations/build_request_body.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/annotations/build_request_body.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/annorations/get_request_params.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/annotations/get_request_params.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/annorations/get_request_params.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/annotations/get_request_params.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.test.ts b/src/plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.test.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.test.ts rename to src/plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.test.ts diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.ts b/src/plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.ts rename to src/plugins/vis_type_timeseries/server/lib/vis_data/build_processor_function.ts diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js similarity index 96% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js index 898ff837d4a01..8b8c31912f168 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_annotations.js @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { handleAnnotationResponse } from './response_processors/annotations/'; -import { getAnnotationRequestParams } from './annorations/get_request_params'; +import { handleAnnotationResponse } from './response_processors/annotations'; +import { getAnnotationRequestParams } from './annotations/get_request_params'; import { getLastSeriesTimestamp } from './helpers/timestamp'; function validAnnotation(annotation) { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_interval_and_timefield.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.d.ts b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.d.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.d.ts rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.d.ts diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_panel_data.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js similarity index 91% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js index b4eb9e6b108ff..1efeccb4b5701 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_series_data.js @@ -20,15 +20,14 @@ import { getSeriesRequestParams } from './series/get_request_params'; import { handleResponseBody } from './series/handle_response_body'; import { handleErrorResponse } from './handle_error_response'; import { getAnnotations } from './get_annotations'; -import { SearchStrategiesRegister } from '../search_strategies/search_strategies_register'; import { getEsQueryConfig } from './helpers/get_es_query_uisettings'; import { getActiveSeries } from './helpers/get_active_series'; export async function getSeriesData(req, panel) { - const { searchStrategy, capabilities } = await SearchStrategiesRegister.getViableStrategyForPanel( - req, - panel - ); + const { + searchStrategy, + capabilities, + } = await req.framework.searchStrategyRegistry.getViableStrategyForPanel(req, panel); const searchRequest = searchStrategy.getSearchRequest(req); const esQueryConfig = await getEsQueryConfig(req); const meta = { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js similarity index 90% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js index 2c92692d2bd1f..1d1c245907959 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/get_table_data.js @@ -20,16 +20,16 @@ import { buildRequestBody } from './table/build_request_body'; import { handleErrorResponse } from './handle_error_response'; import { get } from 'lodash'; import { processBucket } from './table/process_bucket'; -import { SearchStrategiesRegister } from '../search_strategies/search_strategies_register'; import { getEsQueryConfig } from './helpers/get_es_query_uisettings'; import { getIndexPatternObject } from './helpers/get_index_pattern'; export async function getTableData(req, panel) { const panelIndexPattern = panel.index_pattern; - const { searchStrategy, capabilities } = await SearchStrategiesRegister.getViableStrategy( - req, - panelIndexPattern - ); + + const { + searchStrategy, + capabilities, + } = await req.framework.searchStrategyRegistry.getViableStrategy(req, panelIndexPattern); const searchRequest = searchStrategy.getSearchRequest(req); const esQueryConfig = await getEsQueryConfig(req); const { indexPatternObject } = await getIndexPatternObject(req, panelIndexPattern); diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/handle_error_response.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/handle_error_response.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/handle_error_response.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/handle_error_response.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/__snapshots__/bucket_transform.test.js.snap b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/__snapshots__/bucket_transform.test.js.snap similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/__snapshots__/bucket_transform.test.js.snap rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/__snapshots__/bucket_transform.test.js.snap diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/calculate_auto.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/calculate_auto.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/calculate_auto.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/calculate_auto.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/format_key.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/format_key.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/format_key.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/format_key.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_agg_value.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js similarity index 97% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js index de23b90b21d6c..3ec5454fcee77 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.js @@ -24,7 +24,7 @@ import { convertIntervalToUnit, ASCENDING_UNIT_ORDER, } from './unit_to_seconds'; -import { getTimerangeDuration } from '../helpers/get_timerange'; +import { getTimerangeDuration } from './get_timerange'; import { INTERVAL_STRING_RE, GTE_INTERVAL_RE } from '../../../../common/interval_regexp'; const calculateBucketData = (timeInterval, capabilities) => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_bucket_size.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_buckets_path.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_default_decoration.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_query_uisettings.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_query_uisettings.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_query_uisettings.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_query_uisettings.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_es_shard_timeout.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_index_pattern.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_index_pattern.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_index_pattern.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_index_pattern.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_last_metric.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_sibling_agg_value.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange_mode.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange_mode.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange_mode.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_timerange_mode.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/map_bucket.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/moving_fn_scripts.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_interval.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_interval.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_interval.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_interval.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/parse_settings.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/timestamp.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/unit_to_seconds.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/offset_time.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/offset_time.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/offset_time.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/offset_time.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/offset_time.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/offset_time.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/offset_time.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/offset_time.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js similarity index 94% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js index 5a763ce35e35e..995790c590e42 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/date_histogram.js @@ -18,7 +18,7 @@ */ import _ from 'lodash'; -import { dateHistogramInterval } from '../../../../../../data/server'; +import { dateHistogramInterval } from '../../../../../../../legacy/core_plugins/data/server'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { getTimerange } from '../../helpers/get_timerange'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js similarity index 97% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js index d6514e3bc45d4..a4817dac9bd18 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/query.js @@ -19,7 +19,7 @@ import { getBucketSize } from '../../helpers/get_bucket_size'; import { getTimerange } from '../../helpers/get_timerange'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function query(req, panel, annotation, esQueryConfig, indexPattern, capabilities) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/top_hits.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/top_hits.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/top_hits.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/annotations/top_hits.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js similarity index 96% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js index 3b55e2bf4c151..48da5ac19aa3a 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { dateHistogramInterval } from '../../../../../../data/server'; +import { dateHistogramInterval } from '../../../../../../../legacy/core_plugins/data/server'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { offsetTime } from '../../offset_time'; import { getIntervalAndTimefield } from '../../get_interval_and_timefield'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/date_histogram.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/filter_ratios.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/metric_buckets.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/normalize_query.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js similarity index 96% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js index 53f894322a8e0..e5b81912f286e 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.js @@ -19,7 +19,7 @@ import { offsetTime } from '../../offset_time'; import { getIntervalAndTimefield } from '../../get_interval_and_timefield'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function query(req, panel, series, esQueryConfig, indexPatternObject) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/query.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/sibling_buckets.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_everything.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js similarity index 94% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js index 1548c9e17c2e1..80b4ef70a3f08 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function splitByFilter(req, panel, series, esQueryConfig, indexPattern) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filter.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js similarity index 94% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js index 4295bceed43cc..d023c28cdb25e 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function splitByFilters(req, panel, series, esQueryConfig, indexPattern) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_filters.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/series/split_by_terms.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/calculate_agg_root.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/calculate_agg_root.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/calculate_agg_root.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/calculate_agg_root.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js similarity index 96% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js index 183785fab9be1..f33ce145aa230 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/date_histogram.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { dateHistogramInterval } from '../../../../../../data/server'; +import { dateHistogramInterval } from '../../../../../../../legacy/core_plugins/data/server'; import { getBucketSize } from '../../helpers/get_bucket_size'; import { isLastValueTimerangeMode } from '../../helpers/get_timerange_mode'; import { getIntervalAndTimefield } from '../../get_interval_and_timefield'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/filter_ratios.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/filter_ratios.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/filter_ratios.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/filter_ratios.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/metric_buckets.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/metric_buckets.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/metric_buckets.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/metric_buckets.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/normalize_query.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/pivot.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/pivot.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/pivot.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/pivot.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js similarity index 96% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js index 9d46c212e05bd..d8d948e01cccd 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/query.js @@ -18,7 +18,7 @@ */ import { getTimerange } from '../../helpers/get_timerange'; import { getIntervalAndTimefield } from '../../get_interval_and_timefield'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function query(req, panel, esQueryConfig, indexPatternObject) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/sibling_buckets.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/sibling_buckets.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/sibling_buckets.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/sibling_buckets.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js similarity index 95% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js index 17f99ea431fd3..35036abed320f 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_everything.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function splitByEverything(req, panel, esQueryConfig, indexPattern) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js similarity index 95% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js index 042e4d98e2767..5b7ae735cd50f 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/request_processors/table/split_by_terms.js @@ -18,7 +18,7 @@ */ import { set } from 'lodash'; -import { esQuery } from '../../../../../../../../plugins/data/server'; +import { esQuery } from '../../../../../../data/server'; export function splitByTerms(req, panel, esQueryConfig, indexPattern) { return next => doc => { diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/buckets.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/buckets.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/buckets.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/buckets.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/filter.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/annotations/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/_series_agg.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/drop_last_bucket.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/drop_last_bucket.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/drop_last_bucket.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/drop_last_bucket.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/math.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/math.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/math.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/math.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/series_agg.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_bands.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_deviation_sibling.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_metric.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/std_sibling.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.test.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.test.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/time_shift.test.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/_series_agg.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/drop_last_bucket.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/drop_last_bucket.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/drop_last_bucket.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/drop_last_bucket.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/index.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/index.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/index.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/index.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/math.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/math.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/math.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/math.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile_rank.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile_rank.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile_rank.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/percentile_rank.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/series_agg.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/series_agg.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/series_agg.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/series_agg.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_metric.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_metric.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_metric.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_metric.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_sibling.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_sibling.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_sibling.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/table/std_sibling.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.test.ts b/src/plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.test.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.test.ts rename to src/plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.test.ts diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts b/src/plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts similarity index 95% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts rename to src/plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts index 85e1f8f7eb12b..9d8f3fca789f0 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/series/build_request_body.ts @@ -19,7 +19,7 @@ import { buildProcessorFunction } from '../build_processor_function'; // @ts-ignore -import { processors } from '../request_processors/series'; +import { processors } from '../request_processors/series/index'; /** * Builds series request body diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/get_request_params.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/series/get_request_params.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/get_request_params.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/series/get_request_params.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/handle_response_body.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/series/handle_response_body.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/series/handle_response_body.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/series/handle_response_body.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/table/build_request_body.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/table/build_request_body.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/table/build_request_body.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/table/build_request_body.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/table/process_bucket.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/table/process_bucket.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/lib/vis_data/table/process_bucket.js rename to src/plugins/vis_type_timeseries/server/lib/vis_data/table/process_bucket.js diff --git a/src/plugins/vis_type_timeseries/server/plugin.ts b/src/plugins/vis_type_timeseries/server/plugin.ts index dcd0cd500bbc3..6ef6362c6e37b 100644 --- a/src/plugins/vis_type_timeseries/server/plugin.ts +++ b/src/plugins/vis_type_timeseries/server/plugin.ts @@ -24,19 +24,19 @@ import { Plugin, RequestHandlerContext, Logger, + IRouter, + FakeRequest, } from 'src/core/server'; import { Observable } from 'rxjs'; import { Server } from 'hapi'; -import { once } from 'lodash'; import { VisTypeTimeseriesConfig } from '.'; -import { - init, - getVisData, - GetVisData, - GetVisDataOptions, -} from '../../../legacy/core_plugins/vis_type_timeseries/server'; -import { ValidationTelemetryService } from './validation_telemetry/validation_telemetry_service'; +import { getVisData, GetVisData, GetVisDataOptions } from './lib/get_vis_data'; +import { ValidationTelemetryService } from './validation_telemetry'; import { UsageCollectionSetup } from '../../usage_collection/server'; +import { visDataRoutes } from './routes/vis'; +// @ts-ignore +import { fieldsRoutes } from './routes/fields'; +import { SearchStrategyRegistry } from './lib/search_strategies'; export interface LegacySetup { server: Server; @@ -47,15 +47,12 @@ interface VisTypeTimeseriesPluginSetupDependencies { } export interface VisTypeTimeseriesSetup { - /** @deprecated */ - __legacy: { - config$: Observable; - registerLegacyAPI: (__LEGACY: LegacySetup) => void; - }; getVisData: ( requestContext: RequestHandlerContext, + fakeRequest: FakeRequest, options: GetVisDataOptions ) => ReturnType; + addSearchStrategy: SearchStrategyRegistry['addStrategy']; } export interface Framework { @@ -64,6 +61,8 @@ export interface Framework { config$: Observable; globalConfig$: PluginInitializerContext['config']['legacy']['globalConfig$']; logger: Logger; + router: IRouter; + searchStrategyRegistry: SearchStrategyRegistry; } export class VisTypeTimeseriesPlugin implements Plugin { @@ -79,6 +78,9 @@ export class VisTypeTimeseriesPlugin implements Plugin { const config$ = this.initializerContext.config.create(); // Global config contains things like the ES shard timeout const globalConfig$ = this.initializerContext.config.legacy.globalConfig$; + const router = core.http.createRouter(); + + const searchStrategyRegistry = new SearchStrategyRegistry(); const framework: Framework = { core, @@ -86,23 +88,29 @@ export class VisTypeTimeseriesPlugin implements Plugin { config$, globalConfig$, logger, + router, + searchStrategyRegistry, }; - return { - __legacy: { - config$, - registerLegacyAPI: once(async (__LEGACY: LegacySetup) => { - const validationTelemetrySetup = await this.validationTelementryService.setup(core, { - ...plugins, - globalConfig$, - }); + (async () => { + const validationTelemetry = await this.validationTelementryService.setup(core, { + ...plugins, + globalConfig$, + }); + visDataRoutes(router, framework, validationTelemetry); - await init(framework, __LEGACY, validationTelemetrySetup); - }), - }, - getVisData: async (requestContext: RequestHandlerContext, options: GetVisDataOptions) => { - return await getVisData(requestContext, options, framework); + fieldsRoutes(framework); + })(); + + return { + getVisData: async ( + requestContext: RequestHandlerContext, + fakeRequest: FakeRequest, + options: GetVisDataOptions + ) => { + return await getVisData(requestContext, { ...fakeRequest, body: options }, framework); }, + addSearchStrategy: searchStrategyRegistry.addStrategy.bind(searchStrategyRegistry), }; } diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/routes/fields.js b/src/plugins/vis_type_timeseries/server/routes/fields.ts similarity index 54% rename from src/legacy/core_plugins/vis_type_timeseries/server/routes/fields.js rename to src/plugins/vis_type_timeseries/server/routes/fields.ts index d984868afb0b0..255c85c9eefa7 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/routes/fields.js +++ b/src/plugins/vis_type_timeseries/server/routes/fields.ts @@ -17,26 +17,35 @@ * under the License. */ +import { isBoom } from 'boom'; +import { schema } from '@kbn/config-schema'; import { getFields } from '../lib/get_fields'; -import { getIndexPatternService } from '../lib/get_index_pattern_service'; +import { Framework } from '../plugin'; -export const fieldsRoutes = server => { - server.route({ - config: { - pre: [getIndexPatternService], +export const fieldsRoutes = (framework: Framework) => { + framework.router.get( + { + path: '/api/metrics/fields', + validate: { + query: schema.object({ index: schema.string() }), + }, }, - path: '/api/metrics/fields', - method: 'GET', - handler: async req => { + async (context, req, res) => { try { - return await getFields(req); + return res.ok({ body: await getFields(context, req, framework, req.query.index) }); } catch (err) { - if (err.isBoom && err.status === 401) { - return err; + if (isBoom(err) && err.output.statusCode === 401) { + return res.customError({ + body: err.output.payload, + statusCode: err.output.statusCode, + headers: err.output.headers, + }); } - return []; + return res.ok({ + body: [], + }); } - }, - }); + } + ); }; diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/routes/post_vis_schema.ts b/src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timeseries/server/routes/post_vis_schema.ts rename to src/plugins/vis_type_timeseries/server/routes/post_vis_schema.ts diff --git a/src/legacy/core_plugins/vis_type_timeseries/server/routes/vis.ts b/src/plugins/vis_type_timeseries/server/routes/vis.ts similarity index 85% rename from src/legacy/core_plugins/vis_type_timeseries/server/routes/vis.ts rename to src/plugins/vis_type_timeseries/server/routes/vis.ts index 32e87f5a3f666..e2d1e4d114ad5 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/server/routes/vis.ts +++ b/src/plugins/vis_type_timeseries/server/routes/vis.ts @@ -17,14 +17,11 @@ * under the License. */ -import { IRouter } from 'kibana/server'; +import { IRouter, KibanaRequest } from 'kibana/server'; import { schema } from '@kbn/config-schema'; -import { getVisData } from '../lib/get_vis_data'; +import { getVisData, GetVisDataOptions } from '../lib/get_vis_data'; import { visPayloadSchema } from './post_vis_schema'; -import { - Framework, - ValidationTelemetryServiceSetup, -} from '../../../../../plugins/vis_type_timeseries/server'; +import { Framework, ValidationTelemetryServiceSetup } from '../index'; const escapeHatch = schema.object({}, { allowUnknowns: true }); @@ -52,7 +49,11 @@ export const visDataRoutes = ( ); } try { - const results = await getVisData(requestContext, request.body, framework); + const results = await getVisData( + requestContext, + request as KibanaRequest<{}, {}, GetVisDataOptions>, + framework + ); return response.ok({ body: results }); } catch (error) { return response.internalError({ diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index 2dc5c395a605f..c99368ba4e859 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -22,7 +22,7 @@ import expect from '@kbn/expect'; export default function({ getService, getPageObjects }) { const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); - const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'timePicker']); + const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'timePicker', 'header']); describe('kibana settings', function describeIndexTests() { before(async function() { @@ -94,14 +94,21 @@ export default function({ getService, getPageObjects }) { expect(appState.length).to.be.lessThan(20); }); - after( - 'navigate to settings page and turn state:storeInSessionStorage back to false', - async () => { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox('state:storeInSessionStorage'); - } - ); + it("changing 'state:storeInSessionStorage' also takes effect without full page reload", async () => { + await PageObjects.dashboard.preserveCrossAppState(); + await PageObjects.header.clickStackManagement(); + await PageObjects.settings.clickKibanaSettings(); + await PageObjects.settings.toggleAdvancedSettingCheckbox('state:storeInSessionStorage'); + await PageObjects.header.clickDashboard(); + const currentUrl = await browser.getCurrentUrl(); + const urlPieces = currentUrl.match(/(.*)?_g=(.*)&_a=(.*)/); + const globalState = urlPieces[2]; + const appState = urlPieces[3]; + // We don't have to be exact, just need to ensure it's greater than when the hashed variation is being used, + // which is less than 20 characters. + expect(globalState.length).to.be.greaterThan(20); + expect(appState.length).to.be.greaterThan(20); + }); }); after(async function() { 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/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/ml/server/models/calendar/index.js b/x-pack/legacy/plugins/ml/server/models/calendar/index.ts similarity index 75% rename from x-pack/legacy/plugins/ml/server/models/calendar/index.js rename to x-pack/legacy/plugins/ml/server/models/calendar/index.ts index 11f99bc8fd922..2364c3ac73811 100644 --- a/x-pack/legacy/plugins/ml/server/models/calendar/index.js +++ b/x-pack/legacy/plugins/ml/server/models/calendar/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 { 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/rollup/index.js b/x-pack/legacy/plugins/rollup/index.js index a10407b19fa93..cace3bba1592b 100644 --- a/x-pack/legacy/plugins/rollup/index.js +++ b/x-pack/legacy/plugins/rollup/index.js @@ -60,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/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/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 index f9f6aa263ed27..5bb0d1ae8468f 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/connected/index.ts @@ -5,3 +5,6 @@ */ 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/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 b9f0014322062..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,9 +7,8 @@ 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'; 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/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%' }} >

{ + // 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/lib/helper/to_static_index_pattern.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/to_static_index_pattern.ts deleted file mode 100644 index b8a12c1e578e3..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/to_static_index_pattern.ts +++ /dev/null @@ -1,11 +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. - */ - -export const toStaticIndexPattern = (indexPattern: any) => ({ - ...indexPattern, - fields: JSON.parse(indexPattern.attributes.fields), - title: indexPattern.id, -}); 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 b9c2284edb0cf..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,7 +88,7 @@ export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { absoluteDateRangeEnd={absoluteDateRangeEnd} dateRangeStart={dateRangeStart} dateRangeEnd={dateRangeEnd} - filters={filters} + filters={esFilters} statusFilter={statusFilter} /> @@ -141,7 +96,7 @@ export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { absoluteStartDate={absoluteDateRangeStart} absoluteEndDate={absoluteDateRangeEnd} dangerColor={colors.danger} - hasActiveFilters={!!filters} + hasActiveFilters={!!esFilters} implementsCustomErrorState={true} linkParameters={linkParameters} successColor={colors.success} @@ -151,6 +106,6 @@ export const OverviewPage = ({ autocomplete, setBreadcrumbs }: Props) => { }} /> - + ); }; 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 6758006914ab8..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,4 +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/api/index.ts b/x-pack/legacy/plugins/uptime/public/state/api/index.ts index be79317dc97c2..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,4 +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/effects/index.ts b/x-pack/legacy/plugins/uptime/public/state/effects/index.ts index 21d4f7a66ad67..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,6 +9,7 @@ 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() { @@ -16,5 +17,6 @@ export function* rootEffect() { 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/reducers/index.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts index c80ada4f63182..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,7 @@ 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({ @@ -18,5 +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/selectors/__tests__/index.test.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts index 5e3bf95d81292..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,11 @@ describe('state selectors', () => { monitor: null, loading: false, }, + indexPattern: { + index_pattern: null, + loading: false, + errors: [], + }, ping: { pingHistogram: null, loading: false, 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 0066241dcc217..fe6a7a1b7eade 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts @@ -29,6 +29,10 @@ 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/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/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/saved_objects/types.ts deleted file mode 100644 index 0fef1e1428e97..0000000000000 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/types.ts +++ /dev/null @@ -1,11 +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 { UMSavedObjectsQueryFn } from '../framework'; - -export interface UMSavedObjectsAdapter { - getUptimeIndexPattern: UMSavedObjectsQueryFn; -} diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/index.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/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/uptime/server/lib/adapters/stub_index_pattern/index.ts index bd86daba1bcb6..4ef6e3fa8a6bd 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/saved_objects/index.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/stub_index_pattern/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 { 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/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_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/plugins/console_extensions/server/spec/generated/security.put_privileges.json b/x-pack/plugins/console_extensions/server/spec/generated/security.put_privileges.json index 7ecffc780c066..a42d5eb6c953e 100644 --- a/x-pack/plugins/console_extensions/server/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/plugins/console_extensions/server/spec/overrides/security.delete_privileges.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.delete_privileges.json index 35fb78c532c12..5486098ff7bd8 100644 --- a/x-pack/plugins/console_extensions/server/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/plugins/console_extensions/server/spec/overrides/security.put_privileges.json b/x-pack/plugins/console_extensions/server/spec/overrides/security.put_privileges.json index ae37d9a889543..9ebb1046047a7 100644 --- a/x-pack/plugins/console_extensions/server/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/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