From 59144f578f1b23ea22c30dad68a61e8836f8a73d Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 1 Dec 2021 18:12:03 -0600
Subject: [PATCH 01/52] inject filterManager.extract into selector
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 7 ++++++-
.../lens/public/state_management/selectors.ts | 16 +++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 5638a35d1cc6d..1914c0a63c80c 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -93,7 +93,12 @@ export function App({
} = useLensSelector((state) => state.lens);
const currentDoc = useLensSelector((state) =>
- selectSavedObjectFormat(state, datasourceMap, visualizationMap)
+ selectSavedObjectFormat(
+ state,
+ datasourceMap,
+ visualizationMap,
+ data.query.filterManager.extract
+ )
);
// Used to show a popover that guides the user towards changing the date range when no data is available.
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index 4b201e35e5cf7..ee5718fab8b5d 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -7,8 +7,8 @@
import { createSelector } from '@reduxjs/toolkit';
import { SavedObjectReference } from 'kibana/server';
+import { FilterManager } from 'src/plugins/data/public';
import { LensState } from './types';
-import { extractFilterReferences } from '../persistence';
import { Datasource, DatasourceMap, VisualizationMap } from '../types';
import { getDatasourceLayers } from '../editor_frame_service/editor_frame';
@@ -51,6 +51,13 @@ const selectVisualizationMap = (
visualizationMap: VisualizationMap
) => visualizationMap;
+const selectExtractFilterReferences = (
+ state: LensState,
+ datasourceMap: DatasourceMap,
+ visualizationMap: VisualizationMap,
+ extractFilterReferences: FilterManager['extract']
+) => extractFilterReferences;
+
export const selectSavedObjectFormat = createSelector(
[
selectPersistedDoc,
@@ -61,6 +68,7 @@ export const selectSavedObjectFormat = createSelector(
selectActiveDatasourceId,
selectDatasourceMap,
selectVisualizationMap,
+ selectExtractFilterReferences,
],
(
persistedDoc,
@@ -70,7 +78,8 @@ export const selectSavedObjectFormat = createSelector(
filters,
activeDatasourceId,
datasourceMap,
- visualizationMap
+ visualizationMap,
+ extractFilterReferences
) => {
const activeVisualization =
visualization.state && visualization.activeId && visualizationMap[visualization.activeId];
@@ -101,7 +110,8 @@ export const selectSavedObjectFormat = createSelector(
references.push(...savedObjectReferences);
});
- const { persistableFilters, references: filterReferences } = extractFilterReferences(filters);
+ const { state: persistableFilters, references: filterReferences } =
+ extractFilterReferences(filters);
references.push(...filterReferences);
From 49b29321281c715b0d232dcf5d6b1efb2d135c0e Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 1 Dec 2021 19:06:24 -0600
Subject: [PATCH 02/52] tentative migration
---
.../saved_object_migrations.test.ts | 124 ++++++++++++++++++
.../migrations/saved_object_migrations.ts | 17 +++
.../plugins/lens/server/migrations/types.ts | 11 +-
3 files changed, 150 insertions(+), 2 deletions(-)
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
index ef67c768a8997..dc8ffc25cc3df 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
@@ -1404,4 +1404,128 @@ describe('Lens migrations', () => {
]);
});
});
+
+ describe('8.1.0 update filter reference schema', () => {
+ const context = { log: { warning: () => {} } } as unknown as SavedObjectMigrationContext;
+ const example = {
+ type: 'lens',
+ id: 'mocked-saved-object-id',
+ attributes: {
+ savedObjectId: '1',
+ title: 'MyRenamedOps',
+ description: '',
+ visualizationType: null,
+ state: {
+ datasourceMetaData: {
+ filterableIndexPatterns: [],
+ },
+ datasourceStates: {
+ indexpattern: {
+ currentIndexPatternId: 'logstash-*',
+ layers: {
+ '2': {
+ columns: {
+ '3': {
+ label: '@timestamp',
+ dataType: 'date',
+ operationType: 'date_histogram',
+ sourceField: '@timestamp',
+ isBucketed: true,
+ scale: 'interval',
+ params: { interval: 'auto', timeZone: 'Europe/Berlin' },
+ },
+ '4': {
+ label: '@timestamp',
+ dataType: 'date',
+ operationType: 'date_histogram',
+ sourceField: '@timestamp',
+ isBucketed: true,
+ scale: 'interval',
+ params: { interval: 'auto' },
+ },
+ '5': {
+ label: '@timestamp',
+ dataType: 'date',
+ operationType: 'my_unexpected_operation',
+ isBucketed: true,
+ scale: 'interval',
+ params: { timeZone: 'do not delete' },
+ },
+ },
+ columnOrder: ['3', '4', '5'],
+ },
+ },
+ },
+ },
+ visualization: {},
+ query: { query: '', language: 'kuery' },
+ filters: [
+ {
+ meta: {
+ alias: null,
+ negate: false,
+ disabled: false,
+ type: 'phrase',
+ key: 'geo.src',
+ params: { query: 'US' },
+ indexRefName: 'filter-index-pattern-0',
+ },
+ query: { match_phrase: { 'geo.src': 'US' } },
+ $state: { store: 'appState' },
+ },
+ {
+ meta: {
+ alias: null,
+ negate: false,
+ disabled: false,
+ type: 'phrase',
+ key: 'client_ip',
+ params: { query: '1234.5344.2243.3245' },
+ indexRefName: 'filter-index-pattern-2',
+ },
+ query: { match_phrase: { client_ip: '1234.5344.2243.3245' } },
+ $state: { store: 'appState' },
+ },
+ ],
+ },
+ },
+ } as unknown as SavedObjectUnsanitizedDoc>;
+
+ it('should migrate filters schema', () => {
+ const expectedFilters = [
+ {
+ meta: {
+ alias: null,
+ negate: false,
+ disabled: false,
+ type: 'phrase',
+ key: 'geo.src',
+ params: { query: 'US' },
+ index: 'filter-index-pattern-0',
+ },
+ query: { match_phrase: { 'geo.src': 'US' } },
+ $state: { store: 'appState' },
+ },
+ {
+ meta: {
+ alias: null,
+ negate: false,
+ disabled: false,
+ type: 'phrase',
+ key: 'client_ip',
+ params: { query: '1234.5344.2243.3245' },
+ index: 'filter-index-pattern-2',
+ },
+ query: { match_phrase: { client_ip: '1234.5344.2243.3245' } },
+ $state: { store: 'appState' },
+ },
+ ];
+
+ const result = migrations['8.1.0'](example, context) as ReturnType<
+ SavedObjectMigrationFn
+ >;
+
+ expect(result.attributes.state.filters).toEqual(expectedFilters);
+ });
+ });
});
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
index fb3718cf2d213..5b6114e002509 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
@@ -25,6 +25,7 @@ import {
VisStatePost715,
VisStatePre715,
VisState716,
+ LensDocShape810,
} from './types';
import {
commonRenameOperationsForFormula,
@@ -438,6 +439,21 @@ const moveDefaultReversedPaletteToCustom: SavedObjectMigrationFn<
return { ...newDoc, attributes: commonMakeReversePaletteAsCustom(newDoc.attributes) };
};
+const renameFilterReferences: SavedObjectMigrationFn<
+ LensDocShape715,
+ LensDocShape715
+> = (doc) => {
+ const newDoc = cloneDeep(doc);
+ const newFilters = newDoc.attributes.state.filters.map((filter) => {
+ const ret = cloneDeep(filter);
+ ret.meta.index = ret.meta.indexRefName;
+ delete ret.meta.indexRefName;
+ return ret as Filter;
+ });
+ newDoc.attributes.state.filters = newFilters;
+ return newDoc;
+};
+
export const migrations: SavedObjectMigrationMap = {
'7.7.0': removeInvalidAccessors,
// The order of these migrations matter, since the timefield migration relies on the aggConfigs
@@ -451,4 +467,5 @@ export const migrations: SavedObjectMigrationMap = {
'7.14.0': removeTimezoneDateHistogramParam,
'7.15.0': addLayerTypeToVisualization,
'7.16.0': moveDefaultReversedPaletteToCustom,
+ '8.1.0': renameFilterReferences,
};
diff --git a/x-pack/plugins/lens/server/migrations/types.ts b/x-pack/plugins/lens/server/migrations/types.ts
index 43a0f5524f619..de643f9234156 100644
--- a/x-pack/plugins/lens/server/migrations/types.ts
+++ b/x-pack/plugins/lens/server/migrations/types.ts
@@ -8,7 +8,7 @@
import type { PaletteOutput } from 'src/plugins/charts/common';
import { Filter } from '@kbn/es-query';
import { Query } from 'src/plugins/data/public';
-import type { CustomPaletteParams, LayerType } from '../../common';
+import type { CustomPaletteParams, LayerType, PersistableFilter } from '../../common';
export type OperationTypePre712 =
| 'avg'
@@ -191,10 +191,17 @@ export interface LensDocShape715 {
};
visualization: VisualizationState;
query: Query;
- filters: Filter[];
+ filters: PersistableFilter[];
};
}
+export type LensDocShape810 = Omit<
+ LensDocShape715,
+ 'filters'
+> & {
+ filters: Filter[];
+};
+
export type VisState716 =
// Datatable
| {
From f54cf8802bc78a84ab3bbd0f372e18fcda3c8b2a Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Thu, 2 Dec 2021 08:32:15 -0600
Subject: [PATCH 03/52] Replace local injectFilterReferences with
FilterManager.inject
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 7 +-
.../app_plugin/save_modal_container.tsx | 22 +++-
.../lens/public/embeddable/embeddable.tsx | 6 +-
.../public/embeddable/embeddable_factory.ts | 9 +-
.../persistence/filter_references.test.ts | 112 ------------------
.../public/persistence/filter_references.ts | 62 ----------
x-pack/plugins/lens/public/plugin.ts | 1 +
.../init_middleware/load_initial.ts | 6 +-
.../lens/public/state_management/selectors.ts | 30 ++---
9 files changed, 45 insertions(+), 210 deletions(-)
delete mode 100644 x-pack/plugins/lens/public/persistence/filter_references.test.ts
delete mode 100644 x-pack/plugins/lens/public/persistence/filter_references.ts
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 1914c0a63c80c..3113dc4288a0d 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -93,12 +93,11 @@ export function App({
} = useLensSelector((state) => state.lens);
const currentDoc = useLensSelector((state) =>
- selectSavedObjectFormat(
- state,
+ selectSavedObjectFormat(state, {
datasourceMap,
visualizationMap,
- data.query.filterManager.extract
- )
+ extractFilterReferences: data.query.filterManager.extract,
+ })
);
// Used to show a popover that guides the user towards changing the date range when no data is available.
diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
index 0f99902e0b10a..6a34ca331534e 100644
--- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
@@ -14,9 +14,9 @@ import type { SavedObjectReference } from 'kibana/public';
import { SaveModal } from './save_modal';
import type { LensAppProps, LensAppServices } from './types';
import type { SaveProps } from './app';
-import { Document, injectFilterReferences } from '../persistence';
+import { Document } from '../persistence';
import type { LensByReferenceInput, LensEmbeddableInput } from '../embeddable';
-import { esFilters } from '../../../../../src/plugins/data/public';
+import { esFilters, FilterManager } from '../../../../../src/plugins/data/public';
import { APP_ID, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../common';
import { trackUiEvent } from '../lens_ui_telemetry';
import { checkForDuplicateTitle } from '../../../../../src/plugins/saved_objects/public';
@@ -170,10 +170,11 @@ const redirectToDashboard = ({
const getDocToSave = (
lastKnownDoc: Document,
saveProps: SaveProps,
- references: SavedObjectReference[]
+ references: SavedObjectReference[],
+ injectFilterReferences: FilterManager['inject']
) => {
const docToSave = {
- ...getLastKnownDocWithoutPinnedFilters(lastKnownDoc)!,
+ ...getLastKnownDocWithoutPinnedFilters(injectFilterReferences, lastKnownDoc)!,
references,
};
@@ -201,6 +202,7 @@ export const runSaveLensVisualization = async (
): Promise | undefined> => {
const {
chrome,
+ data,
initialInput,
originatingApp,
lastKnownDoc,
@@ -241,7 +243,12 @@ export const runSaveLensVisualization = async (
);
}
- const docToSave = getDocToSave(lastKnownDoc, saveProps, references);
+ const docToSave = getDocToSave(
+ lastKnownDoc,
+ saveProps,
+ references,
+ data.query.filterManager.inject
+ );
// Required to serialize filters in by value mode until
// https://github.com/elastic/kibana/issues/77588 is fixed
@@ -352,7 +359,10 @@ export const runSaveLensVisualization = async (
}
};
-export function getLastKnownDocWithoutPinnedFilters(doc?: Document) {
+export function getLastKnownDocWithoutPinnedFilters(
+ injectFilterReferences: FilterManager['inject'],
+ doc?: Document
+) {
if (!doc) return undefined;
const [pinnedFilters, appFilters] = partition(
injectFilterReferences(doc.state?.filters || [], doc.references),
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
index 15704925b1c6b..92c7f213d2157 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
@@ -16,6 +16,7 @@ import type {
TimefilterContract,
TimeRange,
IndexPattern,
+ FilterManager,
} from 'src/plugins/data/public';
import type { PaletteOutput } from 'src/plugins/charts/public';
import type { Start as InspectorStart } from 'src/plugins/inspector/public';
@@ -42,7 +43,7 @@ import {
SavedObjectEmbeddableInput,
ReferenceOrValueEmbeddable,
} from '../../../../../src/plugins/embeddable/public';
-import { Document, injectFilterReferences } from '../persistence';
+import { Document } from '../persistence';
import { ExpressionWrapper, ExpressionWrapperProps } from './expression_wrapper';
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
import {
@@ -105,6 +106,7 @@ export interface LensEmbeddableDeps {
indexPatternService: IndexPatternsContract;
expressionRenderer: ReactExpressionRendererType;
timefilter: TimefilterContract;
+ injectFilterReferences: FilterManager['inject'];
basePath: IBasePath;
inspector: InspectorStart;
getTrigger?: UiActionsStart['getTrigger'] | undefined;
@@ -471,7 +473,7 @@ export class Embeddable
output.filters = [...this.savedVis.state.filters];
}
- output.filters = injectFilterReferences(output.filters, this.savedVis.references);
+ output.filters = this.deps.injectFilterReferences(output.filters, this.savedVis.references);
return output;
}
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
index 63b07affcb9ed..92b650478e372 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
+++ b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
@@ -10,7 +10,11 @@ import { i18n } from '@kbn/i18n';
import { RecursiveReadonly } from '@kbn/utility-types';
import { Ast } from '@kbn/interpreter/common';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
-import { IndexPatternsContract, TimefilterContract } from '../../../../../src/plugins/data/public';
+import {
+ FilterManager,
+ IndexPatternsContract,
+ TimefilterContract,
+} from '../../../../../src/plugins/data/public';
import { ReactExpressionRendererType } from '../../../../../src/plugins/expressions/public';
import {
EmbeddableFactoryDefinition,
@@ -29,6 +33,7 @@ import { VisualizationMap } from '../types';
export interface LensEmbeddableStartServices {
timefilter: TimefilterContract;
+ injectFilterReferences: FilterManager['inject'];
coreHttp: HttpSetup;
inspector: InspectorStart;
attributeService: LensAttributeService;
@@ -86,6 +91,7 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
async create(input: LensEmbeddableInput, parent?: IContainer) {
const {
timefilter,
+ injectFilterReferences,
expressionRenderer,
documentToExpression,
visualizationMap,
@@ -107,6 +113,7 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
attributeService,
indexPatternService,
timefilter,
+ injectFilterReferences,
inspector,
expressionRenderer,
basePath: coreHttp.basePath,
diff --git a/x-pack/plugins/lens/public/persistence/filter_references.test.ts b/x-pack/plugins/lens/public/persistence/filter_references.test.ts
deleted file mode 100644
index 8a86c6fdc9664..0000000000000
--- a/x-pack/plugins/lens/public/persistence/filter_references.test.ts
+++ /dev/null
@@ -1,112 +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
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { Filter } from '@kbn/es-query';
-import { extractFilterReferences, injectFilterReferences } from './filter_references';
-import { FilterStateStore } from 'src/plugins/data/common';
-
-describe('filter saved object references', () => {
- const filters: Filter[] = [
- {
- $state: { store: FilterStateStore.APP_STATE },
- meta: {
- alias: null,
- disabled: false,
- index: '90943e30-9a47-11e8-b64d-95841ca0b247',
- key: 'geo.src',
- negate: true,
- params: { query: 'CN' },
- type: 'phrase',
- },
- query: { match_phrase: { 'geo.src': 'CN' } },
- },
- {
- $state: { store: FilterStateStore.APP_STATE },
- meta: {
- alias: null,
- disabled: false,
- index: 'ff959d40-b880-11e8-a6d9-e546fe2bba5f',
- key: 'geoip.country_iso_code',
- negate: true,
- params: { query: 'US' },
- type: 'phrase',
- },
- query: { match_phrase: { 'geoip.country_iso_code': 'US' } },
- },
- ];
-
- it('should create two index-pattern references', () => {
- const { references } = extractFilterReferences(filters);
- expect(references).toMatchInlineSnapshot(`
- Array [
- Object {
- "id": "90943e30-9a47-11e8-b64d-95841ca0b247",
- "name": "filter-index-pattern-0",
- "type": "index-pattern",
- },
- Object {
- "id": "ff959d40-b880-11e8-a6d9-e546fe2bba5f",
- "name": "filter-index-pattern-1",
- "type": "index-pattern",
- },
- ]
- `);
- });
-
- it('should remove index and value from persistable filter', () => {
- const { persistableFilters } = extractFilterReferences([
- { ...filters[0], meta: { ...filters[0].meta, value: 'CN' } },
- { ...filters[1], meta: { ...filters[1].meta, value: 'US' } },
- ]);
- expect(persistableFilters.length).toBe(2);
- persistableFilters.forEach((filter) => {
- expect(filter.meta.hasOwnProperty('index')).toBe(false);
- expect(filter.meta.hasOwnProperty('value')).toBe(false);
- });
- });
-
- it('should restore the same filter after extracting and injecting', () => {
- const { persistableFilters, references } = extractFilterReferences(filters);
- expect(injectFilterReferences(persistableFilters, references)).toEqual(filters);
- });
-
- it('should ignore other references', () => {
- const { persistableFilters, references } = extractFilterReferences(filters);
- expect(
- injectFilterReferences(persistableFilters, [
- { type: 'index-pattern', id: '1234', name: 'some other index pattern' },
- ...references,
- ])
- ).toEqual(filters);
- });
-
- it('should inject other ids if references change', () => {
- const { persistableFilters, references } = extractFilterReferences(filters);
-
- expect(
- injectFilterReferences(
- persistableFilters,
- references.map((reference, index) => ({ ...reference, id: `overwritten-id-${index}` }))
- )
- ).toEqual([
- {
- ...filters[0],
- meta: {
- ...filters[0].meta,
- index: 'overwritten-id-0',
- },
- },
- {
- ...filters[1],
- meta: {
- ...filters[1].meta,
- index: 'overwritten-id-1',
- },
- },
- ]);
- });
-});
diff --git a/x-pack/plugins/lens/public/persistence/filter_references.ts b/x-pack/plugins/lens/public/persistence/filter_references.ts
deleted file mode 100644
index d080e2157c3d3..0000000000000
--- a/x-pack/plugins/lens/public/persistence/filter_references.ts
+++ /dev/null
@@ -1,62 +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
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { Filter } from '@kbn/es-query';
-import { SavedObjectReference } from 'kibana/public';
-import { PersistableFilter } from '../../common';
-
-export function extractFilterReferences(filters: Filter[]): {
- persistableFilters: PersistableFilter[];
- references: SavedObjectReference[];
-} {
- const references: SavedObjectReference[] = [];
- const persistableFilters = filters.map((filterRow, i) => {
- if (!filterRow.meta || !filterRow.meta.index) {
- return filterRow;
- }
- const refName = `filter-index-pattern-${i}`;
- references.push({
- name: refName,
- type: 'index-pattern',
- id: filterRow.meta.index,
- });
- const newFilter = {
- ...filterRow,
- meta: {
- ...filterRow.meta,
- indexRefName: refName,
- },
- };
- // remove index because it's specified by indexRefName
- delete newFilter.meta.index;
- // remove value because it can't be persisted
- delete newFilter.meta.value;
- return newFilter;
- });
-
- return { persistableFilters, references };
-}
-
-export function injectFilterReferences(
- filters: PersistableFilter[],
- references: SavedObjectReference[]
-) {
- return filters.map((filterRow) => {
- if (!filterRow.meta || !filterRow.meta.indexRefName) {
- return filterRow as Filter;
- }
- const { indexRefName, ...metaRest } = filterRow.meta;
- const reference = references.find((ref) => ref.name === indexRefName);
- if (!reference) {
- throw new Error(`Could not find reference for ${indexRefName}`);
- }
- return {
- ...filterRow,
- meta: { ...metaRest, index: reference.id },
- };
- });
-}
diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts
index b89492d7e7588..15ed6a9fa0b42 100644
--- a/x-pack/plugins/lens/public/plugin.ts
+++ b/x-pack/plugins/lens/public/plugin.ts
@@ -208,6 +208,7 @@ export class LensPlugin {
capabilities: coreStart.application.capabilities,
coreHttp: coreStart.http,
timefilter: plugins.data.query.timefilter.timefilter,
+ injectFilterReferences: plugins.data.query.filterManager.inject,
expressionRenderer: plugins.expressions.ReactExpressionRenderer,
documentToExpression: this.editorFrameService!.documentToExpression,
visualizationMap,
diff --git a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
index 915c56d59dbb3..b0272bed25875 100644
--- a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
+++ b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
@@ -16,7 +16,7 @@ import { getInitialDatasourceId } from '../../utils';
import { initializeDatasources } from '../../editor_frame_service/editor_frame';
import { LensAppServices } from '../../app_plugin/types';
import { getEditPath, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../../common/constants';
-import { Document, injectFilterReferences } from '../../persistence';
+import { Document } from '../../persistence';
export const getPersisted = async ({
initialInput,
@@ -29,7 +29,7 @@ export const getPersisted = async ({
}): Promise<
{ doc: Document; sharingSavedObjectProps: Omit } | undefined
> => {
- const { notifications, spaces, attributeService } = lensServices;
+ const { notifications, spaces, attributeService, data } = lensServices;
let doc: Document;
try {
@@ -163,7 +163,7 @@ export function loadInitial(
{}
);
- const filters = injectFilterReferences(doc.state.filters, doc.references);
+ const filters = data.query.filterManager.inject(doc.state.filters, doc.references);
// Don't overwrite any pinned filters
data.query.filterManager.setAppFilters(filters);
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index ee5718fab8b5d..5f792684ad25f 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -43,20 +43,14 @@ export const selectExecutionContextSearch = createSelector(selectExecutionContex
filters: res.filters,
}));
-const selectDatasourceMap = (state: LensState, datasourceMap: DatasourceMap) => datasourceMap;
-
-const selectVisualizationMap = (
- state: LensState,
- datasourceMap: DatasourceMap,
- visualizationMap: VisualizationMap
-) => visualizationMap;
-
-const selectExtractFilterReferences = (
- state: LensState,
- datasourceMap: DatasourceMap,
- visualizationMap: VisualizationMap,
- extractFilterReferences: FilterManager['extract']
-) => extractFilterReferences;
+const selectDependencies = (
+ _state: LensState,
+ dependencies: {
+ datasourceMap: DatasourceMap;
+ visualizationMap: VisualizationMap;
+ extractFilterReferences: FilterManager['extract'];
+ }
+) => dependencies;
export const selectSavedObjectFormat = createSelector(
[
@@ -66,9 +60,7 @@ export const selectSavedObjectFormat = createSelector(
selectQuery,
selectFilters,
selectActiveDatasourceId,
- selectDatasourceMap,
- selectVisualizationMap,
- selectExtractFilterReferences,
+ selectDependencies,
],
(
persistedDoc,
@@ -77,9 +69,7 @@ export const selectSavedObjectFormat = createSelector(
query,
filters,
activeDatasourceId,
- datasourceMap,
- visualizationMap,
- extractFilterReferences
+ { datasourceMap, visualizationMap, extractFilterReferences }
) => {
const activeVisualization =
visualization.state && visualization.activeId && visualizationMap[visualization.activeId];
From 133f488696aac05ea1c6eb9a0163b4edafc1c322 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Thu, 2 Dec 2021 11:11:10 -0600
Subject: [PATCH 04/52] apply migration in embedded context
---
.../embeddable/lens_embeddable_factory.ts | 9 +++++
.../server/migrations/common_migrations.ts | 9 +++++
.../saved_object_migrations.test.ts | 36 +++++--------------
.../migrations/saved_object_migrations.ts | 11 ++----
4 files changed, 29 insertions(+), 36 deletions(-)
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
index 0e79e342d4427..90f3083220ccf 100644
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
@@ -11,6 +11,7 @@ import { DOC_TYPE } from '../../common';
import {
commonMakeReversePaletteAsCustom,
commonRemoveTimezoneDateHistogramParam,
+ commonRenameFilterReferences,
commonRenameOperationsForFormula,
commonUpdateVisLayerType,
} from '../migrations/common_migrations';
@@ -60,6 +61,14 @@ export const lensEmbeddableFactory = (): EmbeddableRegistryDefinition => {
attributes: migratedLensState,
} as unknown as SerializableRecord;
},
+ '8.1.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonRenameFilterReferences(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
},
extract,
inject,
diff --git a/x-pack/plugins/lens/server/migrations/common_migrations.ts b/x-pack/plugins/lens/server/migrations/common_migrations.ts
index 290655ec634eb..13a10b9231cab 100644
--- a/x-pack/plugins/lens/server/migrations/common_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/common_migrations.ts
@@ -155,3 +155,12 @@ export const commonMakeReversePaletteAsCustom = (
}
return newAttributes;
};
+
+export const commonRenameFilterReferences = (attributes: LensDocShape715) => {
+ const newAttributes = cloneDeep(attributes);
+ for (const filter of newAttributes.state.filters) {
+ filter.meta.index = filter.meta.indexRefName;
+ delete filter.meta.indexRefName;
+ }
+ return newAttributes;
+};
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
index dc8ffc25cc3df..b8b5ee29d2c96 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
@@ -1491,35 +1491,17 @@ describe('Lens migrations', () => {
},
} as unknown as SavedObjectUnsanitizedDoc>;
- it('should migrate filters schema', () => {
- const expectedFilters = [
- {
+ it('should rename indexRefName to index in filters metadata', () => {
+ const expectedFilters = example.attributes.state.filters.map((filter) => {
+ return {
+ ...filter,
meta: {
- alias: null,
- negate: false,
- disabled: false,
- type: 'phrase',
- key: 'geo.src',
- params: { query: 'US' },
- index: 'filter-index-pattern-0',
+ ...filter.meta,
+ index: filter.meta.indexRefName,
+ indexRefName: undefined,
},
- query: { match_phrase: { 'geo.src': 'US' } },
- $state: { store: 'appState' },
- },
- {
- meta: {
- alias: null,
- negate: false,
- disabled: false,
- type: 'phrase',
- key: 'client_ip',
- params: { query: '1234.5344.2243.3245' },
- index: 'filter-index-pattern-2',
- },
- query: { match_phrase: { client_ip: '1234.5344.2243.3245' } },
- $state: { store: 'appState' },
- },
- ];
+ };
+ });
const result = migrations['8.1.0'](example, context) as ReturnType<
SavedObjectMigrationFn
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
index 5b6114e002509..77cc9936d8dda 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
@@ -25,13 +25,13 @@ import {
VisStatePost715,
VisStatePre715,
VisState716,
- LensDocShape810,
} from './types';
import {
commonRenameOperationsForFormula,
commonRemoveTimezoneDateHistogramParam,
commonUpdateVisLayerType,
commonMakeReversePaletteAsCustom,
+ commonRenameFilterReferences,
} from './common_migrations';
interface LensDocShapePre710 {
@@ -444,14 +444,7 @@ const renameFilterReferences: SavedObjectMigrationFn<
LensDocShape715
> = (doc) => {
const newDoc = cloneDeep(doc);
- const newFilters = newDoc.attributes.state.filters.map((filter) => {
- const ret = cloneDeep(filter);
- ret.meta.index = ret.meta.indexRefName;
- delete ret.meta.indexRefName;
- return ret as Filter;
- });
- newDoc.attributes.state.filters = newFilters;
- return newDoc;
+ return { ...newDoc, attributes: commonRenameFilterReferences(newDoc.attributes) };
};
export const migrations: SavedObjectMigrationMap = {
From fbb3835c63f9e95cc34c07c564b9cc0e7454b7e0 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Fri, 3 Dec 2021 09:21:04 -0600
Subject: [PATCH 05/52] some fixes
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 14 +++++++--
.../public/embeddable/embeddable.test.tsx | 20 +++++++++++++
.../plugins/lens/public/persistence/index.ts | 1 -
.../init_middleware/load_initial.ts | 2 +-
.../lens/public/state_management/selectors.ts | 29 ++++++++++++-------
5 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 3113dc4288a0d..3fac2c58abac6 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -155,7 +155,10 @@ export function App({
if (
application.capabilities.visualize.save &&
- !isEqual(persistedDoc?.state, getLastKnownDocWithoutPinnedFilters(lastKnownDoc)?.state) &&
+ !isEqual(
+ persistedDoc?.state,
+ getLastKnownDocWithoutPinnedFilters(data.query.filterManager.inject, lastKnownDoc)?.state
+ ) &&
(isSaveable || persistedDoc)
) {
return actions.confirm(
@@ -170,7 +173,14 @@ export function App({
return actions.default();
}
});
- }, [onAppLeave, lastKnownDoc, isSaveable, persistedDoc, application.capabilities.visualize.save]);
+ }, [
+ onAppLeave,
+ lastKnownDoc,
+ isSaveable,
+ persistedDoc,
+ application.capabilities.visualize.save,
+ data.query.filterManager.inject,
+ ]);
const getLegacyUrlConflictCallout = useCallback(() => {
// This function returns a callout component *if* we have encountered a "legacy URL conflict" scenario
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index b07962c6e66a0..b0029aff69cfe 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -129,6 +129,7 @@ describe('embeddable', () => {
getTrigger,
theme: themeServiceMock.createStartContract(),
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
documentToExpression: () =>
Promise.resolve({
ast: {
@@ -170,6 +171,7 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -216,6 +218,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -264,6 +267,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -308,6 +312,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -349,6 +354,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -393,6 +399,7 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -444,6 +451,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -493,6 +501,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -549,6 +558,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -606,6 +616,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -666,6 +677,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -710,6 +722,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -754,6 +767,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -798,6 +812,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -857,6 +872,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -932,6 +948,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -982,6 +999,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1032,6 +1050,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1108,6 +1127,7 @@ describe('embeddable', () => {
onEditAction: onEditActionMock,
} as unknown as Visualization,
},
+ injectFilterReferences: jest.fn(),
documentToExpression: documentToExpressionMock,
},
{ id: '123' } as unknown as LensEmbeddableInput
diff --git a/x-pack/plugins/lens/public/persistence/index.ts b/x-pack/plugins/lens/public/persistence/index.ts
index 66f75aed35fcc..376986c545681 100644
--- a/x-pack/plugins/lens/public/persistence/index.ts
+++ b/x-pack/plugins/lens/public/persistence/index.ts
@@ -6,4 +6,3 @@
*/
export * from './saved_object_store';
-export * from './filter_references';
diff --git a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
index b0272bed25875..06b51b6a766cf 100644
--- a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
+++ b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
@@ -29,7 +29,7 @@ export const getPersisted = async ({
}): Promise<
{ doc: Document; sharingSavedObjectProps: Omit } | undefined
> => {
- const { notifications, spaces, attributeService, data } = lensServices;
+ const { notifications, spaces, attributeService } = lensServices;
let doc: Document;
try {
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index 5f792684ad25f..250e9dde31373 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -43,14 +43,10 @@ export const selectExecutionContextSearch = createSelector(selectExecutionContex
filters: res.filters,
}));
-const selectDependencies = (
- _state: LensState,
- dependencies: {
- datasourceMap: DatasourceMap;
- visualizationMap: VisualizationMap;
- extractFilterReferences: FilterManager['extract'];
- }
-) => dependencies;
+const selectInjectedDependencies = (_state: LensState, dependencies: unknown) => dependencies;
+
+// use this type to cast selectInjectedDependencies to require whatever outside dependencies the selector needs
+type SelectInjectedDependenciesFunction = (state: LensState, dependencies: T) => T;
export const selectSavedObjectFormat = createSelector(
[
@@ -60,7 +56,11 @@ export const selectSavedObjectFormat = createSelector(
selectQuery,
selectFilters,
selectActiveDatasourceId,
- selectDependencies,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction<{
+ datasourceMap: DatasourceMap;
+ visualizationMap: VisualizationMap;
+ extractFilterReferences: FilterManager['extract'];
+ }>,
],
(
persistedDoc,
@@ -140,12 +140,19 @@ export const selectAreDatasourcesLoaded = createSelector(
);
export const selectDatasourceLayers = createSelector(
- [selectDatasourceStates, selectDatasourceMap],
+ [
+ selectDatasourceStates,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction,
+ ],
(datasourceStates, datasourceMap) => getDatasourceLayers(datasourceStates, datasourceMap)
);
export const selectFramePublicAPI = createSelector(
- [selectDatasourceStates, selectActiveData, selectDatasourceMap],
+ [
+ selectDatasourceStates,
+ selectActiveData,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction,
+ ],
(datasourceStates, activeData, datasourceMap) => {
return {
datasourceLayers: getDatasourceLayers(datasourceStates, datasourceMap),
From f17bb31cf101cb3abb3352a5913fb506662f9898 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Fri, 3 Dec 2021 10:01:12 -0600
Subject: [PATCH 06/52] expose query service in server data plugin setup
---
src/plugins/data/server/plugin.ts | 5 ++++-
src/plugins/data/server/query/index.ts | 2 +-
src/plugins/data/server/query/query_service.ts | 3 +++
x-pack/plugins/lens/server/plugin.tsx | 8 ++++++--
x-pack/plugins/lens/server/saved_objects.ts | 11 +++++++++--
5 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index cb52500e78f94..dbc4c12964f02 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -20,6 +20,7 @@ import { UsageCollectionSetup } from '../../usage_collection/server';
import { AutocompleteService } from './autocomplete';
import { FieldFormatsSetup, FieldFormatsStart } from '../../field_formats/server';
import { getUiSettings } from './ui_settings';
+import { QuerySetup } from './query';
export interface DataEnhancements {
search: SearchEnhancements;
@@ -31,6 +32,7 @@ export interface DataPluginSetup {
* @deprecated - use "fieldFormats" plugin directly instead
*/
fieldFormats: FieldFormatsSetup;
+ query: QuerySetup;
/**
* @internal
*/
@@ -88,7 +90,7 @@ export class DataServerPlugin
{ bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies
) {
this.scriptsService.setup(core);
- this.queryService.setup(core);
+ const queryService = this.queryService.setup(core);
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });
@@ -105,6 +107,7 @@ export class DataServerPlugin
searchSetup.__enhance(enhancements.search);
},
search: searchSetup,
+ query: queryService,
fieldFormats,
};
}
diff --git a/src/plugins/data/server/query/index.ts b/src/plugins/data/server/query/index.ts
index 1f394e9fc89f9..7a1d2326fdc7e 100644
--- a/src/plugins/data/server/query/index.ts
+++ b/src/plugins/data/server/query/index.ts
@@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
-export { QueryService } from './query_service';
+export { QueryService, QuerySetup } from './query_service';
diff --git a/src/plugins/data/server/query/query_service.ts b/src/plugins/data/server/query/query_service.ts
index 173abeda0c951..33aeecbc11df1 100644
--- a/src/plugins/data/server/query/query_service.ts
+++ b/src/plugins/data/server/query/query_service.ts
@@ -36,3 +36,6 @@ export class QueryService implements Plugin {
public start() {}
}
+
+/** @public */
+export type QuerySetup = ReturnType;
diff --git a/x-pack/plugins/lens/server/plugin.tsx b/x-pack/plugins/lens/server/plugin.tsx
index 42e68c6223b6d..aa6a6968d5ada 100644
--- a/x-pack/plugins/lens/server/plugin.tsx
+++ b/x-pack/plugins/lens/server/plugin.tsx
@@ -7,7 +7,10 @@
import { Plugin, CoreSetup, CoreStart, PluginInitializerContext, Logger } from 'src/core/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
-import { PluginStart as DataPluginStart } from 'src/plugins/data/server';
+import {
+ PluginStart as DataPluginStart,
+ PluginSetup as DataPluginSetup,
+} from 'src/plugins/data/server';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { FieldFormatsStart } from 'src/plugins/field_formats/server';
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
@@ -27,6 +30,7 @@ export interface PluginSetupContract {
taskManager?: TaskManagerSetupContract;
embeddable: EmbeddableSetup;
expressions: ExpressionsServerSetup;
+ data: DataPluginSetup;
}
export interface PluginStartContract {
@@ -47,7 +51,7 @@ export class LensServerPlugin implements Plugin, plugins: PluginSetupContract) {
- setupSavedObjects(core);
+ setupSavedObjects(core, plugins.data.query.filterManager.getAllMigrations());
setupRoutes(core, this.initializerContext.logger.get());
setupExpressions(core, plugins.expressions);
diff --git a/x-pack/plugins/lens/server/saved_objects.ts b/x-pack/plugins/lens/server/saved_objects.ts
index 4e376b23b3374..5953c71b25866 100644
--- a/x-pack/plugins/lens/server/saved_objects.ts
+++ b/x-pack/plugins/lens/server/saved_objects.ts
@@ -6,10 +6,14 @@
*/
import { CoreSetup } from 'kibana/server';
+import {
+ mergeMigrationFunctionMaps,
+ MigrateFunctionsObject,
+} from 'src/plugins/kibana_utils/common';
import { getEditPath } from '../common';
import { migrations } from './migrations/saved_object_migrations';
-export function setupSavedObjects(core: CoreSetup) {
+export function setupSavedObjects(core: CoreSetup, filterMigrations: MigrateFunctionsObject) {
core.savedObjects.registerType({
name: 'lens',
hidden: false,
@@ -25,7 +29,10 @@ export function setupSavedObjects(core: CoreSetup) {
uiCapabilitiesPath: 'visualize.show',
}),
},
- migrations,
+ migrations: mergeMigrationFunctionMaps(
+ migrations as unknown as MigrateFunctionsObject,
+ filterMigrations
+ ),
mappings: {
properties: {
title: {
From 7218e4f769cdaf0b4e7dea1edc368b18510faf78 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Fri, 3 Dec 2021 10:21:10 -0600
Subject: [PATCH 07/52] apply filter migrations to embedded lens visualizations
---
.../embeddable/lens_embeddable_factory.ts | 76 -----------------
...> lens_embeddable_factory_factory.test.ts} | 4 +-
.../lens_embeddable_factory_factory.ts | 81 +++++++++++++++++++
x-pack/plugins/lens/server/plugin.tsx | 9 ++-
x-pack/plugins/lens/server/saved_objects.ts | 4 +-
5 files changed, 91 insertions(+), 83 deletions(-)
delete mode 100644 x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
rename x-pack/plugins/lens/server/embeddable/{lens_embeddable_factory.test.ts => lens_embeddable_factory_factory.test.ts} (82%)
create mode 100644 x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
deleted file mode 100644
index 90f3083220ccf..0000000000000
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
+++ /dev/null
@@ -1,76 +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
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { EmbeddableRegistryDefinition } from 'src/plugins/embeddable/server';
-import type { SerializableRecord } from '@kbn/utility-types';
-import { DOC_TYPE } from '../../common';
-import {
- commonMakeReversePaletteAsCustom,
- commonRemoveTimezoneDateHistogramParam,
- commonRenameFilterReferences,
- commonRenameOperationsForFormula,
- commonUpdateVisLayerType,
-} from '../migrations/common_migrations';
-import {
- LensDocShape713,
- LensDocShape715,
- LensDocShapePre712,
- VisState716,
- VisStatePre715,
-} from '../migrations/types';
-import { extract, inject } from '../../common/embeddable_factory';
-
-export const lensEmbeddableFactory = (): EmbeddableRegistryDefinition => {
- return {
- id: DOC_TYPE,
- migrations: {
- // This migration is run in 7.13.1 for `by value` panels because the 7.13 release window was missed.
- '7.13.1': (state) => {
- const lensState = state as unknown as { attributes: LensDocShapePre712 };
- const migratedLensState = commonRenameOperationsForFormula(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.14.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape713 };
- const migratedLensState = commonRemoveTimezoneDateHistogramParam(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.15.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonUpdateVisLayerType(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.16.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonMakeReversePaletteAsCustom(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '8.1.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonRenameFilterReferences(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- },
- extract,
- inject,
- };
-};
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts
similarity index 82%
rename from x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts
rename to x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts
index 9ce405804bde1..0987eeb83a34d 100644
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts
@@ -6,7 +6,7 @@
*/
import semverGte from 'semver/functions/gte';
-import { lensEmbeddableFactory } from './lens_embeddable_factory';
+import { lensEmbeddableFactoryFactory } from './lens_embeddable_factory_factory';
import { migrations } from '../migrations/saved_object_migrations';
describe('saved object migrations and embeddable migrations', () => {
@@ -14,7 +14,7 @@ describe('saved object migrations and embeddable migrations', () => {
const savedObjectMigrationVersions = Object.keys(migrations).filter((version) => {
return semverGte(version, '7.13.1');
});
- const embeddableMigrationVersions = lensEmbeddableFactory()?.migrations;
+ const embeddableMigrationVersions = lensEmbeddableFactoryFactory({})()?.migrations;
if (embeddableMigrationVersions) {
expect(savedObjectMigrationVersions.sort()).toEqual(
Object.keys(embeddableMigrationVersions).sort()
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
new file mode 100644
index 0000000000000..0495c8d417ea5
--- /dev/null
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
@@ -0,0 +1,81 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { EmbeddableRegistryDefinition } from 'src/plugins/embeddable/server';
+import type { SerializableRecord } from '@kbn/utility-types';
+import {
+ mergeMigrationFunctionMaps,
+ MigrateFunctionsObject,
+} from 'src/plugins/kibana_utils/common';
+import { DOC_TYPE } from '../../common';
+import {
+ commonMakeReversePaletteAsCustom,
+ commonRemoveTimezoneDateHistogramParam,
+ commonRenameFilterReferences,
+ commonRenameOperationsForFormula,
+ commonUpdateVisLayerType,
+} from '../migrations/common_migrations';
+import {
+ LensDocShape713,
+ LensDocShape715,
+ LensDocShapePre712,
+ VisState716,
+ VisStatePre715,
+} from '../migrations/types';
+import { extract, inject } from '../../common/embeddable_factory';
+
+export const lensEmbeddableFactoryFactory =
+ (filterMigrations: MigrateFunctionsObject) => (): EmbeddableRegistryDefinition => {
+ return {
+ id: DOC_TYPE,
+ migrations: mergeMigrationFunctionMaps(filterMigrations, {
+ // This migration is run in 7.13.1 for `by value` panels because the 7.13 release window was missed.
+ '7.13.1': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShapePre712 };
+ const migratedLensState = commonRenameOperationsForFormula(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.14.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape713 };
+ const migratedLensState = commonRemoveTimezoneDateHistogramParam(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.15.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonUpdateVisLayerType(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.16.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonMakeReversePaletteAsCustom(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '8.1.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonRenameFilterReferences(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ }),
+ extract,
+ inject,
+ };
+ };
diff --git a/x-pack/plugins/lens/server/plugin.tsx b/x-pack/plugins/lens/server/plugin.tsx
index aa6a6968d5ada..df60e0fc1d71f 100644
--- a/x-pack/plugins/lens/server/plugin.tsx
+++ b/x-pack/plugins/lens/server/plugin.tsx
@@ -22,7 +22,7 @@ import {
} from './usage';
import { setupSavedObjects } from './saved_objects';
import { EmbeddableSetup } from '../../../../src/plugins/embeddable/server';
-import { lensEmbeddableFactory } from './embeddable/lens_embeddable_factory';
+import { lensEmbeddableFactoryFactory } from './embeddable/lens_embeddable_factory_factory';
import { setupExpressions } from './expressions';
export interface PluginSetupContract {
@@ -40,7 +40,7 @@ export interface PluginStartContract {
}
export interface LensServerPluginSetup {
- lensEmbeddableFactory: typeof lensEmbeddableFactory;
+ lensEmbeddableFactory: ReturnType;
}
export class LensServerPlugin implements Plugin {
@@ -51,7 +51,8 @@ export class LensServerPlugin implements Plugin, plugins: PluginSetupContract) {
- setupSavedObjects(core, plugins.data.query.filterManager.getAllMigrations());
+ const filterMigrations = plugins.data.query.filterManager.getAllMigrations();
+ setupSavedObjects(core, filterMigrations);
setupRoutes(core, this.initializerContext.logger.get());
setupExpressions(core, plugins.expressions);
@@ -65,6 +66,8 @@ export class LensServerPlugin implements Plugin
Date: Fri, 3 Dec 2021 11:42:49 -0600
Subject: [PATCH 08/52] fix imports
---
.../lens/server/embeddable/lens_embeddable_factory_factory.ts | 2 +-
x-pack/plugins/lens/server/saved_objects.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
index 0495c8d417ea5..7d4b8736fee02 100644
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
@@ -10,7 +10,7 @@ import type { SerializableRecord } from '@kbn/utility-types';
import {
mergeMigrationFunctionMaps,
MigrateFunctionsObject,
-} from 'src/plugins/kibana_utils/common';
+} from '../../../../../src/plugins/kibana_utils/common';
import { DOC_TYPE } from '../../common';
import {
commonMakeReversePaletteAsCustom,
diff --git a/x-pack/plugins/lens/server/saved_objects.ts b/x-pack/plugins/lens/server/saved_objects.ts
index 414107a2f12ff..9680a401086eb 100644
--- a/x-pack/plugins/lens/server/saved_objects.ts
+++ b/x-pack/plugins/lens/server/saved_objects.ts
@@ -9,7 +9,7 @@ import { CoreSetup } from 'kibana/server';
import {
mergeMigrationFunctionMaps,
MigrateFunctionsObject,
-} from 'src/plugins/kibana_utils/common';
+} from '../../../../src/plugins/kibana_utils/common';
import { getEditPath } from '../common';
import { migrations } from './migrations/saved_object_migrations';
From 9ad9b376135db3f2c04ab2f38da55fc3383621c6 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Fri, 3 Dec 2021 15:14:16 -0600
Subject: [PATCH 09/52] fix type export
---
src/plugins/data/server/query/index.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/plugins/data/server/query/index.ts b/src/plugins/data/server/query/index.ts
index 7a1d2326fdc7e..4cf4b04bef272 100644
--- a/src/plugins/data/server/query/index.ts
+++ b/src/plugins/data/server/query/index.ts
@@ -6,4 +6,5 @@
* Side Public License, v 1.
*/
-export { QueryService, QuerySetup } from './query_service';
+export type { QuerySetup } from './query_service';
+export { QueryService } from './query_service';
From 4ba73598925a85852662a053e24b3c61a5097d68 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Fri, 3 Dec 2021 15:48:02 -0600
Subject: [PATCH 10/52] statically import filter inject/extract
---
src/plugins/data/common/query/index.ts | 1 +
x-pack/plugins/lens/public/app_plugin/app.tsx | 6 +-----
.../app_plugin/save_modal_container.tsx | 20 ++++++-------------
.../public/embeddable/embeddable.test.tsx | 20 -------------------
.../lens/public/embeddable/embeddable.tsx | 5 ++---
.../public/embeddable/embeddable_factory.ts | 9 +--------
x-pack/plugins/lens/public/plugin.ts | 1 -
.../lens/public/state_management/selectors.ts | 5 ++---
8 files changed, 13 insertions(+), 54 deletions(-)
diff --git a/src/plugins/data/common/query/index.ts b/src/plugins/data/common/query/index.ts
index 35b1617dfa7d6..95f69a14b1f56 100644
--- a/src/plugins/data/common/query/index.ts
+++ b/src/plugins/data/common/query/index.ts
@@ -9,3 +9,4 @@
export * from './timefilter';
export * from './types';
export * from './is_query';
+export * from './persistable_state';
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 3fac2c58abac6..2f81f3b5c1d7f 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -96,7 +96,6 @@ export function App({
selectSavedObjectFormat(state, {
datasourceMap,
visualizationMap,
- extractFilterReferences: data.query.filterManager.extract,
})
);
@@ -155,10 +154,7 @@ export function App({
if (
application.capabilities.visualize.save &&
- !isEqual(
- persistedDoc?.state,
- getLastKnownDocWithoutPinnedFilters(data.query.filterManager.inject, lastKnownDoc)?.state
- ) &&
+ !isEqual(persistedDoc?.state, getLastKnownDocWithoutPinnedFilters(lastKnownDoc)?.state) &&
(isSaveable || persistedDoc)
) {
return actions.confirm(
diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
index 6a34ca331534e..07f9b6fba8c79 100644
--- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
@@ -11,12 +11,13 @@ import { METRIC_TYPE } from '@kbn/analytics';
import { partition } from 'lodash';
import type { SavedObjectReference } from 'kibana/public';
+import { inject as injectFilterReferences } from '../../../../../src/plugins/data/common';
import { SaveModal } from './save_modal';
import type { LensAppProps, LensAppServices } from './types';
import type { SaveProps } from './app';
import { Document } from '../persistence';
import type { LensByReferenceInput, LensEmbeddableInput } from '../embeddable';
-import { esFilters, FilterManager } from '../../../../../src/plugins/data/public';
+import { esFilters } from '../../../../../src/plugins/data/public';
import { APP_ID, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../common';
import { trackUiEvent } from '../lens_ui_telemetry';
import { checkForDuplicateTitle } from '../../../../../src/plugins/saved_objects/public';
@@ -170,11 +171,10 @@ const redirectToDashboard = ({
const getDocToSave = (
lastKnownDoc: Document,
saveProps: SaveProps,
- references: SavedObjectReference[],
- injectFilterReferences: FilterManager['inject']
+ references: SavedObjectReference[]
) => {
const docToSave = {
- ...getLastKnownDocWithoutPinnedFilters(injectFilterReferences, lastKnownDoc)!,
+ ...getLastKnownDocWithoutPinnedFilters(lastKnownDoc)!,
references,
};
@@ -243,12 +243,7 @@ export const runSaveLensVisualization = async (
);
}
- const docToSave = getDocToSave(
- lastKnownDoc,
- saveProps,
- references,
- data.query.filterManager.inject
- );
+ const docToSave = getDocToSave(lastKnownDoc, saveProps, references);
// Required to serialize filters in by value mode until
// https://github.com/elastic/kibana/issues/77588 is fixed
@@ -359,10 +354,7 @@ export const runSaveLensVisualization = async (
}
};
-export function getLastKnownDocWithoutPinnedFilters(
- injectFilterReferences: FilterManager['inject'],
- doc?: Document
-) {
+export function getLastKnownDocWithoutPinnedFilters(doc?: Document) {
if (!doc) return undefined;
const [pinnedFilters, appFilters] = partition(
injectFilterReferences(doc.state?.filters || [], doc.references),
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index b0029aff69cfe..b07962c6e66a0 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -129,7 +129,6 @@ describe('embeddable', () => {
getTrigger,
theme: themeServiceMock.createStartContract(),
visualizationMap: {},
- injectFilterReferences: jest.fn(),
documentToExpression: () =>
Promise.resolve({
ast: {
@@ -171,7 +170,6 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -218,7 +216,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -267,7 +264,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -312,7 +308,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -354,7 +349,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -399,7 +393,6 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -451,7 +444,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -501,7 +493,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -558,7 +549,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -616,7 +606,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -677,7 +666,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -722,7 +710,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -767,7 +754,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -812,7 +798,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -872,7 +857,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -948,7 +932,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -999,7 +982,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1050,7 +1032,6 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
- injectFilterReferences: jest.fn(),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1127,7 +1108,6 @@ describe('embeddable', () => {
onEditAction: onEditActionMock,
} as unknown as Visualization,
},
- injectFilterReferences: jest.fn(),
documentToExpression: documentToExpressionMock,
},
{ id: '123' } as unknown as LensEmbeddableInput
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
index 92c7f213d2157..7fd69ccfe3b3f 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
@@ -16,7 +16,6 @@ import type {
TimefilterContract,
TimeRange,
IndexPattern,
- FilterManager,
} from 'src/plugins/data/public';
import type { PaletteOutput } from 'src/plugins/charts/public';
import type { Start as InspectorStart } from 'src/plugins/inspector/public';
@@ -28,6 +27,7 @@ import { map, distinctUntilChanged, skip } from 'rxjs/operators';
import fastIsEqual from 'fast-deep-equal';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { METRIC_TYPE } from '@kbn/analytics';
+import { inject as injectFilterReferences } from '../../../../../src/plugins/data/common';
import { KibanaThemeProvider } from '../../../../../src/plugins/kibana_react/public';
import {
ExpressionRendererEvent,
@@ -106,7 +106,6 @@ export interface LensEmbeddableDeps {
indexPatternService: IndexPatternsContract;
expressionRenderer: ReactExpressionRendererType;
timefilter: TimefilterContract;
- injectFilterReferences: FilterManager['inject'];
basePath: IBasePath;
inspector: InspectorStart;
getTrigger?: UiActionsStart['getTrigger'] | undefined;
@@ -473,7 +472,7 @@ export class Embeddable
output.filters = [...this.savedVis.state.filters];
}
- output.filters = this.deps.injectFilterReferences(output.filters, this.savedVis.references);
+ output.filters = injectFilterReferences(output.filters, this.savedVis.references);
return output;
}
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
index 92b650478e372..63b07affcb9ed 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
+++ b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
@@ -10,11 +10,7 @@ import { i18n } from '@kbn/i18n';
import { RecursiveReadonly } from '@kbn/utility-types';
import { Ast } from '@kbn/interpreter/common';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
-import {
- FilterManager,
- IndexPatternsContract,
- TimefilterContract,
-} from '../../../../../src/plugins/data/public';
+import { IndexPatternsContract, TimefilterContract } from '../../../../../src/plugins/data/public';
import { ReactExpressionRendererType } from '../../../../../src/plugins/expressions/public';
import {
EmbeddableFactoryDefinition,
@@ -33,7 +29,6 @@ import { VisualizationMap } from '../types';
export interface LensEmbeddableStartServices {
timefilter: TimefilterContract;
- injectFilterReferences: FilterManager['inject'];
coreHttp: HttpSetup;
inspector: InspectorStart;
attributeService: LensAttributeService;
@@ -91,7 +86,6 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
async create(input: LensEmbeddableInput, parent?: IContainer) {
const {
timefilter,
- injectFilterReferences,
expressionRenderer,
documentToExpression,
visualizationMap,
@@ -113,7 +107,6 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
attributeService,
indexPatternService,
timefilter,
- injectFilterReferences,
inspector,
expressionRenderer,
basePath: coreHttp.basePath,
diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts
index 15ed6a9fa0b42..b89492d7e7588 100644
--- a/x-pack/plugins/lens/public/plugin.ts
+++ b/x-pack/plugins/lens/public/plugin.ts
@@ -208,7 +208,6 @@ export class LensPlugin {
capabilities: coreStart.application.capabilities,
coreHttp: coreStart.http,
timefilter: plugins.data.query.timefilter.timefilter,
- injectFilterReferences: plugins.data.query.filterManager.inject,
expressionRenderer: plugins.expressions.ReactExpressionRenderer,
documentToExpression: this.editorFrameService!.documentToExpression,
visualizationMap,
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index 250e9dde31373..d75f84c077d5f 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -7,7 +7,7 @@
import { createSelector } from '@reduxjs/toolkit';
import { SavedObjectReference } from 'kibana/server';
-import { FilterManager } from 'src/plugins/data/public';
+import { extract as extractFilterReferences } from '../../../../../src/plugins/data/common';
import { LensState } from './types';
import { Datasource, DatasourceMap, VisualizationMap } from '../types';
import { getDatasourceLayers } from '../editor_frame_service/editor_frame';
@@ -59,7 +59,6 @@ export const selectSavedObjectFormat = createSelector(
selectInjectedDependencies as SelectInjectedDependenciesFunction<{
datasourceMap: DatasourceMap;
visualizationMap: VisualizationMap;
- extractFilterReferences: FilterManager['extract'];
}>,
],
(
@@ -69,7 +68,7 @@ export const selectSavedObjectFormat = createSelector(
query,
filters,
activeDatasourceId,
- { datasourceMap, visualizationMap, extractFilterReferences }
+ { datasourceMap, visualizationMap }
) => {
const activeVisualization =
visualization.state && visualization.activeId && visualizationMap[visualization.activeId];
From d1594a8f70b168c849c9b073d4c22f13928e6e2b Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 09:32:29 -0600
Subject: [PATCH 11/52] replacing dynamic injection with static import
---
.../public/state_management/init_middleware/load_initial.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
index 06b51b6a766cf..b30c07aa4f1ad 100644
--- a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
+++ b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
@@ -16,6 +16,7 @@ import { getInitialDatasourceId } from '../../utils';
import { initializeDatasources } from '../../editor_frame_service/editor_frame';
import { LensAppServices } from '../../app_plugin/types';
import { getEditPath, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../../common/constants';
+import { inject as injectFilterReferences } from '../../../../../../src/plugins/data/common';
import { Document } from '../../persistence';
export const getPersisted = async ({
@@ -163,7 +164,7 @@ export function loadInitial(
{}
);
- const filters = data.query.filterManager.inject(doc.state.filters, doc.references);
+ const filters = injectFilterReferences(doc.state.filters, doc.references);
// Don't overwrite any pinned filters
data.query.filterManager.setAppFilters(filters);
From 1e8d09edff7d9e1dbb4286c78a29a1dcbee449ce Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 09:48:25 -0600
Subject: [PATCH 12/52] a little more cleanup
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 9 +--------
.../lens/public/app_plugin/save_modal_container.tsx | 1 -
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 2f81f3b5c1d7f..098e1807732eb 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -169,14 +169,7 @@ export function App({
return actions.default();
}
});
- }, [
- onAppLeave,
- lastKnownDoc,
- isSaveable,
- persistedDoc,
- application.capabilities.visualize.save,
- data.query.filterManager.inject,
- ]);
+ }, [onAppLeave, lastKnownDoc, isSaveable, persistedDoc, application.capabilities.visualize.save]);
const getLegacyUrlConflictCallout = useCallback(() => {
// This function returns a callout component *if* we have encountered a "legacy URL conflict" scenario
diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
index 07f9b6fba8c79..23d7f62085fb3 100644
--- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
@@ -202,7 +202,6 @@ export const runSaveLensVisualization = async (
): Promise | undefined> => {
const {
chrome,
- data,
initialInput,
originatingApp,
lastKnownDoc,
From 9ff5fa9cd99bf03029a29cf40ce5de7dabb87e5d Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 11:50:30 -0600
Subject: [PATCH 13/52] apply filter migrations to lens migration map
---
...est.ts => lens_embeddable_factory.test.ts} | 4 +-
.../embeddable/lens_embeddable_factory.ts | 79 ++++++++++++++++++
.../lens_embeddable_factory_factory.ts | 81 -------------------
.../server/migrations/common_migrations.ts | 23 ++++++
.../saved_object_migrations.test.ts | 33 ++++++++
.../migrations/saved_object_migrations.ts | 13 ++-
x-pack/plugins/lens/server/plugin.tsx | 9 +--
x-pack/plugins/lens/server/saved_objects.ts | 11 +--
8 files changed, 154 insertions(+), 99 deletions(-)
rename x-pack/plugins/lens/server/embeddable/{lens_embeddable_factory_factory.test.ts => lens_embeddable_factory.test.ts} (82%)
create mode 100644 x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
delete mode 100644 x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts
similarity index 82%
rename from x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts
rename to x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts
index 0987eeb83a34d..9ce405804bde1 100644
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.test.ts
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.test.ts
@@ -6,7 +6,7 @@
*/
import semverGte from 'semver/functions/gte';
-import { lensEmbeddableFactoryFactory } from './lens_embeddable_factory_factory';
+import { lensEmbeddableFactory } from './lens_embeddable_factory';
import { migrations } from '../migrations/saved_object_migrations';
describe('saved object migrations and embeddable migrations', () => {
@@ -14,7 +14,7 @@ describe('saved object migrations and embeddable migrations', () => {
const savedObjectMigrationVersions = Object.keys(migrations).filter((version) => {
return semverGte(version, '7.13.1');
});
- const embeddableMigrationVersions = lensEmbeddableFactoryFactory({})()?.migrations;
+ const embeddableMigrationVersions = lensEmbeddableFactory()?.migrations;
if (embeddableMigrationVersions) {
expect(savedObjectMigrationVersions.sort()).toEqual(
Object.keys(embeddableMigrationVersions).sort()
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
new file mode 100644
index 0000000000000..403948354111b
--- /dev/null
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
@@ -0,0 +1,79 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { EmbeddableRegistryDefinition } from 'src/plugins/embeddable/server';
+import type { SerializableRecord } from '@kbn/utility-types';
+import { getAllMigrations } from 'src/plugins/data/common';
+import { mergeMigrationFunctionMaps } from '../../../../../src/plugins/kibana_utils/common';
+import { DOC_TYPE } from '../../common';
+import {
+ commonMakeReversePaletteAsCustom,
+ commonRemoveTimezoneDateHistogramParam,
+ commonRenameFilterReferences,
+ commonRenameOperationsForFormula,
+ commonUpdateVisLayerType,
+ getLensFilterMigrations,
+} from '../migrations/common_migrations';
+import {
+ LensDocShape713,
+ LensDocShape715,
+ LensDocShapePre712,
+ VisState716,
+ VisStatePre715,
+} from '../migrations/types';
+import { extract, inject } from '../../common/embeddable_factory';
+
+export const lensEmbeddableFactory = (): EmbeddableRegistryDefinition => {
+ return {
+ id: DOC_TYPE,
+ migrations: mergeMigrationFunctionMaps(getLensFilterMigrations(getAllMigrations()), {
+ // This migration is run in 7.13.1 for `by value` panels because the 7.13 release window was missed.
+ '7.13.1': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShapePre712 };
+ const migratedLensState = commonRenameOperationsForFormula(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.14.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape713 };
+ const migratedLensState = commonRemoveTimezoneDateHistogramParam(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.15.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonUpdateVisLayerType(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '7.16.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonMakeReversePaletteAsCustom(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ '8.1.0': (state) => {
+ const lensState = state as unknown as { attributes: LensDocShape715 };
+ const migratedLensState = commonRenameFilterReferences(lensState.attributes);
+ return {
+ ...lensState,
+ attributes: migratedLensState,
+ } as unknown as SerializableRecord;
+ },
+ }),
+ extract,
+ inject,
+ };
+};
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
deleted file mode 100644
index 7d4b8736fee02..0000000000000
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory_factory.ts
+++ /dev/null
@@ -1,81 +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
- * 2.0; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-import { EmbeddableRegistryDefinition } from 'src/plugins/embeddable/server';
-import type { SerializableRecord } from '@kbn/utility-types';
-import {
- mergeMigrationFunctionMaps,
- MigrateFunctionsObject,
-} from '../../../../../src/plugins/kibana_utils/common';
-import { DOC_TYPE } from '../../common';
-import {
- commonMakeReversePaletteAsCustom,
- commonRemoveTimezoneDateHistogramParam,
- commonRenameFilterReferences,
- commonRenameOperationsForFormula,
- commonUpdateVisLayerType,
-} from '../migrations/common_migrations';
-import {
- LensDocShape713,
- LensDocShape715,
- LensDocShapePre712,
- VisState716,
- VisStatePre715,
-} from '../migrations/types';
-import { extract, inject } from '../../common/embeddable_factory';
-
-export const lensEmbeddableFactoryFactory =
- (filterMigrations: MigrateFunctionsObject) => (): EmbeddableRegistryDefinition => {
- return {
- id: DOC_TYPE,
- migrations: mergeMigrationFunctionMaps(filterMigrations, {
- // This migration is run in 7.13.1 for `by value` panels because the 7.13 release window was missed.
- '7.13.1': (state) => {
- const lensState = state as unknown as { attributes: LensDocShapePre712 };
- const migratedLensState = commonRenameOperationsForFormula(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.14.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape713 };
- const migratedLensState = commonRemoveTimezoneDateHistogramParam(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.15.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonUpdateVisLayerType(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '7.16.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonMakeReversePaletteAsCustom(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- '8.1.0': (state) => {
- const lensState = state as unknown as { attributes: LensDocShape715 };
- const migratedLensState = commonRenameFilterReferences(lensState.attributes);
- return {
- ...lensState,
- attributes: migratedLensState,
- } as unknown as SerializableRecord;
- },
- }),
- extract,
- inject,
- };
- };
diff --git a/x-pack/plugins/lens/server/migrations/common_migrations.ts b/x-pack/plugins/lens/server/migrations/common_migrations.ts
index 13a10b9231cab..747dd76b28dba 100644
--- a/x-pack/plugins/lens/server/migrations/common_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/common_migrations.ts
@@ -7,6 +7,8 @@
import { cloneDeep } from 'lodash';
import { PaletteOutput } from 'src/plugins/charts/common';
+import { MigrateFunction, MigrateFunctionsObject } from 'src/plugins/kibana_utils/common';
+import { Filter } from '@kbn/es-query';
import {
LensDocShapePre712,
OperationTypePre712,
@@ -19,6 +21,7 @@ import {
VisState716,
} from './types';
import { CustomPaletteParams, layerTypes } from '../../common';
+import { LensDocShape } from './saved_object_migrations';
export const commonRenameOperationsForFormula = (
attributes: LensDocShapePre712
@@ -164,3 +167,23 @@ export const commonRenameFilterReferences = (attributes: LensDocShape715) => {
+ return (doc: LensDocShape) => ({
+ ...doc,
+ state: { ...doc.state, filters: doc.state.filters.map((filter) => filterMigration(filter)) },
+ });
+};
+
+/**
+ * This creates a migration map that applies filter migrations to Lens visualizations
+ */
+export const getLensFilterMigrations = (filterMigrations: MigrateFunctionsObject) => {
+ const migrationMap: MigrateFunctionsObject = {};
+ for (const version in filterMigrations) {
+ if (filterMigrations.hasOwnProperty(version)) {
+ migrationMap[version] = getApplyFilterMigrationToLens(filterMigrations[version]);
+ }
+ }
+ return migrationMap;
+};
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
index b8b5ee29d2c96..3306bbfee205d 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
@@ -15,6 +15,8 @@ import {
import { LensDocShape715, VisState716, VisStatePost715, VisStatePre715 } from './types';
import { CustomPaletteParams, layerTypes } from '../../common';
import { PaletteOutput } from 'src/plugins/charts/common';
+import { Filter } from '@kbn/es-query';
+import { getLensFilterMigrations } from './common_migrations';
describe('Lens migrations', () => {
describe('7.7.0 missing dimensions in XY', () => {
@@ -1510,4 +1512,35 @@ describe('Lens migrations', () => {
expect(result.attributes.state.filters).toEqual(expectedFilters);
});
});
+
+ describe('applying filter migrations', () => {
+ it('creates a filter migrations map that works on a lens visualization', () => {
+ const filterMigrations = {
+ '1.1': (filter: Filter) => ({ ...filter, version: '1.1' }),
+ '2.2': (filter: Filter) => ({ ...filter, version: '2.2' }),
+ '3.3': (filter: Filter) => ({ ...filter, version: '3.3' }),
+ };
+
+ const lensVisualization = {
+ state: {
+ filters: [{}, {}],
+ },
+ };
+
+ const migrationMap = getLensFilterMigrations(filterMigrations);
+
+ expect(migrationMap['1.1'](lensVisualization).state.filters).toEqual([
+ { version: '1.1' },
+ { version: '1.1' },
+ ]);
+ expect(migrationMap['2.2'](lensVisualization).state.filters).toEqual([
+ { version: '2.2' },
+ { version: '2.2' },
+ ]);
+ expect(migrationMap['3.3'](lensVisualization).state.filters).toEqual([
+ { version: '3.3' },
+ { version: '3.3' },
+ ]);
+ });
+ });
});
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
index 77cc9936d8dda..66904d40e6d06 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
@@ -15,6 +15,11 @@ import {
} from 'src/core/server';
import { Filter } from '@kbn/es-query';
import { Query } from 'src/plugins/data/public';
+import {
+ mergeMigrationFunctionMaps,
+ MigrateFunctionsObject,
+} from 'src/plugins/kibana_utils/common';
+import { getAllMigrations } from 'src/plugins/data/common';
import { PersistableFilter } from '../../common';
import {
LensDocShapePost712,
@@ -32,6 +37,7 @@ import {
commonUpdateVisLayerType,
commonMakeReversePaletteAsCustom,
commonRenameFilterReferences,
+ getLensFilterMigrations,
} from './common_migrations';
interface LensDocShapePre710 {
@@ -447,7 +453,7 @@ const renameFilterReferences: SavedObjectMigrationFn<
return { ...newDoc, attributes: commonRenameFilterReferences(newDoc.attributes) };
};
-export const migrations: SavedObjectMigrationMap = {
+const lensMigrations: SavedObjectMigrationMap = {
'7.7.0': removeInvalidAccessors,
// The order of these migrations matter, since the timefield migration relies on the aggConfigs
// sitting directly on the esaggs as an argument and not a nested function (which lens_auto_date was).
@@ -462,3 +468,8 @@ export const migrations: SavedObjectMigrationMap = {
'7.16.0': moveDefaultReversedPaletteToCustom,
'8.1.0': renameFilterReferences,
};
+
+export const migrations = mergeMigrationFunctionMaps(
+ lensMigrations as MigrateFunctionsObject,
+ getLensFilterMigrations(getAllMigrations())
+);
diff --git a/x-pack/plugins/lens/server/plugin.tsx b/x-pack/plugins/lens/server/plugin.tsx
index df60e0fc1d71f..9ddfb6f106e4d 100644
--- a/x-pack/plugins/lens/server/plugin.tsx
+++ b/x-pack/plugins/lens/server/plugin.tsx
@@ -22,8 +22,8 @@ import {
} from './usage';
import { setupSavedObjects } from './saved_objects';
import { EmbeddableSetup } from '../../../../src/plugins/embeddable/server';
-import { lensEmbeddableFactoryFactory } from './embeddable/lens_embeddable_factory_factory';
import { setupExpressions } from './expressions';
+import { lensEmbeddableFactory } from './embeddable/lens_embeddable_factory';
export interface PluginSetupContract {
usageCollection?: UsageCollectionSetup;
@@ -40,7 +40,7 @@ export interface PluginStartContract {
}
export interface LensServerPluginSetup {
- lensEmbeddableFactory: ReturnType;
+ lensEmbeddableFactory: typeof lensEmbeddableFactory;
}
export class LensServerPlugin implements Plugin {
@@ -51,8 +51,7 @@ export class LensServerPlugin implements Plugin, plugins: PluginSetupContract) {
- const filterMigrations = plugins.data.query.filterManager.getAllMigrations();
- setupSavedObjects(core, filterMigrations);
+ setupSavedObjects(core);
setupRoutes(core, this.initializerContext.logger.get());
setupExpressions(core, plugins.expressions);
@@ -66,8 +65,6 @@ export class LensServerPlugin implements Plugin
Date: Mon, 6 Dec 2021 11:54:46 -0600
Subject: [PATCH 14/52] remove unused query service dep
---
src/plugins/data/server/query/query_service.ts | 3 ---
x-pack/plugins/lens/server/plugin.tsx | 8 ++------
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/plugins/data/server/query/query_service.ts b/src/plugins/data/server/query/query_service.ts
index 33aeecbc11df1..173abeda0c951 100644
--- a/src/plugins/data/server/query/query_service.ts
+++ b/src/plugins/data/server/query/query_service.ts
@@ -36,6 +36,3 @@ export class QueryService implements Plugin {
public start() {}
}
-
-/** @public */
-export type QuerySetup = ReturnType;
diff --git a/x-pack/plugins/lens/server/plugin.tsx b/x-pack/plugins/lens/server/plugin.tsx
index 9ddfb6f106e4d..42e68c6223b6d 100644
--- a/x-pack/plugins/lens/server/plugin.tsx
+++ b/x-pack/plugins/lens/server/plugin.tsx
@@ -7,10 +7,7 @@
import { Plugin, CoreSetup, CoreStart, PluginInitializerContext, Logger } from 'src/core/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
-import {
- PluginStart as DataPluginStart,
- PluginSetup as DataPluginSetup,
-} from 'src/plugins/data/server';
+import { PluginStart as DataPluginStart } from 'src/plugins/data/server';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { FieldFormatsStart } from 'src/plugins/field_formats/server';
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
@@ -22,15 +19,14 @@ import {
} from './usage';
import { setupSavedObjects } from './saved_objects';
import { EmbeddableSetup } from '../../../../src/plugins/embeddable/server';
-import { setupExpressions } from './expressions';
import { lensEmbeddableFactory } from './embeddable/lens_embeddable_factory';
+import { setupExpressions } from './expressions';
export interface PluginSetupContract {
usageCollection?: UsageCollectionSetup;
taskManager?: TaskManagerSetupContract;
embeddable: EmbeddableSetup;
expressions: ExpressionsServerSetup;
- data: DataPluginSetup;
}
export interface PluginStartContract {
From 6ce57e3e003458aead5ec415128937cdb13e1f52 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 11:57:56 -0600
Subject: [PATCH 15/52] move a test
---
.../migrations/common_migrations.test.ts | 42 +++++++++++++++++++
.../saved_object_migrations.test.ts | 31 --------------
2 files changed, 42 insertions(+), 31 deletions(-)
create mode 100644 x-pack/plugins/lens/server/migrations/common_migrations.test.ts
diff --git a/x-pack/plugins/lens/server/migrations/common_migrations.test.ts b/x-pack/plugins/lens/server/migrations/common_migrations.test.ts
new file mode 100644
index 0000000000000..2fa7dc0c895f8
--- /dev/null
+++ b/x-pack/plugins/lens/server/migrations/common_migrations.test.ts
@@ -0,0 +1,42 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { Filter } from '@kbn/es-query';
+import { getLensFilterMigrations } from './common_migrations';
+
+describe('Lens migrations', () => {
+ describe('applying filter migrations', () => {
+ it('creates a filter migrations map that works on a lens visualization', () => {
+ const filterMigrations = {
+ '1.1': (filter: Filter) => ({ ...filter, version: '1.1' }),
+ '2.2': (filter: Filter) => ({ ...filter, version: '2.2' }),
+ '3.3': (filter: Filter) => ({ ...filter, version: '3.3' }),
+ };
+
+ const lensVisualization = {
+ state: {
+ filters: [{}, {}],
+ },
+ };
+
+ const migrationMap = getLensFilterMigrations(filterMigrations);
+
+ expect(migrationMap['1.1'](lensVisualization).state.filters).toEqual([
+ { version: '1.1' },
+ { version: '1.1' },
+ ]);
+ expect(migrationMap['2.2'](lensVisualization).state.filters).toEqual([
+ { version: '2.2' },
+ { version: '2.2' },
+ ]);
+ expect(migrationMap['3.3'](lensVisualization).state.filters).toEqual([
+ { version: '3.3' },
+ { version: '3.3' },
+ ]);
+ });
+ });
+});
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
index 3306bbfee205d..21b4a731c12bf 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
@@ -1512,35 +1512,4 @@ describe('Lens migrations', () => {
expect(result.attributes.state.filters).toEqual(expectedFilters);
});
});
-
- describe('applying filter migrations', () => {
- it('creates a filter migrations map that works on a lens visualization', () => {
- const filterMigrations = {
- '1.1': (filter: Filter) => ({ ...filter, version: '1.1' }),
- '2.2': (filter: Filter) => ({ ...filter, version: '2.2' }),
- '3.3': (filter: Filter) => ({ ...filter, version: '3.3' }),
- };
-
- const lensVisualization = {
- state: {
- filters: [{}, {}],
- },
- };
-
- const migrationMap = getLensFilterMigrations(filterMigrations);
-
- expect(migrationMap['1.1'](lensVisualization).state.filters).toEqual([
- { version: '1.1' },
- { version: '1.1' },
- ]);
- expect(migrationMap['2.2'](lensVisualization).state.filters).toEqual([
- { version: '2.2' },
- { version: '2.2' },
- ]);
- expect(migrationMap['3.3'](lensVisualization).state.filters).toEqual([
- { version: '3.3' },
- { version: '3.3' },
- ]);
- });
- });
});
From 99e9b7c3b7fd79ef8160cada8157f4c5257f0337 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 13:28:04 -0600
Subject: [PATCH 16/52] changing common imports to relative
---
.../plugins/lens/server/embeddable/lens_embeddable_factory.ts | 2 +-
.../plugins/lens/server/migrations/saved_object_migrations.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
index 403948354111b..6fc1139c7765d 100644
--- a/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
+++ b/x-pack/plugins/lens/server/embeddable/lens_embeddable_factory.ts
@@ -7,7 +7,7 @@
import { EmbeddableRegistryDefinition } from 'src/plugins/embeddable/server';
import type { SerializableRecord } from '@kbn/utility-types';
-import { getAllMigrations } from 'src/plugins/data/common';
+import { getAllMigrations } from '../../../../../src/plugins/data/common';
import { mergeMigrationFunctionMaps } from '../../../../../src/plugins/kibana_utils/common';
import { DOC_TYPE } from '../../common';
import {
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
index 66904d40e6d06..398f6e218ab27 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
@@ -15,11 +15,11 @@ import {
} from 'src/core/server';
import { Filter } from '@kbn/es-query';
import { Query } from 'src/plugins/data/public';
+import { getAllMigrations } from '../../../../../src/plugins/data/common';
import {
mergeMigrationFunctionMaps,
MigrateFunctionsObject,
-} from 'src/plugins/kibana_utils/common';
-import { getAllMigrations } from 'src/plugins/data/common';
+} from '../../../../../src/plugins/kibana_utils/common';
import { PersistableFilter } from '../../common';
import {
LensDocShapePost712,
From c2031a4e8f3b68c5184e58be9899a714487bcb7d Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 13:45:22 -0600
Subject: [PATCH 17/52] remove QuerySetup export
---
src/plugins/data/server/query/index.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/data/server/query/index.ts b/src/plugins/data/server/query/index.ts
index 4cf4b04bef272..1f394e9fc89f9 100644
--- a/src/plugins/data/server/query/index.ts
+++ b/src/plugins/data/server/query/index.ts
@@ -6,5 +6,4 @@
* Side Public License, v 1.
*/
-export type { QuerySetup } from './query_service';
export { QueryService } from './query_service';
From 0b05d81660cc297cc064f043bac09cc240159309 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 14:00:32 -0600
Subject: [PATCH 18/52] remove problem import
---
src/plugins/data/server/plugin.ts | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index dbc4c12964f02..e95394c33a9f0 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -20,7 +20,6 @@ import { UsageCollectionSetup } from '../../usage_collection/server';
import { AutocompleteService } from './autocomplete';
import { FieldFormatsSetup, FieldFormatsStart } from '../../field_formats/server';
import { getUiSettings } from './ui_settings';
-import { QuerySetup } from './query';
export interface DataEnhancements {
search: SearchEnhancements;
@@ -32,7 +31,6 @@ export interface DataPluginSetup {
* @deprecated - use "fieldFormats" plugin directly instead
*/
fieldFormats: FieldFormatsSetup;
- query: QuerySetup;
/**
* @internal
*/
From 954150a52ebf55b3b7c371b8c952612b40c1c626 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Mon, 6 Dec 2021 16:44:12 -0600
Subject: [PATCH 19/52] mergeSavedObjectMigrationMaps
---
.../saved_object_migrations.test.ts | 2 --
.../migrations/saved_object_migrations.ts | 26 ++++++++++++++-----
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
index 21b4a731c12bf..b8b5ee29d2c96 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.test.ts
@@ -15,8 +15,6 @@ import {
import { LensDocShape715, VisState716, VisStatePost715, VisStatePre715 } from './types';
import { CustomPaletteParams, layerTypes } from '../../common';
import { PaletteOutput } from 'src/plugins/charts/common';
-import { Filter } from '@kbn/es-query';
-import { getLensFilterMigrations } from './common_migrations';
describe('Lens migrations', () => {
describe('7.7.0 missing dimensions in XY', () => {
diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
index 398f6e218ab27..63e9448329417 100644
--- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
+++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts
@@ -5,21 +5,18 @@
* 2.0.
*/
-import { cloneDeep } from 'lodash';
+import { cloneDeep, mergeWith } from 'lodash';
import { fromExpression, toExpression, Ast, ExpressionFunctionAST } from '@kbn/interpreter/common';
import {
SavedObjectMigrationMap,
SavedObjectMigrationFn,
SavedObjectReference,
SavedObjectUnsanitizedDoc,
+ SavedObjectMigrationContext,
} from 'src/core/server';
import { Filter } from '@kbn/es-query';
import { Query } from 'src/plugins/data/public';
import { getAllMigrations } from '../../../../../src/plugins/data/common';
-import {
- mergeMigrationFunctionMaps,
- MigrateFunctionsObject,
-} from '../../../../../src/plugins/kibana_utils/common';
import { PersistableFilter } from '../../common';
import {
LensDocShapePost712,
@@ -469,7 +466,22 @@ const lensMigrations: SavedObjectMigrationMap = {
'8.1.0': renameFilterReferences,
};
-export const migrations = mergeMigrationFunctionMaps(
- lensMigrations as MigrateFunctionsObject,
+export const mergeSavedObjectMigrationMaps = (
+ obj1: SavedObjectMigrationMap,
+ obj2: SavedObjectMigrationMap
+): SavedObjectMigrationMap => {
+ const customizer = (objValue: SavedObjectMigrationFn, srcValue: SavedObjectMigrationFn) => {
+ if (!srcValue || !objValue) {
+ return srcValue || objValue;
+ }
+ return (state: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) =>
+ objValue(srcValue(state, context), context);
+ };
+
+ return mergeWith({ ...obj1 }, obj2, customizer);
+};
+
+export const migrations = mergeSavedObjectMigrationMaps(
+ lensMigrations,
getLensFilterMigrations(getAllMigrations())
);
From 38d7de5f7d3df43a78f6695bdaf93b3a043c6e86 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 08:47:03 -0600
Subject: [PATCH 20/52] revert selector changes
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 5 +--
.../lens/public/state_management/selectors.ts | 31 ++++++++-----------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 098e1807732eb..5638a35d1cc6d 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -93,10 +93,7 @@ export function App({
} = useLensSelector((state) => state.lens);
const currentDoc = useLensSelector((state) =>
- selectSavedObjectFormat(state, {
- datasourceMap,
- visualizationMap,
- })
+ selectSavedObjectFormat(state, datasourceMap, visualizationMap)
);
// Used to show a popover that guides the user towards changing the date range when no data is available.
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index d75f84c077d5f..0110d7ef735d3 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -7,8 +7,8 @@
import { createSelector } from '@reduxjs/toolkit';
import { SavedObjectReference } from 'kibana/server';
-import { extract as extractFilterReferences } from '../../../../../src/plugins/data/common';
import { LensState } from './types';
+import { extract as extractFilterReferences } from '../../../../../src/plugins/data/common';
import { Datasource, DatasourceMap, VisualizationMap } from '../types';
import { getDatasourceLayers } from '../editor_frame_service/editor_frame';
@@ -43,10 +43,13 @@ export const selectExecutionContextSearch = createSelector(selectExecutionContex
filters: res.filters,
}));
-const selectInjectedDependencies = (_state: LensState, dependencies: unknown) => dependencies;
+const selectDatasourceMap = (state: LensState, datasourceMap: DatasourceMap) => datasourceMap;
-// use this type to cast selectInjectedDependencies to require whatever outside dependencies the selector needs
-type SelectInjectedDependenciesFunction = (state: LensState, dependencies: T) => T;
+const selectVisualizationMap = (
+ state: LensState,
+ datasourceMap: DatasourceMap,
+ visualizationMap: VisualizationMap
+) => visualizationMap;
export const selectSavedObjectFormat = createSelector(
[
@@ -56,10 +59,8 @@ export const selectSavedObjectFormat = createSelector(
selectQuery,
selectFilters,
selectActiveDatasourceId,
- selectInjectedDependencies as SelectInjectedDependenciesFunction<{
- datasourceMap: DatasourceMap;
- visualizationMap: VisualizationMap;
- }>,
+ selectDatasourceMap,
+ selectVisualizationMap,
],
(
persistedDoc,
@@ -68,7 +69,8 @@ export const selectSavedObjectFormat = createSelector(
query,
filters,
activeDatasourceId,
- { datasourceMap, visualizationMap }
+ datasourceMap,
+ visualizationMap
) => {
const activeVisualization =
visualization.state && visualization.activeId && visualizationMap[visualization.activeId];
@@ -139,19 +141,12 @@ export const selectAreDatasourcesLoaded = createSelector(
);
export const selectDatasourceLayers = createSelector(
- [
- selectDatasourceStates,
- selectInjectedDependencies as SelectInjectedDependenciesFunction,
- ],
+ [selectDatasourceStates, selectDatasourceMap],
(datasourceStates, datasourceMap) => getDatasourceLayers(datasourceStates, datasourceMap)
);
export const selectFramePublicAPI = createSelector(
- [
- selectDatasourceStates,
- selectActiveData,
- selectInjectedDependencies as SelectInjectedDependenciesFunction,
- ],
+ [selectDatasourceStates, selectActiveData, selectDatasourceMap],
(datasourceStates, activeData, datasourceMap) => {
return {
datasourceLayers: getDatasourceLayers(datasourceStates, datasourceMap),
From 0ef428e2ef39ae8bb654c6eba030599bff301c59 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 08:56:20 -0600
Subject: [PATCH 21/52] some more cleanup
---
src/plugins/data/server/plugin.ts | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index e95394c33a9f0..0811bf1fb7ae9 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -13,7 +13,6 @@ import { PluginStart as DataViewsServerPluginStart } from 'src/plugins/data_view
import { ConfigSchema } from '../config';
import { ISearchSetup, ISearchStart, SearchEnhancements } from './search';
import { SearchService } from './search/search_service';
-import { QueryService } from './query/query_service';
import { ScriptsService } from './scripts';
import { KqlTelemetryService } from './kql_telemetry';
import { UsageCollectionSetup } from '../../usage_collection/server';
@@ -72,7 +71,6 @@ export class DataServerPlugin
private readonly scriptsService: ScriptsService;
private readonly kqlTelemetryService: KqlTelemetryService;
private readonly autocompleteService: AutocompleteService;
- private readonly queryService = new QueryService();
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
@@ -88,7 +86,6 @@ export class DataServerPlugin
{ bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies
) {
this.scriptsService.setup(core);
- const queryService = this.queryService.setup(core);
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });
@@ -105,7 +102,6 @@ export class DataServerPlugin
searchSetup.__enhance(enhancements.search);
},
search: searchSetup,
- query: queryService,
fieldFormats,
};
}
From c958f18ffbd421f6f313cd410e9442e7fb3f4e71 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 08:58:15 -0600
Subject: [PATCH 22/52] reverting data server plugin changes
---
src/plugins/data/server/plugin.ts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index 0811bf1fb7ae9..cb52500e78f94 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -13,6 +13,7 @@ import { PluginStart as DataViewsServerPluginStart } from 'src/plugins/data_view
import { ConfigSchema } from '../config';
import { ISearchSetup, ISearchStart, SearchEnhancements } from './search';
import { SearchService } from './search/search_service';
+import { QueryService } from './query/query_service';
import { ScriptsService } from './scripts';
import { KqlTelemetryService } from './kql_telemetry';
import { UsageCollectionSetup } from '../../usage_collection/server';
@@ -71,6 +72,7 @@ export class DataServerPlugin
private readonly scriptsService: ScriptsService;
private readonly kqlTelemetryService: KqlTelemetryService;
private readonly autocompleteService: AutocompleteService;
+ private readonly queryService = new QueryService();
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
@@ -86,6 +88,7 @@ export class DataServerPlugin
{ bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies
) {
this.scriptsService.setup(core);
+ this.queryService.setup(core);
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });
From ab48c85ebc429521055a92967e66f5ca8fccb027 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 10:54:56 -0600
Subject: [PATCH 23/52] fix embeddable test
---
x-pack/plugins/lens/public/embeddable/embeddable.test.tsx | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index ceb9388a561f0..4ae6391011d6c 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -663,9 +663,7 @@ describe('embeddable', () => {
state: {
...savedVis.state,
query: { language: 'kquery', query: 'saved filter' },
- filters: [
- { meta: { alias: 'test', negate: false, disabled: false, indexRefName: 'filter-0' } },
- ],
+ filters: [{ meta: { alias: 'test', negate: false, disabled: false, index: 'filter-0' } }],
},
references: [{ type: 'index-pattern', name: 'filter-0', id: 'my-index-pattern-id' }],
};
From 3a063cefc2bf850962023d3bec4287a7f43f99a7 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 11:17:44 -0600
Subject: [PATCH 24/52] Fix load_initial test
---
x-pack/plugins/lens/public/mocks/services_mock.tsx | 2 +-
.../state_management/__snapshots__/load_initial.test.tsx.snap | 3 +++
.../plugins/lens/public/state_management/load_initial.test.tsx | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/x-pack/plugins/lens/public/mocks/services_mock.tsx b/x-pack/plugins/lens/public/mocks/services_mock.tsx
index 5ec4f8db4a0ed..9fa6d61370a17 100644
--- a/x-pack/plugins/lens/public/mocks/services_mock.tsx
+++ b/x-pack/plugins/lens/public/mocks/services_mock.tsx
@@ -40,7 +40,7 @@ export const defaultDoc = {
visualizationType: 'testVis',
state: {
query: 'kuery',
- filters: [{ query: { match_phrase: { src: 'test' } } }],
+ filters: [{ query: { match_phrase: { src: 'test' } }, meta: { index: 'index-pattern-0' } }],
datasourceStates: {
testDatasource: 'datasource',
},
diff --git a/x-pack/plugins/lens/public/state_management/__snapshots__/load_initial.test.tsx.snap b/x-pack/plugins/lens/public/state_management/__snapshots__/load_initial.test.tsx.snap
index efde7184ac731..7f70508dc423f 100644
--- a/x-pack/plugins/lens/public/state_management/__snapshots__/load_initial.test.tsx.snap
+++ b/x-pack/plugins/lens/public/state_management/__snapshots__/load_initial.test.tsx.snap
@@ -37,6 +37,9 @@ Object {
},
"filters": Array [
Object {
+ "meta": Object {
+ "index": "index-pattern-0",
+ },
"query": Object {
"match_phrase": Object {
"src": "test",
diff --git a/x-pack/plugins/lens/public/state_management/load_initial.test.tsx b/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
index 1143bf8f7561e..bf793f51608ea 100644
--- a/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
+++ b/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
@@ -224,7 +224,7 @@ describe('Initializing the store', () => {
});
expect(deps.lensServices.data.query.filterManager.setAppFilters).toHaveBeenCalledWith([
- { query: { match_phrase: { src: 'test' } } },
+ { query: { match_phrase: { src: 'test' } }, meta: { index: '1' } },
]);
expect(store.getState()).toEqual({
From cc1e3cdc3d8ee3e098af0c4800f9e7eb8e2b1b9e Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Tue, 7 Dec 2021 16:26:18 -0600
Subject: [PATCH 25/52] attempt to fix confirmation test
---
.../lens/public/app_plugin/app.test.tsx | 2 +-
x-pack/plugins/lens/public/app_plugin/app.tsx | 8 +++--
.../app_plugin/save_modal_container.tsx | 35 +++++++++++--------
.../fixtures/kbn_archiver/lens/default.json | 2 +-
4 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
index 7748a5fe37179..ad0a151b2efc8 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
@@ -140,7 +140,7 @@ describe('Lens App', () => {
expression: 'definitely a valid expression',
state: {
query: 'lucene',
- filters: [{ query: { match_phrase: { src: 'test' } } }],
+ filters: [{ query: { match_phrase: { src: 'test' } }, meta: { index: 'index-pattern-0' } }],
},
references: [{ type: 'index-pattern', id: '1', name: 'index-pattern-0' }],
} as unknown as Document;
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 5638a35d1cc6d..723da6a259c5b 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -34,8 +34,9 @@ import {
} from '../state_management';
import {
SaveModalContainer,
- getLastKnownDocWithoutPinnedFilters,
runSaveLensVisualization,
+ injectDocFilterReferences,
+ removePinnedFilters,
} from './save_modal_container';
import { LensInspector } from '../lens_inspector_service';
import { getEditPath } from '../../common';
@@ -148,10 +149,11 @@ export function App({
onAppLeave((actions) => {
// Confirm when the user has made any changes to an existing doc
// or when the user has configured something without saving
-
+ const persistedState = injectDocFilterReferences(persistedDoc)?.state;
+ const lastKnownDocState = removePinnedFilters(injectDocFilterReferences(lastKnownDoc))?.state;
if (
application.capabilities.visualize.save &&
- !isEqual(persistedDoc?.state, getLastKnownDocWithoutPinnedFilters(lastKnownDoc)?.state) &&
+ !isEqual(persistedState, lastKnownDocState) &&
(isSaveable || persistedDoc)
) {
return actions.confirm(
diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
index 23d7f62085fb3..d00a8b8ebae10 100644
--- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
@@ -174,7 +174,7 @@ const getDocToSave = (
references: SavedObjectReference[]
) => {
const docToSave = {
- ...getLastKnownDocWithoutPinnedFilters(lastKnownDoc)!,
+ ...injectDocFilterReferences(removePinnedFilters(lastKnownDoc))!,
references,
};
@@ -353,21 +353,26 @@ export const runSaveLensVisualization = async (
}
};
-export function getLastKnownDocWithoutPinnedFilters(doc?: Document) {
+export function injectDocFilterReferences(doc?: Document) {
if (!doc) return undefined;
- const [pinnedFilters, appFilters] = partition(
- injectFilterReferences(doc.state?.filters || [], doc.references),
- esFilters.isFilterPinned
- );
- return pinnedFilters?.length
- ? {
- ...doc,
- state: {
- ...doc.state,
- filters: appFilters,
- },
- }
- : doc;
+ return {
+ ...doc,
+ state: {
+ ...doc.state,
+ filters: injectFilterReferences(doc.state?.filters || [], doc.references),
+ },
+ };
+}
+
+export function removePinnedFilters(doc?: Document) {
+ if (!doc) return undefined;
+ return {
+ ...doc,
+ state: {
+ ...doc.state,
+ filters: (doc.state?.filters || []).filter((filter) => !esFilters.isFilterPinned(filter)),
+ },
+ };
}
// eslint-disable-next-line import/no-default-export
diff --git a/x-pack/test/functional/fixtures/kbn_archiver/lens/default.json b/x-pack/test/functional/fixtures/kbn_archiver/lens/default.json
index 6f1007703a832..c3de3323d087e 100644
--- a/x-pack/test/functional/fixtures/kbn_archiver/lens/default.json
+++ b/x-pack/test/functional/fixtures/kbn_archiver/lens/default.json
@@ -85,7 +85,7 @@
"meta": {
"alias": null,
"disabled": false,
- "indexRefName": "filter-index-pattern-0",
+ "index": "filter-index-pattern-0",
"key": "response",
"negate": true,
"params": {
From 195fea3d1e131ba3564793d5dd2dfe2344304f76 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 06:45:23 -0600
Subject: [PATCH 26/52] inject filter manager inject function for
save_modal_container
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 15 ++++++++++---
.../app_plugin/save_modal_container.tsx | 22 +++++++++++++------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 723da6a259c5b..dd99bec261a9b 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -149,8 +149,10 @@ export function App({
onAppLeave((actions) => {
// Confirm when the user has made any changes to an existing doc
// or when the user has configured something without saving
- const persistedState = injectDocFilterReferences(persistedDoc)?.state;
- const lastKnownDocState = removePinnedFilters(injectDocFilterReferences(lastKnownDoc))?.state;
+ const persistedState = persistedDoc?.state;
+ const lastKnownDocState = removePinnedFilters(
+ injectDocFilterReferences(data.query.filterManager.inject, lastKnownDoc)
+ )?.state;
if (
application.capabilities.visualize.save &&
!isEqual(persistedState, lastKnownDocState) &&
@@ -168,7 +170,14 @@ export function App({
return actions.default();
}
});
- }, [onAppLeave, lastKnownDoc, isSaveable, persistedDoc, application.capabilities.visualize.save]);
+ }, [
+ onAppLeave,
+ lastKnownDoc,
+ isSaveable,
+ persistedDoc,
+ application.capabilities.visualize.save,
+ data.query.filterManager.inject,
+ ]);
const getLegacyUrlConflictCallout = useCallback(() => {
// This function returns a callout component *if* we have encountered a "legacy URL conflict" scenario
diff --git a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
index d00a8b8ebae10..b685629b9a7d1 100644
--- a/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/save_modal_container.tsx
@@ -8,16 +8,14 @@
import React, { useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';
-import { partition } from 'lodash';
import type { SavedObjectReference } from 'kibana/public';
-import { inject as injectFilterReferences } from '../../../../../src/plugins/data/common';
import { SaveModal } from './save_modal';
import type { LensAppProps, LensAppServices } from './types';
import type { SaveProps } from './app';
import { Document } from '../persistence';
import type { LensByReferenceInput, LensEmbeddableInput } from '../embeddable';
-import { esFilters } from '../../../../../src/plugins/data/public';
+import { esFilters, FilterManager } from '../../../../../src/plugins/data/public';
import { APP_ID, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../common';
import { trackUiEvent } from '../lens_ui_telemetry';
import { checkForDuplicateTitle } from '../../../../../src/plugins/saved_objects/public';
@@ -171,10 +169,11 @@ const redirectToDashboard = ({
const getDocToSave = (
lastKnownDoc: Document,
saveProps: SaveProps,
- references: SavedObjectReference[]
+ references: SavedObjectReference[],
+ injectFilterReferences: FilterManager['inject']
) => {
const docToSave = {
- ...injectDocFilterReferences(removePinnedFilters(lastKnownDoc))!,
+ ...injectDocFilterReferences(injectFilterReferences, removePinnedFilters(lastKnownDoc))!,
references,
};
@@ -202,6 +201,7 @@ export const runSaveLensVisualization = async (
): Promise | undefined> => {
const {
chrome,
+ data,
initialInput,
originatingApp,
lastKnownDoc,
@@ -242,7 +242,12 @@ export const runSaveLensVisualization = async (
);
}
- const docToSave = getDocToSave(lastKnownDoc, saveProps, references);
+ const docToSave = getDocToSave(
+ lastKnownDoc,
+ saveProps,
+ references,
+ data.query.filterManager.inject
+ );
// Required to serialize filters in by value mode until
// https://github.com/elastic/kibana/issues/77588 is fixed
@@ -353,7 +358,10 @@ export const runSaveLensVisualization = async (
}
};
-export function injectDocFilterReferences(doc?: Document) {
+export function injectDocFilterReferences(
+ injectFilterReferences: FilterManager['inject'],
+ doc?: Document
+) {
if (!doc) return undefined;
return {
...doc,
From 6432ec1c51a303192039ff5a74a086a6e6f00db3 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 07:14:33 -0600
Subject: [PATCH 27/52] inject injectFilterReferences into embeddable
---
.../public/embeddable/embeddable.test.tsx | 35 ++++++++++++++++++-
.../lens/public/embeddable/embeddable.tsx | 5 +--
.../public/embeddable/embeddable_factory.ts | 9 ++++-
x-pack/plugins/lens/public/plugin.ts | 1 +
4 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index 4ae6391011d6c..fa2d055c33ff8 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -17,7 +17,7 @@ import {
import { ReactExpressionRendererProps } from 'src/plugins/expressions/public';
import { spacesPluginMock } from '../../../spaces/public/mocks';
import { Filter } from '@kbn/es-query';
-import { Query, TimeRange, IndexPatternsContract } from 'src/plugins/data/public';
+import { Query, TimeRange, IndexPatternsContract, FilterManager } from 'src/plugins/data/public';
import { Document } from '../persistence';
import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks';
import { VIS_EVENT_TO_TRIGGER } from '../../../../../src/plugins/visualizations/public/embeddable';
@@ -72,6 +72,19 @@ const options = {
checkForDuplicateTitle: defaultCheckForDuplicateTitle,
};
+const mockInjectFilterReferences: FilterManager['inject'] = (filters, references) => {
+ return filters.map((filter) => {
+ const reference = references.find((ref) => ref.name === filter.meta.index);
+ return {
+ ...filter,
+ meta: {
+ ...filter.meta,
+ index: reference?.id,
+ },
+ };
+ });
+};
+
const attributeServiceMockFromSavedVis = (document: Document): LensAttributeService => {
const core = coreMock.createStart();
const service = new AttributeService<
@@ -139,6 +152,7 @@ describe('embeddable', () => {
getTrigger,
theme: themeServiceMock.createStartContract(),
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
documentToExpression: () =>
Promise.resolve({
ast: {
@@ -180,6 +194,7 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -226,6 +241,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -283,6 +299,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -329,6 +346,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -370,6 +388,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -414,6 +433,7 @@ describe('embeddable', () => {
capabilities: { canSaveDashboards: true, canSaveVisualizations: true },
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -465,6 +485,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -514,6 +535,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -570,6 +592,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -627,6 +650,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -685,6 +709,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -729,6 +754,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -773,6 +799,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -817,6 +844,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -876,6 +904,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -951,6 +980,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1001,6 +1031,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1051,6 +1082,7 @@ describe('embeddable', () => {
},
getTrigger,
visualizationMap: {},
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
theme: themeServiceMock.createStartContract(),
documentToExpression: () =>
Promise.resolve({
@@ -1122,6 +1154,7 @@ describe('embeddable', () => {
},
getTrigger,
theme: themeServiceMock.createStartContract(),
+ injectFilterReferences: jest.fn(mockInjectFilterReferences),
visualizationMap: {
[visDocument.visualizationType as string]: {
onEditAction: onEditActionMock,
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
index d1d47ec291241..91b2ce52b8dfc 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx
@@ -16,6 +16,7 @@ import type {
TimefilterContract,
TimeRange,
IndexPattern,
+ FilterManager,
} from 'src/plugins/data/public';
import type { PaletteOutput } from 'src/plugins/charts/public';
import type { Start as InspectorStart } from 'src/plugins/inspector/public';
@@ -27,7 +28,6 @@ import { map, distinctUntilChanged, skip } from 'rxjs/operators';
import fastIsEqual from 'fast-deep-equal';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { METRIC_TYPE } from '@kbn/analytics';
-import { inject as injectFilterReferences } from '../../../../../src/plugins/data/common';
import { KibanaThemeProvider } from '../../../../../src/plugins/kibana_react/public';
import {
ExpressionRendererEvent,
@@ -108,6 +108,7 @@ export interface LensEmbeddableDeps {
documentToExpression: (
doc: Document
) => Promise<{ ast: Ast | null; errors: ErrorMessage[] | undefined }>;
+ injectFilterReferences: FilterManager['inject'];
visualizationMap: VisualizationMap;
indexPatternService: IndexPatternsContract;
expressionRenderer: ReactExpressionRendererType;
@@ -478,7 +479,7 @@ export class Embeddable
output.filters = [...this.savedVis.state.filters];
}
- output.filters = injectFilterReferences(output.filters, this.savedVis.references);
+ output.filters = this.deps.injectFilterReferences(output.filters, this.savedVis.references);
return output;
}
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
index 63b07affcb9ed..b3a11c14e79e6 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
+++ b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts
@@ -10,7 +10,11 @@ import { i18n } from '@kbn/i18n';
import { RecursiveReadonly } from '@kbn/utility-types';
import { Ast } from '@kbn/interpreter/common';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
-import { IndexPatternsContract, TimefilterContract } from '../../../../../src/plugins/data/public';
+import {
+ FilterManager,
+ IndexPatternsContract,
+ TimefilterContract,
+} from '../../../../../src/plugins/data/public';
import { ReactExpressionRendererType } from '../../../../../src/plugins/expressions/public';
import {
EmbeddableFactoryDefinition,
@@ -40,6 +44,7 @@ export interface LensEmbeddableStartServices {
documentToExpression: (
doc: Document
) => Promise<{ ast: Ast | null; errors: ErrorMessage[] | undefined }>;
+ injectFilterReferences: FilterManager['inject'];
visualizationMap: VisualizationMap;
spaces?: SpacesPluginStart;
theme: ThemeServiceStart;
@@ -88,6 +93,7 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
timefilter,
expressionRenderer,
documentToExpression,
+ injectFilterReferences,
visualizationMap,
uiActions,
coreHttp,
@@ -113,6 +119,7 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
getTrigger: uiActions?.getTrigger,
getTriggerCompatibleActions: uiActions?.getTriggerCompatibleActions,
documentToExpression,
+ injectFilterReferences,
visualizationMap,
capabilities: {
canSaveDashboards: Boolean(capabilities.dashboard?.showWriteControls),
diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts
index b89492d7e7588..4c77231e091a3 100644
--- a/x-pack/plugins/lens/public/plugin.ts
+++ b/x-pack/plugins/lens/public/plugin.ts
@@ -210,6 +210,7 @@ export class LensPlugin {
timefilter: plugins.data.query.timefilter.timefilter,
expressionRenderer: plugins.expressions.ReactExpressionRenderer,
documentToExpression: this.editorFrameService!.documentToExpression,
+ injectFilterReferences: data.query.filterManager.inject,
visualizationMap,
indexPatternService: plugins.data.indexPatterns,
uiActions: plugins.uiActions,
From 26387a98429c1dc2073b762d19e3322f79d1f44f Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 07:29:17 -0600
Subject: [PATCH 28/52] use inject from data plugin for load_initial
---
.../lens/public/embeddable/embeddable.test.tsx | 17 +++++++----------
.../lens/public/mocks/data_plugin_mock.ts | 8 +++++++-
.../init_middleware/load_initial.ts | 3 +--
.../state_management/load_initial.test.tsx | 2 +-
4 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index fa2d055c33ff8..387ba484cbe1d 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -73,16 +73,13 @@ const options = {
};
const mockInjectFilterReferences: FilterManager['inject'] = (filters, references) => {
- return filters.map((filter) => {
- const reference = references.find((ref) => ref.name === filter.meta.index);
- return {
- ...filter,
- meta: {
- ...filter.meta,
- index: reference?.id,
- },
- };
- });
+ return filters.map((filter) => ({
+ ...filter,
+ meta: {
+ ...filter.meta,
+ index: 'injected!',
+ },
+ }));
};
const attributeServiceMockFromSavedVis = (document: Document): LensAttributeService => {
diff --git a/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts b/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
index daab2566b28fe..440c9aab18f48 100644
--- a/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
+++ b/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
@@ -7,7 +7,7 @@
import { Observable, Subject } from 'rxjs';
import moment from 'moment';
-import { DataPublicPluginStart, esFilters } from '../../../../../src/plugins/data/public';
+import { DataPublicPluginStart, esFilters, Filter } from '../../../../../src/plugins/data/public';
function createMockTimefilter() {
const unsubscribe = jest.fn();
@@ -90,6 +90,12 @@ export function mockDataPlugin(
filters = [];
subscriber();
},
+ inject: (filtersIn: Filter[]) => {
+ return filtersIn.map((filter) => ({
+ ...filter,
+ meta: { ...filter.meta, index: 'injected!' },
+ }));
+ },
};
}
function createMockQueryString() {
diff --git a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
index c3309b5d4f1a9..2f48a331f58fa 100644
--- a/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
+++ b/x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts
@@ -16,7 +16,6 @@ import { getInitialDatasourceId } from '../../utils';
import { initializeDatasources } from '../../editor_frame_service/editor_frame';
import { LensAppServices } from '../../app_plugin/types';
import { getEditPath, getFullPath, LENS_EMBEDDABLE_TYPE } from '../../../common/constants';
-import { inject as injectFilterReferences } from '../../../../../../src/plugins/data/common';
import { Document } from '../../persistence';
export const getPersisted = async ({
@@ -165,7 +164,7 @@ export function loadInitial(
{}
);
- const filters = injectFilterReferences(doc.state.filters, doc.references);
+ const filters = data.query.filterManager.inject(doc.state.filters, doc.references);
// Don't overwrite any pinned filters
data.query.filterManager.setAppFilters(filters);
diff --git a/x-pack/plugins/lens/public/state_management/load_initial.test.tsx b/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
index bf793f51608ea..1015838e11674 100644
--- a/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
+++ b/x-pack/plugins/lens/public/state_management/load_initial.test.tsx
@@ -224,7 +224,7 @@ describe('Initializing the store', () => {
});
expect(deps.lensServices.data.query.filterManager.setAppFilters).toHaveBeenCalledWith([
- { query: { match_phrase: { src: 'test' } }, meta: { index: '1' } },
+ { query: { match_phrase: { src: 'test' } }, meta: { index: 'injected!' } },
]);
expect(store.getState()).toEqual({
From 6b526082ea087518c7d8bd3972b727e839596d1b Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 08:25:04 -0600
Subject: [PATCH 29/52] inject extractFilterReferences into selector
---
x-pack/plugins/lens/public/app_plugin/app.tsx | 13 ++++++--
.../lens/public/state_management/selectors.ts | 32 +++++++++++--------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index dd99bec261a9b..15352eff7e021 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -8,7 +8,7 @@
import './app.scss';
import { isEqual } from 'lodash';
-import React, { useState, useEffect, useCallback } from 'react';
+import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiBreadcrumb } from '@elastic/eui';
import {
@@ -93,8 +93,17 @@ export function App({
isSaveable,
} = useLensSelector((state) => state.lens);
+ const selectorDependencies = useMemo(
+ () => ({
+ datasourceMap,
+ visualizationMap,
+ extractFilterReferences: data.query.filterManager.extract,
+ }),
+ [datasourceMap, visualizationMap, data.query.filterManager.extract]
+ );
+
const currentDoc = useLensSelector((state) =>
- selectSavedObjectFormat(state, datasourceMap, visualizationMap)
+ selectSavedObjectFormat(state, selectorDependencies)
);
// Used to show a popover that guides the user towards changing the date range when no data is available.
diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts
index 0110d7ef735d3..250e9dde31373 100644
--- a/x-pack/plugins/lens/public/state_management/selectors.ts
+++ b/x-pack/plugins/lens/public/state_management/selectors.ts
@@ -7,8 +7,8 @@
import { createSelector } from '@reduxjs/toolkit';
import { SavedObjectReference } from 'kibana/server';
+import { FilterManager } from 'src/plugins/data/public';
import { LensState } from './types';
-import { extract as extractFilterReferences } from '../../../../../src/plugins/data/common';
import { Datasource, DatasourceMap, VisualizationMap } from '../types';
import { getDatasourceLayers } from '../editor_frame_service/editor_frame';
@@ -43,13 +43,10 @@ export const selectExecutionContextSearch = createSelector(selectExecutionContex
filters: res.filters,
}));
-const selectDatasourceMap = (state: LensState, datasourceMap: DatasourceMap) => datasourceMap;
+const selectInjectedDependencies = (_state: LensState, dependencies: unknown) => dependencies;
-const selectVisualizationMap = (
- state: LensState,
- datasourceMap: DatasourceMap,
- visualizationMap: VisualizationMap
-) => visualizationMap;
+// use this type to cast selectInjectedDependencies to require whatever outside dependencies the selector needs
+type SelectInjectedDependenciesFunction = (state: LensState, dependencies: T) => T;
export const selectSavedObjectFormat = createSelector(
[
@@ -59,8 +56,11 @@ export const selectSavedObjectFormat = createSelector(
selectQuery,
selectFilters,
selectActiveDatasourceId,
- selectDatasourceMap,
- selectVisualizationMap,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction<{
+ datasourceMap: DatasourceMap;
+ visualizationMap: VisualizationMap;
+ extractFilterReferences: FilterManager['extract'];
+ }>,
],
(
persistedDoc,
@@ -69,8 +69,7 @@ export const selectSavedObjectFormat = createSelector(
query,
filters,
activeDatasourceId,
- datasourceMap,
- visualizationMap
+ { datasourceMap, visualizationMap, extractFilterReferences }
) => {
const activeVisualization =
visualization.state && visualization.activeId && visualizationMap[visualization.activeId];
@@ -141,12 +140,19 @@ export const selectAreDatasourcesLoaded = createSelector(
);
export const selectDatasourceLayers = createSelector(
- [selectDatasourceStates, selectDatasourceMap],
+ [
+ selectDatasourceStates,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction,
+ ],
(datasourceStates, datasourceMap) => getDatasourceLayers(datasourceStates, datasourceMap)
);
export const selectFramePublicAPI = createSelector(
- [selectDatasourceStates, selectActiveData, selectDatasourceMap],
+ [
+ selectDatasourceStates,
+ selectActiveData,
+ selectInjectedDependencies as SelectInjectedDependenciesFunction,
+ ],
(datasourceStates, activeData, datasourceMap) => {
return {
datasourceLayers: getDatasourceLayers(datasourceStates, datasourceMap),
From 49be9a0e9a28d876b2a10ac1c975dc8b9ab024e8 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 08:52:40 -0600
Subject: [PATCH 30/52] update embeddable test
---
.../lens/public/embeddable/embeddable.test.tsx | 15 +++++++++------
.../plugins/lens/public/mocks/data_plugin_mock.ts | 7 +++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
index 387ba484cbe1d..17e18392e83e9 100644
--- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
+++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx
@@ -612,7 +612,7 @@ describe('embeddable', () => {
expect.objectContaining({
timeRange,
query: [query, savedVis.state.query],
- filters,
+ filters: mockInjectFilterReferences(filters, []),
})
);
@@ -728,11 +728,14 @@ describe('embeddable', () => {
expect(expressionRenderer.mock.calls[0][0].searchContext).toEqual({
timeRange,
query: [query, { language: 'kquery', query: 'saved filter' }],
- filters: [
- filters[0],
- // actual index pattern id gets injected
- { meta: { alias: 'test', negate: false, disabled: false, index: 'my-index-pattern-id' } },
- ],
+ // actual index pattern id gets injected
+ filters: mockInjectFilterReferences(
+ [
+ filters[0],
+ { meta: { alias: 'test', negate: false, disabled: false, index: 'injected!' } },
+ ],
+ []
+ ),
});
});
diff --git a/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts b/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
index 440c9aab18f48..865e21f5bb613 100644
--- a/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
+++ b/x-pack/plugins/lens/public/mocks/data_plugin_mock.ts
@@ -96,6 +96,13 @@ export function mockDataPlugin(
meta: { ...filter.meta, index: 'injected!' },
}));
},
+ extract: (filtersIn: Filter[]) => {
+ const state = filtersIn.map((filter) => ({
+ ...filter,
+ meta: { ...filter.meta, index: 'extracted!' },
+ }));
+ return { state, references: [] };
+ },
};
}
function createMockQueryString() {
From 0763942f2de350e78390042f548a21a836cb179a Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 11:38:01 -0600
Subject: [PATCH 31/52] fix saves app filters test
---
src/plugins/data/server/plugin.ts | 2 ++
src/plugins/data/server/query/index.ts | 2 +-
src/plugins/data/server/query/query_service.ts | 3 +++
x-pack/plugins/lens/public/app_plugin/app.test.tsx | 2 +-
4 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index cb52500e78f94..fef82c710bca1 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -20,6 +20,7 @@ import { UsageCollectionSetup } from '../../usage_collection/server';
import { AutocompleteService } from './autocomplete';
import { FieldFormatsSetup, FieldFormatsStart } from '../../field_formats/server';
import { getUiSettings } from './ui_settings';
+import { QuerySetup } from './query';
export interface DataEnhancements {
search: SearchEnhancements;
@@ -27,6 +28,7 @@ export interface DataEnhancements {
export interface DataPluginSetup {
search: ISearchSetup;
+ query: QuerySetup;
/**
* @deprecated - use "fieldFormats" plugin directly instead
*/
diff --git a/src/plugins/data/server/query/index.ts b/src/plugins/data/server/query/index.ts
index 1f394e9fc89f9..7a1d2326fdc7e 100644
--- a/src/plugins/data/server/query/index.ts
+++ b/src/plugins/data/server/query/index.ts
@@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
-export { QueryService } from './query_service';
+export { QueryService, QuerySetup } from './query_service';
diff --git a/src/plugins/data/server/query/query_service.ts b/src/plugins/data/server/query/query_service.ts
index 173abeda0c951..33aeecbc11df1 100644
--- a/src/plugins/data/server/query/query_service.ts
+++ b/src/plugins/data/server/query/query_service.ts
@@ -36,3 +36,6 @@ export class QueryService implements Plugin {
public start() {}
}
+
+/** @public */
+export type QuerySetup = ReturnType;
diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
index ad0a151b2efc8..30378ec712179 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
@@ -695,7 +695,7 @@ describe('Lens App', () => {
savedObjectId: defaultSavedObjectId,
title: 'hello there2',
state: expect.objectContaining({
- filters: [unpinned],
+ filters: services.data.query.filterManager.inject([unpinned], []),
}),
}),
true,
From b9785fed7d2d69a7f561c519f7b9ccd862506eb9 Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 12:59:09 -0600
Subject: [PATCH 32/52] skip failing unit test
---
x-pack/plugins/lens/public/app_plugin/app.test.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
index 30378ec712179..367e7adf42fd1 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx
@@ -1261,7 +1261,8 @@ describe('Lens App', () => {
expect(defaultLeave).not.toHaveBeenCalled();
});
- it('should not confirm when changes are saved', async () => {
+ // TODO - re-enable when we add the isDirty flag
+ it.skip('should not confirm when changes are saved', async () => {
const { props } = await mountWith({
preloadedState: {
persistedDoc: {
From a22a1d8af81b48b5df18991d1b1a70229caf0dbb Mon Sep 17 00:00:00 2001
From: Andrew Tate
Date: Wed, 8 Dec 2021 13:35:27 -0600
Subject: [PATCH 33/52] merge main
---
.github/CODEOWNERS | 2 +
NOTICE.txt | 2 +-
.../getting-started/debugging.asciidoc | 68 -
docs/developer/plugin-list.asciidoc | 5 +
...-plugin-core-public.doclinksstart.links.md | 10 +-
...kibana-plugin-core-public.doclinksstart.md | 2 +-
docs/osquery/osquery.asciidoc | 22 +-
docs/settings/apm-settings.asciidoc | 6 +-
docs/settings/fleet-settings.asciidoc | 2 +
docs/settings/monitoring-settings.asciidoc | 3 +
docs/settings/spaces-settings.asciidoc | 8 -
docs/settings/url-drilldown-settings.asciidoc | 14 +-
docs/setup/docker.asciidoc | 2 +-
docs/setup/install/deb.asciidoc | 6 +-
docs/setup/install/rpm.asciidoc | 7 +-
docs/setup/install/targz.asciidoc | 3 +-
docs/setup/upgrade.asciidoc | 13 +-
.../setup/upgrade/upgrade-migrations.asciidoc | 7 +-
docs/user/index.asciidoc | 2 +
docs/user/troubleshooting.asciidoc | 70 +
package.json | 8 +-
packages/BUILD.bazel | 3 +
.../elastic-eslint-config-kibana/react.js | 2 +-
.../typescript.js | 2 +-
.../src/init_apm.test.ts | 19 +-
packages/kbn-cli-dev-mode/BUILD.bazel | 4 +-
.../kbn-cli-dev-mode/src/cli_dev_mode.test.ts | 8 +-
packages/kbn-cli-dev-mode/src/cli_dev_mode.ts | 3 +-
.../src/get_server_watch_paths.test.ts | 5 +-
.../src/get_server_watch_paths.ts | 4 +-
packages/kbn-crypto/BUILD.bazel | 2 +-
packages/kbn-dev-utils/BUILD.bazel | 28 +-
packages/kbn-dev-utils/package.json | 1 -
packages/kbn-dev-utils/src/index.ts | 1 -
.../tooling_log_text_writer.test.ts.snap | 8 +
.../tooling_log_text_writer.test.ts | 52 +
.../tooling_log/tooling_log_text_writer.ts | 10 +-
packages/kbn-docs-utils/BUILD.bazel | 28 +-
packages/kbn-docs-utils/package.json | 1 -
.../src/api_docs/build_api_docs_cli.ts | 5 +-
.../src/api_docs/find_plugins.ts | 3 +-
packages/kbn-es-archiver/BUILD.bazel | 28 +-
packages/kbn-es-archiver/package.json | 1 -
packages/kbn-es-archiver/src/actions/load.ts | 3 +-
.../src/actions/rebuild_all.ts | 4 +-
packages/kbn-es-archiver/src/actions/save.ts | 4 +-
.../kbn-es-archiver/src/actions/unload.ts | 4 +-
packages/kbn-es-archiver/src/es_archiver.ts | 3 +-
.../docs/generate_doc_records_stream.test.ts | 5 +-
.../lib/docs/index_doc_records_stream.test.ts | 9 +-
packages/kbn-es/BUILD.bazel | 4 +-
packages/kbn-es/src/artifact.test.js | 12 +-
.../kbn-es/src/{artifact.js => artifact.ts} | 200 +-
...ustom_snapshots.js => custom_snapshots.ts} | 17 +-
packages/kbn-es/src/errors.ts | 25 +
packages/kbn-es/src/{index.js => index.ts} | 6 +-
packages/kbn-es/src/install/index.js | 12 -
.../kbn-es/src/install/index.ts | 6 +-
.../{archive.js => install_archive.ts} | 72 +-
.../{snapshot.js => install_snapshot.ts} | 60 +-
.../install/{source.js => install_source.ts} | 54 +-
packages/kbn-es/src/paths.js | 24 -
packages/kbn-es/src/paths.ts | 24 +
.../{build_snapshot.js => build_snapshot.ts} | 74 +-
packages/kbn-es/src/utils/cache.js | 41 -
packages/kbn-es/src/utils/cache.ts | 40 +
....js => find_most_recently_changed.test.ts} | 4 +-
...anged.js => find_most_recently_changed.ts} | 15 +-
packages/kbn-es/src/utils/index.js | 16 -
packages/kbn-es/src/utils/index.ts | 19 +
packages/kbn-es/src/utils/{log.js => log.ts} | 6 +-
.../BUILD.bazel | 3 +-
.../helpers/exports.js | 2 +-
packages/kbn-optimizer/BUILD.bazel | 6 +-
packages/kbn-optimizer/limits.yml | 1 +
..._babel_runtime_helpers_in_entry_bundles.ts | 3 +-
.../src/node/node_auto_tranpilation.ts | 2 +-
.../src/optimizer/get_changes.test.ts | 3 +-
.../src/optimizer/get_changes.ts | 2 +-
packages/kbn-plugin-generator/BUILD.bazel | 2 +-
packages/kbn-plugin-helpers/BUILD.bazel | 2 +-
packages/kbn-pm/dist/index.js | 10 +-
.../src/technical_field_names.ts | 3 +
packages/kbn-storybook/BUILD.bazel | 4 +-
packages/kbn-storybook/src/lib/constants.ts | 2 +-
.../kbn-storybook/src/lib/theme_switcher.tsx | 72 +-
packages/kbn-telemetry-tools/BUILD.bazel | 3 +-
packages/kbn-test/BUILD.bazel | 12 +-
packages/kbn-test/jest-preset.js | 1 +
packages/kbn-test/src/es/es_test_config.ts | 2 +-
.../buildkite_metadata.ts | 38 +
.../src/failed_tests_reporter/github_api.ts | 82 +-
.../report_failures_to_file.ts | 34 +-
.../run_failed_tests_reporter_cli.ts | 190 +-
.../lib/mocha/validate_ci_group_tags.js | 2 +-
.../lib/suite_tracker.test.ts | 2 +-
.../lib/babel_register_for_test_plugins.js | 2 +-
.../kbn-test/src/functional_tests/tasks.ts | 3 +-
.../kbn-test/src/jest/mocks/apm_agent_mock.ts | 63 +
packages/kbn-test/src/kbn/users.ts | 2 +-
.../kbn_client/kbn_client_import_export.ts | 3 +-
.../kbn-typed-react-router-config/BUILD.bazel | 2 +-
.../src/create_router.test.tsx | 2 -
.../src/create_router.ts | 14 +-
.../src/types/index.ts | 20 +-
.../integration_tests/invalid_config.test.ts | 2 +-
.../public/doc_links/doc_links_service.ts | 12 +-
src/core/public/public.api.md | 10 +-
.../capabilities_service.test.ts | 2 +-
src/core/server/core_context.mock.ts | 2 +-
.../client/configure_client.test.ts | 411 +-
.../elasticsearch/client/configure_client.ts | 95 +-
src/core/server/elasticsearch/client/index.ts | 3 +-
.../client/log_query_and_deprecation.test.ts | 624 +
.../client/log_query_and_deprecation.ts | 143 +
.../elasticsearch_service.test.ts | 2 +-
.../http/cookie_session_storage.test.ts | 2 +-
src/core/server/http/http_service.test.ts | 2 +-
src/core/server/http/test_utils.ts | 2 +-
.../logging/get_ops_metrics_log.test.ts | 62 +-
.../metrics/logging/get_ops_metrics_log.ts | 32 +-
.../server/metrics/metrics_service.test.ts | 1 +
.../discovery/plugins_discovery.test.ts | 2 +-
.../integration_tests/plugins_service.test.ts | 2 +-
src/core/server/plugins/plugin.test.ts | 2 +-
.../server/plugins/plugin_context.test.ts | 2 +-
.../server/plugins/plugins_config.test.ts | 2 +-
.../server/plugins/plugins_service.test.ts | 3 +-
.../server/plugins/plugins_system.test.ts | 2 +-
.../server/preboot/preboot_service.test.ts | 2 +-
src/core/server/root/index.test.ts | 2 +-
.../7.7.2_xpack_100k.test.ts | 2 +-
.../migration_from_older_v1.test.ts | 2 +-
.../migration_from_same_v1.test.ts | 2 +-
.../saved_objects_service.test.ts | 2 +-
.../service/lib/repository.test.ts | 14 +
.../saved_objects/service/lib/repository.ts | 4 +-
src/core/server/server.test.ts | 2 +-
.../integration_tests/index.test.ts | 2 +-
src/core/test_helpers/kbn_server.ts | 3 +-
.../integration_tests/version_info.test.ts | 2 +-
src/dev/build/tasks/install_chromium.js | 22 +-
.../docker_generator/bundle_dockerfiles.ts | 3 +-
.../tasks/os_packages/docker_generator/run.ts | 3 +-
.../templates/ironbank/Dockerfile | 4 +-
.../ironbank/hardening_manifest.yaml | 4 +-
src/dev/chromium_version.ts | 3 +-
.../__tests__/enumerate_patterns.test.js | 18 +-
.../ingest_coverage/team_assignment/index.js | 3 +-
src/dev/ensure_all_tests_in_ci_group.ts | 3 +-
src/dev/eslint/run_eslint_with_types.ts | 3 +-
src/dev/plugin_discovery/find_plugins.ts | 8 +-
src/dev/run_build_docs_cli.ts | 3 +-
.../run_find_plugins_with_circular_deps.ts | 3 +-
src/dev/run_precommit_hook.js | 3 +-
src/dev/typescript/build_ts_refs.ts | 3 +-
src/dev/typescript/build_ts_refs_cli.ts | 3 +-
.../ref_output_cache/ref_output_cache.ts | 3 +-
src/dev/typescript/root_refs_config.ts | 3 +-
.../public/expression_renderers/index.scss | 8 -
.../static/components/empty_placeholder.scss | 7 +
.../static/components/empty_placeholder.tsx | 17 +-
.../contexts/services_context.mock.ts | 3 +-
.../application/contexts/services_context.tsx | 5 +-
.../use_send_current_request_to_es.ts | 16 +-
.../console/public/application/index.tsx | 58 +-
.../legacy_core_editor/mode/worker/worker.js | 39 +-
.../console/public/lib/mappings/mappings.js | 5 +-
src/plugins/console/public/plugin.ts | 3 +-
src/plugins/console/public/shared_imports.ts | 2 +
.../actions/add_to_library_action.test.tsx | 1 +
.../actions/clone_panel_action.test.tsx | 1 +
.../actions/copy_to_dashboard_action.tsx | 6 +-
.../actions/expand_panel_action.test.tsx | 1 +
.../actions/export_csv_action.test.tsx | 1 +
.../library_notification_action.test.tsx | 9 +-
.../actions/library_notification_action.tsx | 21 +-
.../library_notification_popover.test.tsx | 1 +
.../actions/open_replace_panel_flyout.tsx | 3 +-
.../actions/replace_panel_action.test.tsx | 1 +
.../unlink_from_library_action.test.tsx | 1 +
.../public/application/dashboard_router.tsx | 44 +-
.../embeddable/dashboard_container.test.tsx | 1 +
.../embeddable/dashboard_container.tsx | 10 +-
.../embeddable/grid/dashboard_grid.test.tsx | 1 +
.../placeholder/placeholder_embeddable.tsx | 20 +-
.../placeholder_embeddable_factory.ts | 11 +-
.../viewport/dashboard_viewport.test.tsx | 1 +
.../public/application/lib/filter_utils.ts | 2 +-
.../lib/load_saved_dashboard_state.ts | 43 +-
.../application/listing/confirm_overlays.tsx | 6 +-
.../application/listing/dashboard_listing.tsx | 3 +-
.../listing/dashboard_no_match.tsx | 3 +-
.../application/top_nav/dashboard_top_nav.tsx | 10 +-
.../application/top_nav/show_clone_modal.tsx | 31 +-
.../top_nav/show_options_popover.tsx | 52 +-
.../dashboard/public/dashboard_strings.ts | 8 +
src/plugins/dashboard/public/plugin.tsx | 24 +-
.../dashboard/public/services/kibana_react.ts | 1 +
.../data/common/search/aggs/agg_types.ts | 4 +
.../common/search/aggs/aggs_service.test.ts | 4 +
.../search/aggs/buckets/bucket_agg_types.ts | 2 +
.../aggs/buckets/diversified_sampler.ts | 62 +
.../buckets/diversified_sampler_fn.test.ts | 58 +
.../aggs/buckets/diversified_sampler_fn.ts | 90 +
.../data/common/search/aggs/buckets/index.ts | 4 +
.../common/search/aggs/buckets/multi_terms.ts | 7 +
.../search/aggs/buckets/multi_terms_fn.ts | 6 +
.../common/search/aggs/buckets/sampler.ts | 43 +
.../search/aggs/buckets/sampler_fn.test.ts | 52 +
.../common/search/aggs/buckets/sampler_fn.ts | 77 +
src/plugins/data/common/search/aggs/types.ts | 4 +
.../aggs/utils/get_aggs_formats.test.ts | 32 +
.../search/aggs/utils/get_aggs_formats.ts | 4 +-
.../public/search/aggs/aggs_service.test.ts | 4 +-
src/plugins/data/server/plugin.ts | 3 +-
.../field_editor/form_fields/script_field.tsx | 1 +
.../fetcher/index_patterns_fetcher.test.ts | 6 +
.../server/fetcher/index_patterns_fetcher.ts | 4 +
src/plugins/dev_tools/kibana.json | 3 +-
src/plugins/dev_tools/public/application.tsx | 55 +-
.../discover/public/__mocks__/services.ts | 1 +
.../application/context/context_app_route.tsx | 6 +-
.../application/doc/single_doc_route.tsx | 6 +-
.../discover_grid/discover_grid_flyout.tsx | 22 +-
.../doc_table/components/table_row.tsx | 26 +-
.../components/table_row_details.tsx | 13 +-
.../discover/public/utils/breadcrumbs.ts | 4 +-
.../public/utils/get_context_url.test.ts | 43 -
.../discover/public/utils/get_context_url.tsx | 46 -
.../utils/use_navigation_props.test.tsx | 101 +
.../public/utils/use_navigation_props.tsx | 132 +
src/plugins/home/server/plugin.ts | 3 +-
.../tutorials/lib/tutorials_registry_types.ts | 1 +
.../tutorials/tutorials_registry.test.ts | 29 +-
.../services/tutorials/tutorials_registry.ts | 15 +-
.../server/tutorials/activemq_logs/index.ts | 4 +-
.../tutorials/activemq_metrics/index.ts | 4 +-
.../tutorials/aerospike_metrics/index.ts | 4 +-
.../server/tutorials/apache_logs/index.ts | 4 +-
.../server/tutorials/apache_metrics/index.ts | 4 +-
.../home/server/tutorials/auditbeat/index.ts | 4 +-
.../server/tutorials/auditd_logs/index.ts | 4 +-
.../home/server/tutorials/aws_logs/index.ts | 4 +-
.../server/tutorials/aws_metrics/index.ts | 4 +-
.../home/server/tutorials/azure_logs/index.ts | 4 +-
.../server/tutorials/azure_metrics/index.ts | 4 +-
.../server/tutorials/barracuda_logs/index.ts | 4 +-
.../server/tutorials/bluecoat_logs/index.ts | 4 +-
.../home/server/tutorials/cef_logs/index.ts | 4 +-
.../server/tutorials/ceph_metrics/index.ts | 4 +-
.../server/tutorials/checkpoint_logs/index.ts | 4 +-
.../home/server/tutorials/cisco_logs/index.ts | 4 +-
.../server/tutorials/cloudwatch_logs/index.ts | 4 +-
.../tutorials/cockroachdb_metrics/index.ts | 4 +-
.../server/tutorials/consul_metrics/index.ts | 4 +-
.../server/tutorials/coredns_logs/index.ts | 4 +-
.../server/tutorials/coredns_metrics/index.ts | 4 +-
.../tutorials/couchbase_metrics/index.ts | 4 +-
.../server/tutorials/couchdb_metrics/index.ts | 4 +-
.../tutorials/crowdstrike_logs/index.ts | 4 +-
.../server/tutorials/cylance_logs/index.ts | 4 +-
.../server/tutorials/docker_metrics/index.ts | 4 +-
.../tutorials/dropwizard_metrics/index.ts | 4 +-
.../tutorials/elasticsearch_logs/index.ts | 4 +-
.../tutorials/elasticsearch_metrics/index.ts | 4 +-
.../server/tutorials/envoyproxy_logs/index.ts | 4 +-
.../tutorials/envoyproxy_metrics/index.ts | 4 +-
.../server/tutorials/etcd_metrics/index.ts | 4 +-
.../home/server/tutorials/f5_logs/index.ts | 4 +-
.../server/tutorials/fortinet_logs/index.ts | 4 +-
.../home/server/tutorials/gcp_logs/index.ts | 4 +-
.../server/tutorials/gcp_metrics/index.ts | 4 +-
.../server/tutorials/golang_metrics/index.ts | 4 +-
.../server/tutorials/gsuite_logs/index.ts | 4 +-
.../server/tutorials/haproxy_logs/index.ts | 4 +-
.../server/tutorials/haproxy_metrics/index.ts | 4 +-
.../home/server/tutorials/ibmmq_logs/index.ts | 4 +-
.../server/tutorials/ibmmq_metrics/index.ts | 4 +-
.../server/tutorials/icinga_logs/index.ts | 4 +-
.../home/server/tutorials/iis_logs/index.ts | 4 +-
.../server/tutorials/iis_metrics/index.ts | 4 +-
.../server/tutorials/imperva_logs/index.ts | 4 +-
.../server/tutorials/infoblox_logs/index.ts | 4 +-
.../instructions/auditbeat_instructions.ts | 560 +-
.../instructions/filebeat_instructions.ts | 557 +-
.../instructions/functionbeat_instructions.ts | 346 +-
.../instructions/heartbeat_instructions.ts | 521 +-
.../instructions/metricbeat_instructions.ts | 548 +-
.../instructions/winlogbeat_instructions.ts | 180 +-
.../server/tutorials/iptables_logs/index.ts | 4 +-
.../server/tutorials/juniper_logs/index.ts | 4 +-
.../home/server/tutorials/kafka_logs/index.ts | 4 +-
.../server/tutorials/kafka_metrics/index.ts | 4 +-
.../server/tutorials/kibana_logs/index.ts | 4 +-
.../server/tutorials/kibana_metrics/index.ts | 4 +-
.../tutorials/kubernetes_metrics/index.ts | 4 +-
.../server/tutorials/logstash_logs/index.ts | 4 +-
.../tutorials/logstash_metrics/index.ts | 4 +-
.../tutorials/memcached_metrics/index.ts | 4 +-
.../server/tutorials/microsoft_logs/index.ts | 4 +-
.../home/server/tutorials/misp_logs/index.ts | 4 +-
.../server/tutorials/mongodb_logs/index.ts | 4 +-
.../server/tutorials/mongodb_metrics/index.ts | 4 +-
.../home/server/tutorials/mssql_logs/index.ts | 4 +-
.../server/tutorials/mssql_metrics/index.ts | 4 +-
.../server/tutorials/munin_metrics/index.ts | 4 +-
.../home/server/tutorials/mysql_logs/index.ts | 4 +-
.../server/tutorials/mysql_metrics/index.ts | 4 +-
.../home/server/tutorials/nats_logs/index.ts | 4 +-
.../server/tutorials/nats_metrics/index.ts | 4 +-
.../server/tutorials/netflow_logs/index.ts | 4 +-
.../server/tutorials/netscout_logs/index.ts | 4 +-
.../home/server/tutorials/nginx_logs/index.ts | 4 +-
.../server/tutorials/nginx_metrics/index.ts | 4 +-
.../home/server/tutorials/o365_logs/index.ts | 4 +-
.../home/server/tutorials/okta_logs/index.ts | 4 +-
.../tutorials/openmetrics_metrics/index.ts | 4 +-
.../server/tutorials/oracle_metrics/index.ts | 4 +-
.../server/tutorials/osquery_logs/index.ts | 4 +-
.../home/server/tutorials/panw_logs/index.ts | 4 +-
.../server/tutorials/php_fpm_metrics/index.ts | 4 +-
.../server/tutorials/postgresql_logs/index.ts | 4 +-
.../tutorials/postgresql_metrics/index.ts | 4 +-
.../tutorials/prometheus_metrics/index.ts | 4 +-
.../server/tutorials/rabbitmq_logs/index.ts | 4 +-
.../tutorials/rabbitmq_metrics/index.ts | 4 +-
.../server/tutorials/radware_logs/index.ts | 4 +-
.../home/server/tutorials/redis_logs/index.ts | 4 +-
.../server/tutorials/redis_metrics/index.ts | 4 +-
.../redisenterprise_metrics/index.ts | 4 +-
.../home/server/tutorials/santa_logs/index.ts | 4 +-
.../server/tutorials/sonicwall_logs/index.ts | 4 +-
.../server/tutorials/sophos_logs/index.ts | 4 +-
.../home/server/tutorials/squid_logs/index.ts | 4 +-
.../server/tutorials/stan_metrics/index.ts | 4 +-
.../server/tutorials/statsd_metrics/index.ts | 4 +-
.../server/tutorials/suricata_logs/index.ts | 4 +-
.../server/tutorials/system_logs/index.ts | 4 +-
.../server/tutorials/system_metrics/index.ts | 4 +-
.../server/tutorials/tomcat_logs/index.ts | 4 +-
.../server/tutorials/traefik_logs/index.ts | 4 +-
.../server/tutorials/traefik_metrics/index.ts | 4 +-
.../server/tutorials/uptime_monitors/index.ts | 4 +-
.../server/tutorials/uwsgi_metrics/index.ts | 4 +-
.../server/tutorials/vsphere_metrics/index.ts | 4 +-
.../tutorials/windows_event_logs/index.ts | 4 +-
.../server/tutorials/windows_metrics/index.ts | 4 +-
.../home/server/tutorials/zeek_logs/index.ts | 4 +-
.../tutorials/zookeeper_metrics/index.ts | 4 +-
.../server/tutorials/zscaler_logs/index.ts | 4 +-
.../server/kibana_config_writer.test.ts | 11 +-
.../server/kibana_config_writer.ts | 7 +-
.../management_app/management_app.tsx | 43 +-
.../heatmap/public/vis_type/heatmap.tsx | 27 +-
.../metric/public/metric_vis_type.ts | 9 +-
.../pie/public/sample_vis.test.mocks.ts | 18 +-
.../vis_types/pie/public/vis_type/pie.ts | 18 +-
.../vis_types/table/public/table_vis_type.ts | 4 +-
src/plugins/vis_types/vislib/public/gauge.ts | 9 +-
src/plugins/vis_types/vislib/public/goal.ts | 9 +-
.../point_series/point_series.mocks.ts | 81 +-
.../xy/public/sample_vis.test.mocks.ts | 27 +-
.../xy/public/utils/get_series_params.test.ts | 2 +-
.../xy/public/utils/get_series_params.ts | 2 +-
.../vis_types/xy/public/vis_types/area.ts | 29 +-
.../xy/public/vis_types/histogram.ts | 29 +-
.../xy/public/vis_types/horizontal_bar.ts | 29 +-
.../vis_types/xy/public/vis_types/line.ts | 29 +-
.../check_for_duplicate_title.ts | 66 +
.../confirm_modal_promise.tsx | 46 +
.../utils/saved_objects_utils/constants.ts | 22 +
.../display_duplicate_title_confirm_modal.ts | 36 +
.../find_object_by_title.test.ts | 40 +
.../find_object_by_title.ts | 37 +
.../public/utils/saved_objects_utils/index.ts | 11 +-
.../save_with_confirmation.test.ts | 82 +
.../save_with_confirmation.ts | 76 +
.../utils/saved_visualize_utils.test.ts | 21 +-
.../public/utils/saved_visualize_utils.ts | 9 +-
...ualization_saved_object_migrations.test.ts | 32 +-
.../visualization_saved_object_migrations.ts | 18 +-
test/common/config.js | 4 +
.../apps/context/_context_navigation.ts | 27 +
.../run_pipeline/esaggs_sampler.ts | 121 +
.../test_suites/run_pipeline/index.ts | 1 +
x-pack/.gitignore | 2 +-
x-pack/.i18nrc.json | 1 +
x-pack/examples/reporting_example/kibana.json | 3 +-
.../public/containers/main.tsx | 13 +-
.../server/task_runner/task_runner.test.ts | 36 -
.../server/task_runner/task_runner.ts | 2 -
.../task_runner/task_runner_cancel.test.ts | 9 -
x-pack/plugins/apm/common/agent_key_types.ts | 13 +
.../common/anomaly_detection/apm_ml_job.ts | 17 +
.../get_anomaly_detection_setup_state.ts | 78 +
.../common/correlations/field_stats_types.ts | 6 +-
x-pack/plugins/apm/common/environment_rt.ts | 12 +-
x-pack/plugins/apm/common/fleet.ts | 2 +-
.../Settings/agent_keys/agent_keys_table.tsx | 6 +-
.../Settings/agent_keys/create_agent_key.tsx | 244 +
.../create_agent_key/agent_key_callout.tsx | 86 +
.../app/Settings/agent_keys/index.tsx | 163 +-
.../app/Settings/anomaly_detection/index.tsx | 43 +-
.../Settings/anomaly_detection/jobs_list.tsx | 179 +-
.../anomaly_detection/jobs_list_status.tsx | 102 +
.../anomaly_detection/legacy_jobs_callout.tsx | 51 -
.../context_popover/context_popover.tsx | 31 +-
.../context_popover/top_values.tsx | 334 +-
.../app/service_inventory/index.tsx | 25 +-
.../service_inventory.stories.tsx | 2 +
.../service_list/MLCallout.tsx | 60 -
.../service_inventory/service_list/index.tsx | 50 +-
.../service_list/service_list.test.tsx | 91 +-
.../agent_instructions_accordion.tsx | 219 +-
.../apm_agents/agent_instructions_mappings.ts | 15 +
.../fleet_integration/apm_agents/index.tsx | 15 +-
...template_strings.ts => render_mustache.ts} | 17 +-
.../default_discovery_rule.tsx | 30 +
.../runtime_attachment/discovery_rule.tsx | 125 +
.../edit_discovery_rule.tsx | 181 +
.../apm_agents/runtime_attachment/index.tsx | 327 +
.../runtime_attachment.stories.tsx | 484 +
.../runtime_attachment/runtime_attachment.tsx | 235 +
.../java_runtime_attachment.tsx | 276 +
.../routing/templates/settings_template.tsx | 26 +-
.../MachineLearningLinks/MLManageJobsLink.tsx | 40 +-
.../anomaly_detection_setup_link.test.tsx | 110 +-
.../anomaly_detection_setup_link.tsx | 129 +-
.../components/shared/managed_table/index.tsx | 3 +
.../components/shared/ml_callout/index.tsx | 196 +
.../anomaly_detection_jobs_context.tsx | 46 +-
.../public/hooks/use_ml_manage_jobs_href.ts | 48 +
x-pack/plugins/apm/public/plugin.ts | 3 +
.../server/deprecations/deprecations.test.ts | 2 +-
.../plugins/apm/server/deprecations/index.ts | 4 +-
x-pack/plugins/apm/server/index.ts | 12 +-
.../anomaly_detection/apm_ml_jobs_query.ts | 10 +-
.../create_anomaly_detection_jobs.ts | 20 +-
.../get_anomaly_detection_jobs.ts | 28 +-
.../get_anomaly_timeseries.ts | 10 +-
.../get_ml_jobs_with_apm_group.ts | 54 +-
.../lib/anomaly_detection/has_legacy_jobs.ts | 38 -
.../routes/agent_keys/create_agent_key.ts | 138 +
.../apm/server/routes/agent_keys/route.ts | 34 +-
...action_duration_anomaly_alert_type.test.ts | 23 +-
...transaction_duration_anomaly_alert_type.ts | 6 +-
.../field_stats/get_boolean_field_stats.ts | 19 +-
.../field_stats/get_field_stats.test.ts | 52 +-
.../field_stats/get_field_value_stats.ts | 76 +
.../queries/field_stats/get_fields_stats.ts | 13 +-
.../field_stats/get_keyword_field_stats.ts | 20 +-
.../field_stats/get_numeric_field_stats.ts | 52 +-
.../routes/correlations/queries/index.ts | 1 +
.../apm/server/routes/correlations/route.ts | 53 +-
.../correlations/utils/field_stats_utils.ts | 21 -
.../data_view/create_static_data_view.test.ts | 10 +-
.../data_view/create_static_data_view.ts | 4 +-
.../service_map/get_service_anomalies.ts | 12 +-
.../settings/anomaly_detection/route.ts | 53 +-
.../anomaly_detection/update_to_v3.ts | 60 +
x-pack/plugins/apm/server/routes/typings.ts | 1 +
.../plugins/cases/common/api/cases/alerts.ts | 1 -
.../__snapshots__/audit_logger.test.ts.snap | 84 +
.../server/authorization/authorization.ts | 2 +-
.../cases/server/authorization/index.ts | 174 +-
.../cases/server/authorization/types.ts | 1 +
.../plugins/cases/server/client/alerts/get.ts | 2 +-
.../cases/server/client/alerts/types.ts | 2 +-
.../cases/server/client/attachments/add.ts | 9 +-
.../cases/server/client/attachments/delete.ts | 3 +-
.../cases/server/client/attachments/get.ts | 64 +-
.../cases/server/client/attachments/update.ts | 4 +-
.../cases/server/client/cases/create.ts | 3 +-
.../cases/server/client/cases/delete.ts | 2 +-
.../plugins/cases/server/client/cases/find.ts | 3 +-
.../plugins/cases/server/client/cases/get.ts | 3 +-
.../plugins/cases/server/client/cases/push.ts | 3 +-
.../cases/server/client/cases/update.ts | 4 +-
.../cases/server/client/cases/utils.test.ts | 2 +-
.../cases/server/client/configure/client.ts | 2 +-
.../client/configure/create_mappings.ts | 2 +-
.../server/client/configure/get_mappings.ts | 2 +-
.../client/configure/update_mappings.ts | 2 +-
.../server/client/metrics/alerts_count.ts | 48 +-
.../client/metrics/get_case_metrics.test.ts | 14 +-
.../server/client/metrics/get_case_metrics.ts | 51 +-
.../cases/server/client/stats/client.ts | 2 +-
.../cases/server/client/sub_cases/client.ts | 8 +-
.../cases/server/client/sub_cases/update.ts | 4 +-
.../server/client/user_actions/get.test.ts | 2 +-
.../cases/server/client/user_actions/get.ts | 4 +-
.../plugins/cases/server/client/utils.test.ts | 2 +-
x-pack/plugins/cases/server/client/utils.ts | 4 +-
x-pack/plugins/cases/server/common/index.ts | 13 +-
.../server/common/models/commentable_case.ts | 10 +-
x-pack/plugins/cases/server/common/utils.ts | 2 +-
.../cases/server/connectors/case/index.ts | 2 +-
.../routes/api/__fixtures__/authc_mock.ts | 2 +-
.../cases/server/routes/api/utils.test.ts | 2 +-
.../plugins/cases/server/routes/api/utils.ts | 2 +-
.../import_export/export.ts | 3 +-
.../migrations/cases.test.ts | 2 +-
.../saved_object_types/migrations/cases.ts | 5 +-
.../migrations/configuration.test.ts | 3 +-
.../migrations/configuration.ts | 2 +-
.../cases/server/services/alerts/index.ts | 3 +-
.../server/services/attachments/index.ts | 49 +
.../cases/server/services/cases/index.test.ts | 3 +-
.../cases/server/services/cases/index.ts | 4 +-
.../server/services/cases/transform.test.ts | 4 +-
.../cases/server/services/cases/transform.ts | 5 +-
.../server/services/configure/index.test.ts | 3 +-
.../cases/server/services/configure/index.ts | 3 +-
.../services/connector_mappings/index.ts | 2 +-
x-pack/plugins/cases/server/services/mocks.ts | 1 +
.../cases/server/services/test_utils.ts | 2 +-
.../cases/server/services/transform.ts | 2 +-
.../server/services/user_actions/helpers.ts | 2 +-
.../server/services/user_actions/index.ts | 2 +-
.../services/user_actions/transform.test.ts | 4 +-
.../server/services/user_actions/transform.ts | 4 +-
.../public/app/index.tsx | 29 +-
.../public/plugin.ts | 3 +-
.../public/shared_imports.ts | 2 +
.../common/__mocks__/initial_app_data.ts | 1 +
.../enterprise_search/common/types/index.ts | 1 +
.../crawl_details_flyout.test.tsx | 30 +-
.../crawl_details_flyout.tsx | 15 +-
.../crawl_details_preview.test.tsx | 45 +-
.../crawl_details_preview.tsx | 17 +-
.../crawl_details_summary.test.tsx | 82 +
.../crawl_details_summary.tsx | 261 +
.../crawl_event_type_badge.test.tsx | 1 +
.../components/crawl_requests_table.test.tsx | 2 +
.../crawler/crawl_detail_logic.test.ts | 13 +
.../components/crawler/crawler_logic.test.ts | 1 +
.../crawler/crawler_overview.test.tsx | 2 +
.../app_search/components/crawler/types.ts | 30 +-
.../components/crawler/utils.test.ts | 62 +
.../app_search/components/crawler/utils.ts | 47 +-
.../error_connecting.test.tsx | 6 +-
.../error_connecting/error_connecting.tsx | 6 +-
.../applications/app_search/index.test.tsx | 6 +-
.../public/applications/app_search/index.tsx | 4 +-
.../error_connecting.test.tsx | 6 +-
.../error_connecting/error_connecting.tsx | 6 +-
.../enterprise_search/index.test.tsx | 6 +-
.../applications/enterprise_search/index.tsx | 3 +-
.../shared/doc_links/doc_links.ts | 3 +
.../error_state/error_state_prompt.test.tsx | 42 +-
.../shared/error_state/error_state_prompt.tsx | 136 +-
.../__mocks__/content_sources.mock.ts | 5 +
.../components/layout/nav.test.tsx | 5 +
.../components/layout/nav.tsx | 6 +
.../shared/assets/source_icons/index.ts | 2 +
.../license_callout/license_callout.tsx | 5 +-
.../workplace_search/constants.ts | 31 +
.../workplace_search/index.test.tsx | 6 +-
.../applications/workplace_search/index.tsx | 9 +-
.../applications/workplace_search/routes.ts | 39 +-
.../applications/workplace_search/types.ts | 15 +-
.../utils/handle_private_key_upload.ts | 21 +
.../workplace_search/utils/index.ts | 2 +
.../utils/read_uploaded_file_as_text.ts | 22 +
.../views/api_keys/api_keys.test.tsx | 102 +
.../views/api_keys/api_keys.tsx | 109 +
.../views/api_keys/api_keys_logic.test.ts | 491 +
.../views/api_keys/api_keys_logic.ts | 213 +
.../api_keys/components/api_key.test.tsx | 59 +
.../views/api_keys/components/api_key.tsx | 42 +
.../components/api_key_flyout.test.tsx | 94 +
.../api_keys/components/api_key_flyout.tsx | 103 +
.../components/api_keys_list.test.tsx | 193 +
.../api_keys/components/api_keys_list.tsx | 112 +
.../views/api_keys/constants.ts | 149 +
.../workplace_search/views/api_keys}/index.ts | 2 +-
.../components/add_source/add_source_logic.ts | 2 +-
.../add_source/config_completed.tsx | 10 +-
.../add_source/configure_custom.tsx | 4 +-
.../components/add_source/constants.ts | 16 +-
.../document_permissions_callout.tsx | 4 +-
.../add_source/document_permissions_field.tsx | 6 +-
.../components/add_source/github_app.tsx | 64 -
.../components/add_source/github_via_app.tsx | 128 +
.../add_source/github_via_app_logic.ts | 116 +
.../components/add_source/index.ts | 2 +-
.../add_source/save_custom.test.tsx | 2 +-
.../components/add_source/save_custom.tsx | 39 +-
.../content_sources/components/overview.tsx | 22 +-
.../components/source_content.tsx | 4 +-
.../components/source_identifier.test.tsx | 32 +
.../components/source_identifier.tsx | 73 +
.../components/source_layout.tsx | 4 +-
.../components/source_settings.tsx | 77 +-
.../components/synchronization/frequency.tsx | 4 +-
.../synchronization/objects_and_assets.tsx | 4 +-
.../synchronization/synchronization.tsx | 4 +-
.../views/content_sources/constants.ts | 7 -
.../views/content_sources/source_data.tsx | 55 +-
.../content_sources/source_logic.test.ts | 2 +
.../views/content_sources/source_logic.ts | 52 +
.../content_sources/sources_router.test.tsx | 2 +-
.../views/content_sources/sources_router.tsx | 12 +-
.../views/content_sources/sources_view.tsx | 6 +-
.../views/error_state/error_state.test.tsx | 6 +-
.../views/error_state/error_state.tsx | 6 +-
.../views/role_mappings/role_mappings.tsx | 6 +-
.../views/settings/components/connectors.tsx | 2 +-
.../settings/components/oauth_application.tsx | 4 +-
.../views/setup_guide/setup_guide.tsx | 4 +-
.../enterprise_search/public/plugin.ts | 4 +-
.../lib/enterprise_search_config_api.test.ts | 1 +
.../server/routes/app_search/crawler.test.ts | 30 +-
.../server/routes/app_search/crawler.ts | 30 +-
.../app_search/crawler_crawl_rules.test.ts | 6 +-
.../routes/app_search/crawler_crawl_rules.ts | 6 +-
.../app_search/crawler_entry_points.test.ts | 6 +-
.../routes/app_search/crawler_entry_points.ts | 6 +-
.../app_search/crawler_sitemaps.test.ts | 6 +-
.../routes/app_search/crawler_sitemaps.ts | 6 +-
.../routes/workplace_search/api_keys.test.ts | 92 +
.../routes/workplace_search/api_keys.ts | 57 +
.../server/routes/workplace_search/index.ts | 2 +
.../routes/workplace_search/sources.test.ts | 4 +-
.../server/routes/workplace_search/sources.ts | 8 +-
.../common/constants/preconfiguration.ts | 6 +
.../plugins/fleet/common/constants/routes.ts | 31 +-
.../fleet/common/constants/settings.ts | 2 +
.../plugins/fleet/common/openapi/bundled.json | 533 +-
.../plugins/fleet/common/openapi/bundled.yaml | 340 +-
.../openapi/components/schemas/agent.yaml | 3 -
.../schemas/new_package_policy.yaml | 4 -
.../openapi/components/schemas/output.yaml | 2 +
.../schemas/update_package_policy.yaml | 55 +-
.../fleet/common/openapi/entrypoint.yaml | 12 +
.../fleet/common/openapi/paths/agents.yaml | 7 +-
.../openapi/paths/enrollment_api_keys.yaml | 7 +-
...epm@packages@{pkg_name}@{pkg_version}.yaml | 118 +
.../openapi/paths/outputs@{output_id}.yaml | 2 +
x-pack/plugins/fleet/common/services/index.ts | 1 +
.../plugins/fleet/common/services/routes.ts | 29 +-
.../fleet/common/services/split_pkg_key.ts | 34 +
.../fleet/common/types/models/output.ts | 1 +
.../common/types/models/package_policy.ts | 1 +
.../common/types/models/preconfiguration.ts | 1 +
.../fleet/common/types/rest_spec/agent.ts | 15 +-
.../common/types/rest_spec/agent_policy.ts | 9 +-
.../types/rest_spec/enrollment_api_key.ts | 18 +-
.../fleet/common/types/rest_spec/epm.ts | 55 +-
.../fleet/common/types/rest_spec/output.ts | 11 +-
.../common/types/rest_spec/package_policy.ts | 15 +-
.../cypress/fixtures/integrations/apache.json | 2 +-
.../cypress/integration/integrations.spec.ts | 2 +-
.../fleet/cypress/tasks/integrations.ts | 2 +-
x-pack/plugins/fleet/dev_docs/api/epm.md | 4 +-
.../create_package_policy_page/index.tsx | 8 +-
.../edit_package_policy_page/index.tsx | 12 +-
.../sections/agents/agent_list_page/index.tsx | 4 +-
.../fleet_server_on_prem_instructions.tsx | 14 +-
.../components/install_command_utils.test.ts | 33 +-
.../components/install_command_utils.ts | 44 +-
.../components/fleet_server_upgrade_modal.tsx | 2 +-
.../enrollment_token_list_page/index.tsx | 2 +-
.../hooks/use_fleet_server_unhealthy.test.tsx | 4 +-
.../integrations/hooks/use_links.tsx | 3 +-
.../hooks/use_package_install.tsx | 6 +-
.../epm/screens/detail/index.test.tsx | 6 +-
.../sections/epm/screens/detail/index.tsx | 12 +-
.../epm/screens/detail/settings/settings.tsx | 2 +-
.../epm/screens/home/available_packages.tsx | 4 +-
...advanced_agent_authentication_settings.tsx | 4 +-
.../public/hooks/use_package_icon_type.ts | 4 +-
.../hooks/use_package_installations.tsx | 5 +-
.../fleet/public/hooks/use_request/epm.ts | 24 +-
.../fleet/public/search_provider.test.ts | 2 +-
.../plugins/fleet/public/search_provider.ts | 2 +-
x-pack/plugins/fleet/server/mocks/index.ts | 2 +
.../fleet/server/routes/agent/handlers.ts | 3 +-
.../fleet/server/routes/agent/index.ts | 9 +
.../plugins/fleet/server/routes/app/index.ts | 9 +
.../routes/enrollment_api_key/handler.ts | 8 +-
.../server/routes/enrollment_api_key/index.ts | 40 +
.../fleet/server/routes/epm/handlers.ts | 47 +-
.../plugins/fleet/server/routes/epm/index.ts | 95 +
.../routes/package_policy/handlers.test.ts | 158 +-
.../server/routes/package_policy/handlers.ts | 40 +-
.../plugins/fleet/server/routes/security.ts | 4 +-
.../fleet/server/saved_objects/index.ts | 1 +
.../agent_policies/full_agent_policy.test.ts | 57 +-
.../agent_policies/full_agent_policy.ts | 7 +-
.../fleet/server/services/agent_policy.ts | 13 +
.../server/services/epm/packages/install.ts | 2 +-
.../server/services/epm/packages/remove.ts | 8 +-
.../server/services/epm/registry/index.ts | 39 +-
.../server/services/package_policy.test.ts | 218 +
.../fleet/server/services/package_policy.ts | 61 +
.../server/services/preconfiguration.test.ts | 1 +
.../fleet/server/services/preconfiguration.ts | 5 +-
.../plugins/fleet/server/services/settings.ts | 16 +-
.../server/types/models/package_policy.ts | 135 +-
.../server/types/models/preconfiguration.ts | 2 +
.../fleet/server/types/rest_spec/epm.ts | 41 +
.../fleet/server/types/rest_spec/output.ts | 2 +
.../server/types/rest_spec/package_policy.ts | 9 +-
.../storybook/context/fixtures/categories.ts | 2 +-
.../context/fixtures/integration.nginx.ts | 2 +-
.../context/fixtures/integration.okta.ts | 2 +-
.../storybook/context/fixtures/packages.ts | 2 +-
.../plugins/fleet/storybook/context/http.ts | 4 +-
x-pack/plugins/grokdebugger/public/plugin.js | 4 +-
.../plugins/grokdebugger/public/render_app.js | 14 +-
.../grokdebugger/public/shared_imports.ts | 5 +
.../public/application/index.tsx | 33 +-
.../public/plugin.tsx | 3 +-
.../public/shared_imports.ts | 11 +-
.../helpers/http_requests.ts | 12 +
.../template_create.test.tsx | 44 +-
.../template_form.helpers.ts | 4 +-
.../public/application/app_context.tsx | 9 +-
.../component_template_edit.test.tsx | 6 +-
.../helpers/setup_environment.tsx | 29 +-
.../configuration_form/configuration_form.tsx | 15 +-
.../configuration_form_schema.tsx | 8 +
.../mapper_size_plugin_section.tsx | 47 +
.../load_mappings/load_from_json_button.tsx | 6 +-
.../load_mappings_provider.test.tsx | 2 +-
.../load_mappings/load_mappings_provider.tsx | 6 +-
.../mappings_editor/constants/index.ts | 2 +
.../lib/extract_mappings_definition.test.ts | 6 +-
.../lib/extract_mappings_definition.ts | 9 +-
.../lib/mappings_validator.test.ts | 15 +-
.../mappings_editor/lib/mappings_validator.ts | 81 +-
.../mappings_editor/mappings_editor.tsx | 297 +-
.../components/mappings_editor/types/state.ts | 1 +
.../components/wizard_steps/step_mappings.tsx | 6 +-
.../wizard_steps/step_mappings_container.tsx | 3 +
.../public/application/index.tsx | 31 +-
.../application/mount_management_section.ts | 3 +-
.../public/application/services/api.ts | 8 +
.../application/services/documentation.ts | 12 +
.../public/application/services/index.ts | 1 +
.../index_management/public/shared_imports.ts | 3 +
.../server/routes/api/nodes}/index.ts | 2 +-
.../api/nodes/register_nodes_route.test.ts | 48 +
.../routes/api/nodes/register_nodes_route.ts | 33 +
.../index_management/server/routes/index.ts | 2 +
.../server/test/helpers/index.ts} | 10 +-
.../server/test/helpers/route_dependencies.ts | 20 +
.../server/test/helpers/router_mock.ts | 107 +
.../infra/public/alerting/inventory/index.ts | 6 +-
.../public/alerting/log_threshold/index.ts | 2 +-
...ert_type.ts => log_threshold_rule_type.ts} | 4 +-
.../public/alerting/metric_anomaly/index.ts | 9 +-
.../public/alerting/metric_threshold/index.ts | 6 +-
.../infra/public/apps/common_providers.tsx | 8 +-
x-pack/plugins/infra/public/apps/logs_app.tsx | 8 +-
.../plugins/infra/public/apps/metrics_app.tsx | 8 +-
.../data_search_error_callout.stories.tsx | 9 +-
.../data_search_progress.stories.tsx | 9 +-
.../loading/__examples__/index.stories.tsx | 15 +-
.../log_stream/log_stream.stories.mdx | 14 +-
.../log_stream/log_stream_embeddable.tsx | 2 +-
.../quality_warning_notices.stories.tsx | 4 +-
.../initial_configuration_step.stories.tsx | 9 +-
.../indices_configuration_panel.stories.tsx | 29 +-
x-pack/plugins/infra/public/plugin.ts | 14 +-
.../test_utils/use_global_storybook_theme.tsx | 59 +
.../infra/server/lib/alerting/index.ts | 2 +-
.../evaluate_condition.ts | 12 +-
.../inventory_metric_threshold_executor.ts | 41 +-
...r_inventory_metric_threshold_rule_type.ts} | 2 +-
.../log_threshold_executor.test.ts | 24 +-
.../log_threshold/log_threshold_executor.ts | 108 +-
...ts => register_log_threshold_rule_type.ts} | 4 +-
.../metric_anomaly/metric_anomaly_executor.ts | 20 +-
...s => register_metric_anomaly_rule_type.ts} | 14 +-
.../{evaluate_alert.ts => evaluate_rule.ts} | 4 +-
.../metric_threshold_executor.test.ts | 8 +-
.../metric_threshold_executor.ts | 51 +-
...=> register_metric_threshold_rule_type.ts} | 4 +-
.../lib/alerting/register_alert_types.ts | 36 -
.../lib/alerting/register_rule_types.ts | 35 +
x-pack/plugins/infra/server/plugin.ts | 4 +-
.../public/application/index.tsx | 17 +-
.../application/mount_management_section.ts | 4 +-
.../ingest_pipelines/public/shared_imports.ts | 7 +-
.../expressions/gauge_chart/gauge_chart.ts | 134 +
.../common/expressions/gauge_chart}/index.ts | 6 +-
.../common/expressions/gauge_chart/types.ts | 72 +
.../plugins/lens/common/expressions/index.ts | 1 +
.../common/expressions/pie_chart/pie_chart.ts | 4 +
.../common/expressions/pie_chart/types.ts | 1 +
x-pack/plugins/lens/jest.config.js | 1 +
.../lens/public/app_plugin/app.test.tsx | 20 +-
.../app_plugin/save_modal_container.tsx | 3 +-
.../lens/public/assets/chart_gauge.tsx | 61 +
x-pack/plugins/lens/public/async_services.ts | 2 +
.../components/table_basic.test.tsx | 2 +-
.../components/table_basic.tsx | 3 +-
.../visualization.test.tsx | 30 +
.../datatable_visualization/visualization.tsx | 3 +-
.../buttons/empty_dimension_button.tsx | 86 +-
.../editor_frame/config_panel/layer_panel.tsx | 3 +-
.../editor_frame/editor_frame.test.tsx | 1 +
.../editor_frame/suggestion_helpers.test.ts | 2 +
x-pack/plugins/lens/public/expressions.ts | 3 +
.../heatmap_visualization/suggestions.test.ts | 47 +
.../heatmap_visualization/suggestions.ts | 7 +-
.../toolbar_component.tsx | 11 +-
.../visualization.test.ts | 1 -
.../heatmap_visualization/visualization.tsx | 3 +-
.../dimension_panel/bucket_nesting_editor.tsx | 2 +-
.../dimension_panel/dimension_editor.tsx | 117 +-
.../dimension_panel/dimension_panel.test.tsx | 1 -
.../dimensions_editor_helpers.tsx | 25 +-
.../droppable/get_drop_props.ts | 35 +-
.../droppable/on_drop_handler.ts | 13 +-
.../dimension_panel/field_input.test.tsx | 487 +
.../dimension_panel/field_input.tsx | 114 +
.../dimension_panel/field_select.tsx | 52 +-
.../dimension_panel/reference_editor.test.tsx | 1 -
.../dimension_panel/reference_editor.tsx | 10 +-
.../dimension_panel/truncated_label.test.tsx | 1 -
.../indexpattern.test.ts | 3 +-
.../indexpattern_datasource/indexpattern.tsx | 10 +-
.../indexpattern_suggestions.test.tsx | 26 +-
.../indexpattern_suggestions.ts | 2 +-
.../lens_field_icon.tsx | 2 +-
.../definitions/filters/filters.test.tsx | 112 +
.../definitions/filters/filters.tsx | 9 +
.../operations/definitions/index.ts | 41 +-
.../definitions/shared_components/buckets.tsx | 15 +-
.../definitions/static_value.test.tsx | 8 +
.../operations/definitions/static_value.tsx | 2 +
.../definitions/terms/field_inputs.tsx | 234 +
.../definitions/terms/helpers.test.ts | 474 +
.../operations/definitions/terms/helpers.ts | 215 +
.../operations/definitions/terms/index.tsx | 298 +-
.../definitions/terms/terms.test.tsx | 645 +-
.../operations/definitions/terms/types.ts | 36 +
.../operations/operations.test.ts | 18 +-
.../indexpattern_datasource/pure_utils.ts | 43 +
.../public/indexpattern_datasource/utils.tsx | 63 +-
.../lens/public/lens_attribute_service.ts | 4 +-
.../metric_visualization/expression.tsx | 3 +-
.../metric_suggestions.test.ts | 24 +
.../metric_suggestions.ts | 3 +-
.../metric_visualization/visualization.tsx | 2 +-
.../lens/public/mocks/datasource_mock.ts | 1 +
.../plugins/lens/public/persistence/index.ts | 1 +
.../check_for_duplicate_title.ts | 59 +
.../confirm_modal_promise.tsx | 45 +
.../saved_objects_utils/constants.ts | 16 +
.../display_duplicate_title_confirm_modal.ts | 35 +
.../find_object_by_title.test.ts | 35 +
.../find_object_by_title.ts | 36 +
.../persistence/saved_objects_utils/index.ts | 8 +
.../render_function.test.tsx | 2 +-
.../pie_visualization/render_function.tsx | 5 +-
.../pie_visualization/render_helpers.test.ts | 26 +
.../pie_visualization/render_helpers.ts | 11 +-
.../pie_visualization/suggestions.test.ts | 183 +-
.../public/pie_visualization/suggestions.ts | 15 +-
.../public/pie_visualization/to_expression.ts | 16 +-
.../lens/public/pie_visualization/toolbar.tsx | 141 +-
.../pie_visualization/visualization.tsx | 7 +-
x-pack/plugins/lens/public/plugin.ts | 5 +
.../datasource_default_values.test.ts | 43 +
.../datasource_default_values.ts | 45 +
.../shared_components/empty_placeholder.tsx | 30 -
.../lens/public/shared_components/index.ts | 2 +-
.../public/shared_components/vis_label.tsx | 102 +
.../public/state_management/lens_slice.ts | 8 +-
x-pack/plugins/lens/public/types.ts | 9 +
.../chart_component.test.tsx.snap | 36 +
.../gauge/chart_component.test.tsx | 429 +
.../visualizations/gauge/chart_component.tsx | 244 +
.../public/visualizations/gauge/constants.ts | 16 +
.../gauge/dimension_editor.scss | 3 +
.../visualizations/gauge/dimension_editor.tsx | 223 +
.../visualizations/gauge/expression.tsx | 60 +
.../gauge/gauge_visualization.ts | 9 +
.../public/visualizations/gauge/index.scss | 14 +
.../lens/public/visualizations/gauge/index.ts | 41 +
.../visualizations/gauge/palette_config.tsx | 23 +
.../visualizations/gauge/suggestions.test.ts | 213 +
.../visualizations/gauge/suggestions.ts | 108 +
.../toolbar_component/gauge_config_panel.scss | 3 +
.../toolbar_component/gauge_toolbar.test.tsx | 179 +
.../gauge/toolbar_component/index.tsx | 99 +
.../public/visualizations/gauge/utils.test.ts | 41 +
.../lens/public/visualizations/gauge/utils.ts | 113 +
.../gauge/visualization.test.ts | 590 +
.../visualizations/gauge/visualization.tsx | 454 +
.../xy_visualization/expression.test.tsx | 2 +-
.../public/xy_visualization/expression.tsx | 16 +-
.../public/xy_visualization/to_expression.ts | 6 +-
.../public/xy_visualization/visualization.tsx | 7 +-
.../xy_config_panel/index.tsx | 11 +-
.../xy_visualization/xy_suggestions.test.ts | 27 +
.../public/xy_visualization/xy_suggestions.ts | 5 +-
.../public/application/app_context.tsx | 5 +-
.../public/application/app_providers.tsx | 10 +-
.../license_management/public/plugin.ts | 3 +-
.../public/shared_imports.ts | 2 +
x-pack/plugins/licensing/server/plugin.ts | 5 +-
x-pack/plugins/maps/common/constants.ts | 2 -
.../maps/public/classes/fields/mvt_field.ts | 6 +-
.../ems_vector_tile_layer.tsx | 64 +-
.../ems_vector_tile_layer}/image_utils.js | 2 +-
.../layers/heatmap_layer/heatmap_layer.ts | 16 +-
.../mvt_vector_layer/mvt_source_data.test.ts | 84 +-
.../mvt_vector_layer/mvt_source_data.ts | 49 +-
.../mvt_vector_layer.test.tsx | 16 +-
.../mvt_vector_layer/mvt_vector_layer.tsx | 30 +-
.../es_geo_grid_source.test.ts | 27 +-
.../es_geo_grid_source/es_geo_grid_source.tsx | 32 +-
.../es_search_source/es_search_source.test.ts | 16 +-
.../es_search_source/es_search_source.tsx | 34 +-
.../mvt_single_layer_vector_source.test.tsx | 11 +-
.../mvt_single_layer_vector_source.tsx | 24 +-
.../update_source_editor.tsx | 4 +-
.../tiled_single_layer_vector_source.ts | 26 -
.../classes/sources/vector_source/index.ts | 1 +
.../vector_source/mvt_vector_source.ts | 23 +
.../classes/styles/vector/maki_icons.ts | 729 +
.../properties/dynamic_icon_property.test.tsx | 14 +-
.../properties/dynamic_icon_property.tsx | 21 +-
.../properties/dynamic_size_property.tsx | 15 +-
.../vector/properties/static_icon_property.ts | 4 +-
.../vector/properties/static_size_property.ts | 13 +-
.../classes/styles/vector/symbol_utils.js | 86 +-
.../classes/styles/vector/vector_style.tsx | 6 +-
.../connected_components/mb_map/mb_map.tsx | 30 +-
.../connected_components/mb_map/utils.ts | 61 -
.../plugins/metrics_entities/common/index.ts | 13 +-
.../services/utils/compute_transform_id.ts | 2 +-
x-pack/plugins/ml/common/index.ts | 1 +
.../create_analytics_advanced_editor.tsx | 72 +-
.../components/create_step/create_step.tsx | 164 +-
.../create_step_footer/create_step_footer.tsx | 6 +-
.../details_step/details_step_form.tsx | 82 +-
.../action_delete/use_delete_action.tsx | 2 +-
.../use_create_analytics_form.ts | 138 +-
.../ml/public/application/util/index_utils.ts | 7 +-
.../ml/server/lib/alerts/alerting_service.ts | 4 +-
x-pack/plugins/ml/server/routes/apidoc.json | 1 +
x-pack/plugins/ml/server/routes/system.ts | 19 +-
x-pack/plugins/monitoring/common/constants.ts | 8 +
x-pack/plugins/monitoring/common/types/es.ts | 3 +
.../application/hooks/use_breadcrumbs.ts | 13 +
.../monitoring/public/application/index.tsx | 9 +
.../enterprise_search/ent_search_template.tsx | 15 +
.../pages/enterprise_search/overview.tsx | 76 +
.../overview/enterprise_search_panel.js | 166 +
.../components/cluster/overview/helpers.js | 1 +
.../components/cluster/overview/index.js | 7 +
.../enterprise_search/overview/index.ts | 8 +
.../enterprise_search/overview/overview.tsx | 151 +
.../enterprise_search/overview/status.tsx | 49 +
.../get_clusters_summary.test.js.snap | 4 +
.../lib/cluster/get_clusters_from_request.ts | 26 +-
.../lib/cluster/get_clusters_summary.ts | 2 +
.../server/lib/cluster/get_index_patterns.ts | 7 +
.../server/lib/details/get_metrics.ts | 3 +-
.../server/lib/details/get_series.ts | 10 +-
.../nodes/get_nodes/map_nodes_metrics.ts | 2 +-
.../_enterprise_search_stats.ts | 169 +
.../create_enterprise_search_query.ts | 43 +
.../get_enterprise_search_for_clusters.ts | 67 +
.../server/lib/enterprise_search/get_stats.ts | 50 +
.../server/lib/enterprise_search/index.ts | 9 +
.../__snapshots__/metrics.test.js.snap | 306 +
.../lib/metrics/enterprise_search/classes.ts | 31 +
.../lib/metrics/enterprise_search/metrics.js | 408 +
.../monitoring/server/lib/metrics/index.ts | 2 +
.../monitoring/server/lib/metrics/metrics.js | 2 +
.../routes/api/v1/enterprise_search/index.js | 8 +
.../enterprise_search/metric_set_overview.js | 57 +
.../api/v1/enterprise_search/overview.js | 57 +
.../monitoring/server/routes/api/v1/ui.js | 1 +
.../series_editor/columns/series_actions.tsx | 2 +-
.../columns/series_name.test.tsx | 50 +-
.../series_editor/columns/series_name.tsx | 12 +-
.../osquery/public/agents/use_agent_status.ts | 2 +-
.../get_agent_status_for_agent_policy.ts | 2 +-
.../painless_lab/public/application/index.tsx | 22 +-
x-pack/plugins/painless_lab/public/plugin.tsx | 3 +-
.../painless_lab/public/shared_imports.ts | 11 +
.../public/application/index.d.ts | 6 +-
.../public/application/index.js | 15 +-
.../plugins/remote_clusters/public/plugin.ts | 5 +-
.../remote_clusters/public/shared_imports.ts | 2 +
x-pack/plugins/reporting/common/constants.ts | 11 -
.../plugins/reporting/common/test/fixtures.ts | 1 -
x-pack/plugins/reporting/common/types/base.ts | 2 +-
.../common/types/export_types/png.ts | 2 +-
.../common/types/export_types/png_v2.ts | 2 +-
.../types/export_types/printable_pdf.ts | 2 +-
.../types/export_types/printable_pdf_v2.ts | 2 +-
.../plugins/reporting/common/types/index.ts | 17 -
.../plugins/reporting/common/types/layout.ts | 24 -
x-pack/plugins/reporting/kibana.json | 1 +
x-pack/plugins/reporting/public/lib/job.tsx | 2 -
.../components/report_info_flyout_content.tsx | 6 -
x-pack/plugins/reporting/public/plugin.ts | 5 +-
.../public/redirect/mount_redirect_app.tsx | 17 +-
.../public/redirect/redirect_app.tsx | 13 +-
.../public/share_context_menu/index.ts | 2 +-
.../screen_capture_panel_content.tsx | 4 +-
.../chromium/driver_factory/index.test.ts | 76 -
.../browsers/chromium/driver_factory/index.ts | 268 -
.../chromium/driver_factory/start_logs.ts | 144 -
.../server/browsers/chromium/index.ts | 36 -
.../server/browsers/download/download.test.ts | 72 -
.../download/ensure_downloaded.test.ts | 120 -
.../browsers/download/ensure_downloaded.ts | 101 -
.../reporting/server/browsers/index.ts | 35 -
.../reporting/server/browsers/install.ts | 72 -
.../config/__snapshots__/schema.test.ts.snap | 89 -
.../server/config/create_config.test.ts | 48 -
.../reporting/server/config/create_config.ts | 41 +-
.../default_chromium_sandbox_disabled.test.ts | 39 -
.../plugins/reporting/server/config/index.ts | 2 +-
.../reporting/server/config/schema.test.ts | 35 -
.../plugins/reporting/server/config/schema.ts | 60 -
x-pack/plugins/reporting/server/core.ts | 53 +-
.../export_types/common/generate_png.ts | 108 +-
.../server/export_types/common/index.ts | 2 +-
.../export_types/common/pdf/get_template.ts | 4 +-
.../export_types/common/pdf/index.test.ts | 71 +-
.../server/export_types/common/pdf/index.ts | 6 +-
.../png/execute_job/index.test.ts | 54 +-
.../export_types/png/execute_job/index.ts | 29 +-
.../export_types/png_v2/execute_job.test.ts | 62 +-
.../server/export_types/png_v2/execute_job.ts | 25 +-
.../printable_pdf/execute_job/index.test.ts | 24 +-
.../printable_pdf/execute_job/index.ts | 15 +-
.../printable_pdf/lib/generate_pdf.ts | 174 +-
.../export_types/printable_pdf/lib/tracker.ts | 17 +-
.../printable_pdf_v2/execute_job.test.ts | 24 +-
.../printable_pdf_v2/execute_job.ts | 13 +-
.../printable_pdf_v2/lib/generate_pdf.ts | 195 +-
.../printable_pdf_v2/lib/tracker.ts | 17 +-
.../reporting/server/lib/content_stream.ts | 54 +-
.../server/lib/layouts/create_layout.ts | 29 -
.../reporting/server/lib/layouts/index.ts | 51 -
.../screenshots/get_number_of_items.test.ts | 90 -
.../lib/screenshots/get_render_errors.test.ts | 82 -
.../lib/screenshots/get_time_range.test.ts | 76 -
.../reporting/server/lib/screenshots/index.ts | 83 -
.../server/lib/screenshots/observable.test.ts | 490 -
.../server/lib/screenshots/observable.ts | 85 -
.../screenshots/observable_handler.test.ts | 160 -
.../lib/screenshots/observable_handler.ts | 197 -
.../reporting/server/lib/store/mapping.ts | 1 -
.../reporting/server/lib/store/report.test.ts | 6 -
.../reporting/server/lib/store/report.ts | 4 -
.../reporting/server/lib/store/store.test.ts | 7 -
.../reporting/server/lib/store/store.ts | 2 -
.../server/lib/tasks/execute_report.ts | 1 -
.../plugins/reporting/server/plugin.test.ts | 10 -
x-pack/plugins/reporting/server/plugin.ts | 7 +-
.../server/routes/diagnostic/browser.test.ts | 157 +-
.../server/routes/diagnostic/browser.ts | 4 +-
.../routes/diagnostic/screenshot.test.ts | 8 +-
.../server/routes/diagnostic/screenshot.ts | 13 +-
.../server/routes/lib/request_handler.test.ts | 2 -
.../create_mock_browserdriverfactory.ts | 146 -
.../create_mock_reportingplugin.ts | 24 +-
.../reporting/server/test_helpers/index.ts | 2 -
x-pack/plugins/reporting/server/types.ts | 14 +-
.../reporting_usage_collector.test.ts.snap | 7 -
.../server/usage/get_reporting_usage.ts | 5 -
.../plugins/reporting/server/usage/schema.ts | 1 -
.../plugins/reporting/server/usage/types.ts | 1 -
x-pack/plugins/reporting/tsconfig.json | 1 +
x-pack/plugins/rollup/public/application.tsx | 19 +-
.../plugins/rollup/public/shared_imports.ts | 5 +
.../common/assets/field_maps/ecs_field_map.ts | 10 +
x-pack/plugins/rule_registry/server/config.ts | 1 -
.../rule_data_client/rule_data_client.mock.ts | 1 +
.../rule_data_client/rule_data_client.ts | 6 +-
.../server/rule_data_client/types.ts | 1 +
.../rule_data_plugin_service/index_info.ts | 12 +-
.../rule_data_plugin_service/index_options.ts | 11 +
.../resource_installer.mock.ts | 24 +
.../rule_data_plugin_service.test.ts | 109 +
.../create_persistence_rule_type_wrapper.ts | 18 +-
.../server/routes/lib/get_connection_count.ts | 21 +-
.../server/services/tags/tags_client.test.ts | 14 +-
.../server/services/tags/tags_client.ts | 12 +-
x-pack/plugins/screenshotting/README.md | 11 +
.../plugins/screenshotting/common/context.ts | 17 +
x-pack/plugins/screenshotting/common/index.ts | 10 +
.../plugins/screenshotting/common/layout.ts | 75 +
x-pack/plugins/screenshotting/jest.config.js | 15 +
x-pack/plugins/screenshotting/kibana.json | 14 +
.../screenshotting/public/context_storage.ts | 20 +
x-pack/plugins/screenshotting/public/index.ts | 18 +
.../plugins/screenshotting/public/plugin.tsx | 42 +
.../server/browsers/chromium/driver.ts} | 177 +-
.../browsers/chromium/driver_factory/args.ts | 28 +-
.../chromium/driver_factory/index.test.ts | 84 +
.../browsers/chromium/driver_factory/index.ts | 379 +
.../chromium/driver_factory/metrics.test.ts | 0
.../chromium/driver_factory/metrics.ts | 20 +-
.../server/browsers/chromium/index.ts | 21 +
.../server/browsers/chromium/paths.ts | 0
.../server/browsers/download/checksum.test.ts | 0
.../server/browsers/download/checksum.ts | 15 +-
.../server/browsers/download/fetch.test.ts | 57 +
.../server/browsers/download/fetch.ts} | 35 +-
.../server/browsers/download/index.test.ts | 104 +
.../server/browsers/download/index.ts | 94 +
.../browsers/extract/__fixtures__/file.md | 0
.../browsers/extract/__fixtures__/file.md.zip | Bin
.../server/browsers/extract/extract.test.ts | 0
.../server/browsers/extract/extract.ts | 0
.../server/browsers/extract/extract_error.ts | 1 +
.../server/browsers/extract/index.ts | 0
.../server/browsers/extract/unzip.test.ts | 0
.../server/browsers/extract/unzip.ts | 0
.../screenshotting/server/browsers/index.ts | 17 +
.../screenshotting/server/browsers/install.ts | 61 +
.../screenshotting/server/browsers/mock.ts | 95 +
.../server/browsers/network_policy.test.ts | 2 +-
.../server/browsers/network_policy.ts | 4 +-
.../server/browsers/safe_child_process.ts | 22 +-
.../server/config/create_config.test.ts | 39 +
.../server/config/create_config.ts | 57 +
.../default_chromium_sandbox_disabled.test.ts | 35 +
.../default_chromium_sandbox_disabled.ts | 15 +-
.../screenshotting/server/config/index.ts | 49 +
.../server/config/schema.test.ts | 146 +
.../screenshotting/server/config/schema.ts | 72 +
x-pack/plugins/screenshotting/server/index.ts | 20 +
.../server/layouts/base_layout.ts} | 18 +-
.../server}/layouts/canvas_layout.ts | 20 +-
.../server}/layouts/create_layout.test.ts | 28 +-
.../server/layouts/create_layout.ts | 26 +
.../screenshotting/server/layouts/index.ts | 38 +
.../server/layouts/mock.ts} | 22 +-
.../server}/layouts/preserve_layout.css | 0
.../server}/layouts/preserve_layout.test.ts | 0
.../server}/layouts/preserve_layout.ts | 21 +-
.../server}/layouts/print_layout.ts | 28 +-
x-pack/plugins/screenshotting/server/mock.ts | 22 +
.../screenshotting/server/plugin.test.ts | 76 +
.../plugins/screenshotting/server/plugin.ts | 88 +
.../server}/screenshots/constants.ts | 2 +-
.../get_element_position_data.test.ts | 50 +-
.../screenshots/get_element_position_data.ts | 41 +-
.../screenshots/get_number_of_items.test.ts | 58 +
.../screenshots/get_number_of_items.ts | 27 +-
.../screenshots/get_render_errors.test.ts | 53 +
.../server}/screenshots/get_render_errors.ts | 19 +-
.../screenshots/get_screenshots.test.ts | 42 +-
.../server}/screenshots/get_screenshots.ts | 36 +-
.../server/screenshots/get_time_range.test.ts | 49 +
.../server}/screenshots/get_time_range.ts | 15 +-
.../server/screenshots/index.test.ts | 411 +
.../server/screenshots/index.ts | 102 +
.../server}/screenshots/inject_css.ts | 17 +-
.../screenshotting/server/screenshots/mock.ts | 31 +
.../server/screenshots/observable.test.ts | 102 +
.../server/screenshots/observable.ts | 258 +
.../server}/screenshots/open_url.ts | 39 +-
.../server}/screenshots/wait_for_render.ts | 21 +-
.../screenshots/wait_for_visualizations.ts | 21 +-
x-pack/plugins/screenshotting/server/utils.ts | 13 +
x-pack/plugins/screenshotting/tsconfig.json | 19 +
x-pack/plugins/searchprofiler/kibana.json | 2 +-
.../public/application/index.tsx | 18 +-
.../plugins/searchprofiler/public/plugin.ts | 1 +
.../searchprofiler/public/shared_imports.ts | 2 +
.../security_solution/common/constants.ts | 4 +-
.../security_solution/common/cti/constants.ts | 16 +-
.../common/detection_engine/constants.ts | 13 +
.../schemas/request/rule_schemas.ts | 1 +
.../data_loaders/index_endpoint_hosts.ts | 2 +-
.../data_loaders/setup_fleet_for_endpoint.ts | 2 +-
.../common/endpoint/generate_data.ts | 2 +-
.../common/endpoint/index_data.ts | 4 +-
.../security_solution/cti/index.ts | 39 +-
.../security_solution/index.ts | 7 +
.../common/types/timeline/store.ts | 2 +-
.../detection_alerts/cti_enrichments.spec.ts | 11 +-
.../detection_rules/threshold_rule.spec.ts | 4 +-
.../overview/cti_link_panel.spec.ts | 13 +-
.../cypress/screens/create_new_rule.ts | 6 +-
.../cypress/screens/overview.ts | 4 +-
.../cypress/tasks/create_new_rule.ts | 6 +-
.../app/home/global_header/index.test.tsx | 5 +
.../template_wrapper/bottom_bar/index.tsx | 6 +-
.../public/cases/pages/index.tsx | 2 +-
.../enrichment_accordion_group.tsx | 4 +-
.../enrichment_button_content.test.tsx | 6 +-
.../cti_details/enrichment_button_content.tsx | 6 +-
.../cti_details/enrichment_summary.tsx | 28 +-
.../cti_details/helpers.test.tsx | 21 +
.../event_details/cti_details/helpers.tsx | 4 +-
.../event_details/cti_details/translations.ts | 4 +-
.../exceptions/add_exception_modal/index.tsx | 9 +-
.../exceptions/edit_exception_modal/index.tsx | 9 +-
.../exceptions/use_add_exception.test.tsx | 25 +-
.../exceptions/use_add_exception.tsx | 36 +-
.../components/matrix_histogram/types.ts | 4 +-
.../public/common/components/page/index.tsx | 4 +
.../common/components/sourcerer/helpers.tsx | 24 +-
.../components/sourcerer/index.test.tsx | 159 +-
.../common/components/sourcerer/index.tsx | 417 +-
.../components/sourcerer/refresh_button.tsx | 28 +
.../common/components/sourcerer/temporary.tsx | 188 +
.../components/sourcerer/translations.ts | 99 +
.../common/components/sourcerer/trigger.tsx | 116 +
.../update_default_data_view_modal.tsx | 96 +
.../sourcerer/use_pick_index_patterns.tsx | 121 +-
.../sourcerer/use_update_data_view.test.tsx | 95 +
.../sourcerer/use_update_data_view.tsx | 72 +
.../url_state/initialize_redux_by_url.tsx | 2 +-
.../common/containers/sourcerer/index.tsx | 121 +-
.../public/common/mock/mock_timeline_data.ts | 3 +
.../public/common/mock/timeline_results.ts | 4 +-
.../public/common/store/reducer.test.ts | 20 +-
.../public/common/store/sourcerer/actions.ts | 9 +-
.../common/store/sourcerer/helpers.test.ts | 114 +-
.../public/common/store/sourcerer/helpers.ts | 70 +-
.../public/common/store/sourcerer/model.ts | 23 +-
.../public/common/store/sourcerer/reducer.ts | 18 +-
.../common/store/sourcerer/selectors.ts | 44 +-
.../components/alerts_table/actions.test.tsx | 2 +-
.../alerts_table/default_config.test.tsx | 8 +-
.../alerts_table/default_config.tsx | 163 +-
.../components/alerts_table/index.tsx | 30 +-
.../query_preview/custom_histogram.test.tsx | 128 -
.../rules/query_preview/custom_histogram.tsx | 76 -
.../query_preview/eql_histogram.test.tsx | 152 -
.../rules/query_preview/eql_histogram.tsx | 73 -
.../rules/query_preview/histogram.test.tsx | 74 -
.../rules/query_preview/histogram.tsx | 75 -
.../rules/query_preview/index.test.tsx | 502 -
.../components/rules/query_preview/index.tsx | 362 -
.../rules/query_preview/reducer.test.ts | 502 -
.../components/rules/query_preview/reducer.ts | 167 -
.../threshold_histogram.test.tsx | 104 -
.../query_preview/threshold_histogram.tsx | 82 -
.../rules/rule_preview/helpers.test.ts | 51 +-
.../components/rules/rule_preview/helpers.ts | 11 +-
.../rules/rule_preview/index.test.tsx | 30 +-
.../components/rules/rule_preview/index.tsx | 27 +-
.../rule_preview/preview_histogram.test.tsx | 7 +
.../rules/rule_preview/preview_histogram.tsx | 61 +-
.../rule_preview/use_preview_histogram.tsx | 45 +-
.../rules/rule_preview/use_preview_route.tsx | 18 +-
.../rules/step_define_rule/index.test.tsx | 1 -
.../rules/step_define_rule/index.tsx | 33 +-
.../detection_engine/alerts/api.test.ts | 20 -
.../containers/detection_engine/alerts/api.ts | 10 -
.../rules/use_preview_rule.ts | 21 +-
.../detection_engine/detection_engine.tsx | 34 +-
.../detection_engine/rules/all/columns.tsx | 4 +-
.../detection_engine/rules/create/helpers.ts | 15 +-
.../rules/create/index.test.tsx | 1 -
.../rules/details/index.test.tsx | 1 -
.../detection_engine/rules/details/index.tsx | 39 +-
.../hosts/pages/details/details_tabs.test.tsx | 5 +-
.../store/mock_endpoint_result_list.ts | 6 +-
.../management/pages/endpoint_hosts/types.ts | 2 +-
.../pages/endpoint_hosts/view/index.test.tsx | 38 +-
.../pages/endpoint_hosts/view/index.tsx | 7 +-
.../management/pages/mocks/fleet_mocks.ts | 2 +-
.../pages/policy/store/services/ingest.ts | 6 +-
.../pages/policy/store/test_mock_utils.ts | 2 +-
.../embeddables/embedded_map.test.tsx | 9 +-
.../components/embeddables/embedded_map.tsx | 20 +-
.../overview/components/link_panel/helpers.ts | 7 -
.../overview/components/link_panel/index.ts | 1 -
.../components/link_panel/link_panel.tsx | 20 +-
.../overview/components/link_panel/types.ts | 1 +
.../cti_disabled_module.tsx | 11 +-
.../cti_enabled_module.test.tsx | 49 +-
.../overview_cti_links/cti_enabled_module.tsx | 49 +-
.../overview_cti_links/cti_no_events.test.tsx | 70 -
.../overview_cti_links/cti_no_events.tsx | 42 -
.../cti_with_events.test.tsx | 57 -
.../overview_cti_links/cti_with_events.tsx | 49 -
.../overview_cti_links/index.test.tsx | 38 +-
.../components/overview_cti_links/index.tsx | 36 +-
.../components/overview_cti_links/mock.ts | 13 +-
.../threat_intel_panel_view.tsx | 62 +-
.../overview_cti_links/translations.ts | 21 +-
.../use_integrations_page_link.tsx | 11 +
.../use_filters_for_signals_by_category.ts | 18 +-
.../containers/overview_cti_links/api.ts | 28 +
.../containers/overview_cti_links/helpers.ts | 60 -
.../containers/overview_cti_links/index.tsx | 116 +-
.../use_all_ti_data_sources.ts | 22 +
.../use_cti_event_counts.ts | 64 -
.../use_is_threat_intel_module_enabled.ts | 32 -
.../use_request_event_counts.ts | 54 -
.../overview_cti_links/use_ti_data_sources.ts | 174 +
.../overview_cti_links/use_ti_integrations.ts | 55 +
.../public/overview/pages/overview.test.tsx | 28 +-
.../public/overview/pages/overview.tsx | 25 +-
.../components/create_field_button/index.tsx | 15 +-
.../flyout/add_timeline_button/index.test.tsx | 10 +-
.../components/formatted_ip/index.test.tsx | 20 +-
.../components/open_timeline/helpers.ts | 1 -
.../components/timeline/body/index.test.tsx | 4 +
.../threat_match_row.test.tsx.snap | 2 +-
.../body/renderers/cti/indicator_details.tsx | 14 +-
.../renderers/cti/threat_match_row.test.tsx | 20 +-
.../body/renderers/cti/threat_match_row.tsx | 10 +-
.../body/renderers/host_name.test.tsx | 20 +-
.../timeline/eql_tab_content/index.test.tsx | 1 +
.../components/timeline/index.test.tsx | 113 +-
.../timelines/components/timeline/index.tsx | 47 +-
.../properties/use_create_timeline.tsx | 9 +-
.../timeline/query_tab_content/index.test.tsx | 1 +
.../timeline/query_tab_content/index.tsx | 2 +
.../timelines/store/timeline/actions.ts | 7 +-
.../timelines/store/timeline/defaults.ts | 2 +-
.../timelines/store/timeline/epic.test.ts | 4 +-
.../timelines/store/timeline/reducer.test.ts | 8 +-
.../timelines/store/timeline/selectors.ts | 4 +-
.../endpoint/routes/actions/isolation.test.ts | 20 +-
.../endpoint/routes/actions/isolation.ts | 10 +-
.../index/create_preview_index_route.ts | 92 -
.../find_rule_status_internal_route.test.ts | 8 +-
.../routes/rules/preview_rules_route.ts | 140 +-
.../lib/detection_engine/routes/utils.test.ts | 12 +-
.../lib/detection_engine/routes/utils.ts | 2 +-
.../create_security_rule_type_wrapper.ts | 16 +-
.../rule_types/eql/create_eql_alert_type.ts | 4 +-
.../create_indicator_match_alert_type.ts | 4 +-
.../rule_types/ml/create_ml_alert_type.ts | 8 +-
.../query/create_query_alert_type.ts | 4 +-
.../threshold/create_threshold_alert_type.ts | 4 +-
.../lib/detection_engine/rule_types/types.ts | 12 +-
.../enrich_signal_threat_matches.test.ts | 68 +-
.../enrich_signal_threat_matches.ts | 9 +-
.../signals/threat_mapping/types.ts | 1 +
.../server/lib/telemetry/receiver.ts | 2 -
.../timeline/__mocks__/create_timelines.ts | 2 +-
.../security_solution/server/plugin.ts | 97 +-
.../security_solution/server/routes/index.ts | 23 +-
.../security_solution/factory/cti/index.ts | 2 +
.../factory/cti/threat_intel_source/index.ts | 33 +
.../query.threat_intel_source.dsl.test.ts | 71 +
.../query.threat_intel_source.dsl.ts | 59 +
.../public/application/app_context.tsx | 4 +-
.../public/application/app_providers.tsx | 8 +-
.../application/mount_management_section.ts | 3 +-
.../snapshot_restore/public/shared_imports.ts | 6 +-
.../schema/xpack_plugins.json | 3 -
.../telemetry_collection/get_license.test.ts | 18 +-
.../telemetry_collection/get_license.ts | 4 +-
.../timelines/common/ecs/threat/index.ts | 5 +
x-pack/plugins/timelines/common/index.ts | 82 +-
.../common/types/timeline/cells/index.ts | 2 +-
.../timeline/cases/add_to_case_action.tsx | 9 +-
.../components/drag_and_drop/helpers.ts | 6 +-
.../public/components/drag_and_drop/index.tsx | 3 +-
.../components/fields_browser/index.tsx | 5 +-
.../hover_actions/actions/add_to_timeline.tsx | 7 +-
.../hover_actions/actions/column_toggle.tsx | 2 +-
.../components/hover_actions/actions/copy.tsx | 2 +-
.../actions/filter_for_value.tsx | 2 +-
.../actions/filter_out_value.tsx | 2 +-
.../hover_actions/actions/overflow.tsx | 2 +-
.../components/stateful_event_context.ts | 11 +
.../body/column_headers/header/helpers.ts | 4 +-
.../body/column_headers/helpers.test.tsx | 2 +-
.../body/control_columns/checkbox.test.tsx | 2 +-
.../t_grid/body/control_columns/checkbox.tsx | 2 +-
.../t_grid/body/control_columns/index.tsx | 2 +-
.../events/stateful_row_renderer/index.tsx | 2 +-
.../events/use_stateful_event_focus/index.tsx | 9 +-
.../components/t_grid/body/helpers.test.tsx | 2 +-
.../public/components/t_grid/body/index.tsx | 3 +-
.../t_grid/event_rendered_view/index.tsx | 3 +-
.../public/components/t_grid/helpers.tsx | 2 +-
.../alert_status_bulk_actions.tsx | 2 +-
.../fields_browser/categories_pane.tsx | 4 +-
.../toolbar/fields_browser/category.tsx | 5 +-
.../fields_browser/category_columns.tsx | 3 +-
.../toolbar/fields_browser/category_title.tsx | 3 +-
.../fields_browser/field_browser.test.tsx | 196 +-
.../toolbar/fields_browser/field_browser.tsx | 21 +-
.../fields_browser/field_items.test.tsx | 2 +-
.../toolbar/fields_browser/field_items.tsx | 3 +-
.../toolbar/fields_browser/fields_pane.tsx | 3 +-
.../toolbar/fields_browser/helpers.test.tsx | 2 +-
.../t_grid/toolbar/fields_browser/helpers.tsx | 4 +-
.../t_grid/toolbar/fields_browser/search.tsx | 2 +-
.../t_grid/toolbar/fields_browser/types.ts | 2 +-
.../public/components/utils/helpers.ts | 3 +-
.../timelines/public/container/index.tsx | 12 +-
.../public/container/source/index.tsx | 2 +-
.../public/container/use_update_alerts.ts | 2 +-
.../timelines/public/hooks/use_add_to_case.ts | 2 +-
x-pack/plugins/timelines/public/index.ts | 63 +-
.../timelines/public/mock/global_state.ts | 4 +-
.../public/mock/mock_timeline_data.ts | 5 +-
.../plugins/timelines/public/mock/t_grid.tsx | 2 +-
.../timelines/public/store/t_grid/defaults.ts | 2 +-
.../public/store/t_grid/helpers.test.tsx | 2 +-
.../timelines/public/store/t_grid/model.ts | 2 +-
.../public/store/t_grid/selectors.ts | 2 +
.../timelines/public/store/t_grid/types.ts | 2 +-
x-pack/plugins/timelines/public/types.ts | 4 +-
.../search_strategy/index_fields/index.ts | 5 +-
.../timeline/eql/__mocks__/index.ts | 2 +-
.../search_strategy/timeline/eql/helpers.ts | 8 +-
.../search_strategy/timeline/eql/index.ts | 2 +-
.../timeline/factory/events/all/constants.ts | 3 +
.../factory/events/all/helpers.test.ts | 2 +
.../translations/translations/ja-JP.json | 80 +-
.../translations/translations/zh-CN.json | 80 +-
x-pack/plugins/triggers_actions_ui/README.md | 15 +
.../servicenow/deprecated_callout.tsx | 30 +-
.../servicenow/helpers.test.ts | 70 +-
.../servicenow/helpers.ts | 37 +-
.../servicenow/servicenow.tsx | 9 +
.../servicenow/servicenow_connectors.tsx | 20 +-
.../servicenow/servicenow_itsm_params.tsx | 9 +-
.../servicenow/servicenow_selection_row.tsx | 39 +
.../servicenow/servicenow_sir_params.tsx | 11 +-
.../action_form.test.tsx | 61 +-
.../action_type_form.tsx | 180 +-
.../connector_add_inline.tsx | 115 +-
.../connectors_selection.test.tsx | 126 +
.../connectors_selection.tsx | 141 +
.../components/actions_connectors_list.tsx | 27 +-
.../application/sections/common/connectors.ts | 23 +
.../common/connectors_seleciton.test.tsx | 59 +
.../public/common/connectors_selection.tsx | 70 +
.../triggers_actions_ui/public/types.ts | 8 +
.../public/application/app.tsx | 21 +-
.../upgrade_assistant/public/plugin.ts | 1 +
.../public/shared_imports.ts | 3 +
.../plugins/upgrade_assistant/public/types.ts | 7 +-
x-pack/plugins/uptime/common/constants/ui.ts | 2 +
.../uptime/common/runtime_types/index.ts | 1 +
.../monitor_management/config_key.ts | 2 +
.../runtime_types/monitor_management/index.ts | 2 +
.../monitor_management/locations.ts | 35 +
.../monitor_management/monitor_types.ts | 20 +
.../runtime_types/monitor_management/state.ts | 17 +
x-pack/plugins/uptime/common/types/index.ts | 32 +-
.../plugins/uptime/public/apps/uptime_app.tsx | 5 +-
.../components/common/header/action_menu.tsx | 11 +-
.../header/action_menu_content.test.tsx | 8 +-
.../common/header/action_menu_content.tsx | 23 +-
.../browser/advanced_fields.test.tsx | 1 -
.../fleet_package/browser/simple_fields.tsx | 7 +-
.../browser/source_field.test.tsx | 6 +
.../fleet_package/common/default_values.ts | 2 +
.../fleet_package/common/enabled.tsx | 48 +
.../fleet_package/common/formatters.ts | 2 +
.../fleet_package/common/normalizers.ts | 2 +
.../common/simple_fields_wrapper.tsx | 28 +
.../contexts/policy_config_context.tsx | 15 +-
.../contexts/synthetics_context_providers.tsx | 13 +-
.../fleet_package/custom_fields.test.tsx | 21 +
.../fleet_package/custom_fields.tsx | 7 +-
.../fleet_package/hooks/use_policy.ts | 6 +
.../fleet_package/http/simple_fields.tsx | 7 +-
.../fleet_package/icmp/simple_fields.tsx | 7 +-
...s_policy_create_extension_wrapper.test.tsx | 6 +
...ics_policy_edit_extension_wrapper.test.tsx | 7 +
.../fleet_package/tcp/simple_fields.tsx | 7 +-
.../action_bar/action_bar.test.tsx | 44 +-
.../action_bar/action_bar.tsx | 37 +-
.../monitor_management/add_monitor_btn.tsx | 35 +
.../edit_monitor_config.tsx | 89 +
.../monitor_management/formatters/common.ts | 2 +
.../hooks/use_locations.test.tsx | 60 +
.../monitor_management/hooks/use_locations.ts | 28 +
.../monitor_management/loader/loader.test.tsx | 54 +
.../monitor_management/loader/loader.tsx | 51 +
.../monitor_config/locations.test.tsx | 85 +
.../monitor_config/locations.tsx | 71 +
.../{ => monitor_config}/monitor_config.tsx | 18 +-
.../{ => monitor_config}/monitor_fields.tsx | 8 +-
.../monitor_name_location.tsx | 15 +-
.../monitor_list/actions.test.tsx | 66 +
.../monitor_list/actions.tsx | 109 +
.../monitor_list/monitor_list.test.tsx | 112 +
.../monitor_list/monitor_list.tsx | 130 +
.../monitor_management/monitor_list/tags.tsx | 42 +
.../uptime/public/hooks/use_telemetry.ts | 1 +
.../public/lib/__mocks__/uptime_store.mock.ts | 17 +
.../uptime/public/lib/helper/rtl_helpers.tsx | 23 +-
.../public/lib/helper/spy_use_fetcher.ts | 9 +-
.../uptime/public/pages/add_monitor.tsx | 39 +-
.../uptime/public/pages/edit_monitor.tsx | 132 +-
x-pack/plugins/uptime/public/pages/index.ts | 1 +
.../public/pages/monitor_management.tsx | 39 +
x-pack/plugins/uptime/public/routes.tsx | 22 +
.../uptime/public/state/actions/index.ts | 1 +
.../state/actions/monitor_management.ts | 27 +
.../public/state/api/monitor_management.ts | 38 +-
.../plugins/uptime/public/state/api/utils.ts | 20 +
.../uptime/public/state/effects/index.ts | 2 +
.../state/effects/monitor_management.ts | 33 +
.../uptime/public/state/reducers/index.ts | 2 +
.../state/reducers/monitor_management.ts | 122 +
.../public/state/selectors/index.test.ts | 101 +-
.../uptime/public/state/selectors/index.ts | 3 +
.../lib/adapters/framework/adapter_types.ts | 2 +-
.../lib/synthetics_service/get_api_key.ts | 8 +-
.../get_service_locations.test.ts | 22 +-
.../get_service_locations.ts | 13 +-
.../synthetics_service/service_api_client.ts | 10 +-
.../synthetics_service/synthetics_service.ts | 28 +-
.../synthetics_service/get_monitors.ts | 15 +-
.../get_service_locations.ts | 2 +-
.../server/rest_api/uptime_route_wrapper.ts | 14 +-
.../watcher/public/application/index.tsx | 11 +-
.../public/application/shared_imports.ts | 3 +
x-pack/plugins/watcher/public/plugin.ts | 3 +-
x-pack/scripts/functional_tests.js | 1 +
x-pack/tasks/download_chromium.ts | 10 +-
.../spaces_only/tests/alerting/event_log.ts | 20 +-
.../spaces_only/tests/alerting/index.ts | 1 +
.../ml_rule_types/anomaly_detection/alert.ts | 290 +
.../ml_rule_types/anomaly_detection/index.ts | 15 +
.../tests/alerting/ml_rule_types/index.ts | 15 +
.../index_management/cluster_nodes.helpers.ts | 16 +
.../index_management/cluster_nodes.ts | 25 +
.../{constants.js => constants.ts} | 0
.../apis/management/index_management/index.js | 1 +
.../apis/metrics_ui/metric_threshold_alert.ts | 26 +-
.../api_integration/apis/ml/modules/index.ts | 8 +-
.../cluster/fixtures/multicluster.json | 572 +-
.../monitoring/cluster/fixtures/overview.json | 206 +-
.../monitoring/standalone_cluster/cluster.js | 1 -
.../standalone_cluster/fixtures/cluster.json | 32 +-
.../standalone_cluster/fixtures/clusters.json | 341 +-
.../apis/observability/index.ts | 14 -
.../upgrade_assistant/cloud_backup_status.ts | 5 +-
.../apis/uptime/rest/get_monitor.ts | 4 +-
.../tests/alerts/rule_registry.spec.ts | 576 -
.../anomaly_detection/update_to_v3.spec.ts | 119 +
.../tests/common/metrics/get_case_metrics.ts | 132 +-
.../tests/create_threat_matching.ts | 11 +
.../security_and_spaces/tests/index.ts | 1 +
.../tests/preview_rules.ts | 94 +
.../detection_engine_api_integration/utils.ts | 40 +
.../agent_policy_with_agents_setup.ts | 6 +-
.../fleet_api_integration/apis/agents/list.ts | 6 +-
.../apis/agents/reassign.ts | 2 +-
.../apis/agents/status.ts | 6 +-
.../apis/data_streams/list.ts | 13 +-
.../apis/enrollment_api_keys/crud.ts | 61 +-
.../apis/epm/bulk_upgrade.ts | 44 +-
.../apis/epm/data_stream.ts | 20 +-
.../fleet_api_integration/apis/epm/delete.ts | 21 +-
.../fleet_api_integration/apis/epm/file.ts | 2 +-
.../apis/epm/final_pipeline.ts | 10 +-
.../fleet_api_integration/apis/epm/get.ts | 44 +-
.../apis/epm/install_by_upload.ts | 29 +-
.../apis/epm/install_endpoint.ts | 6 +-
.../apis/epm/install_error_rollback.ts | 29 +-
.../apis/epm/install_overrides.ts | 13 +-
.../apis/epm/install_prerelease.ts | 11 +-
.../apis/epm/install_remove_assets.ts | 23 +-
.../apis/epm/install_remove_multiple.ts | 34 +-
.../apis/epm/install_update.ts | 26 +-
.../fleet_api_integration/apis/epm/list.ts | 4 +-
.../apis/epm/package_install_complete.ts | 10 +-
.../fleet_api_integration/apis/epm/setup.ts | 20 +-
.../apis/epm/update_assets.ts | 16 +-
.../apis/package_policy/upgrade.ts | 4 +-
.../apis/service_tokens.ts | 8 +-
x-pack/test/fleet_cypress/agent.ts | 6 +-
.../test/functional/apps/lens/epoch_millis.ts | 61 +
x-pack/test/functional/apps/lens/gauge.ts | 131 +
x-pack/test/functional/apps/lens/index.ts | 3 +
.../test/functional/apps/lens/multi_terms.ts | 90 +
.../test/functional/apps/lens/time_shift.ts | 18 +
.../apps/maps/embeddable/dashboard.js | 3 +-
.../classification_creation.ts | 12 +-
.../outlier_detection_creation.ts | 12 +-
.../regression_creation.ts | 12 +-
.../monitoring/enterprise_search/cluster.js | 36 +
.../monitoring/enterprise_search/overview.js | 44 +
.../test/functional/apps/monitoring/index.js | 3 +
.../apps/uptime/synthetics_integration.ts | 1 +
.../es_archives/lens/epoch_millis/data.json | 187 +
.../lens/epoch_millis/mappings.json | 374 +
.../ent_search/with_es/data.json.gz | Bin 0 -> 3324014 bytes
.../ent_search/with_es/mappings.json | 34470 ++++++++++++++++
.../kbn_archiver/lens/epoch_millis.json | 15 +
.../test/functional/page_objects/lens_page.ts | 44 +-
x-pack/test/functional/services/index.ts | 4 +
.../ml/data_frame_analytics_creation.ts | 8 +-
.../functional/services/ml/test_resources.ts | 11 +-
.../services/monitoring/cluster_overview.js | 19 +
.../monitoring/enterprise_search_overview.js | 20 +
.../enterprise_search_summary_status.js | 25 +
.../functional/services/monitoring/index.js | 2 +
.../services/uptime/synthetics_package.ts | 4 +-
.../apps/triggers_actions_ui/details.ts | 6 +-
x-pack/test/osquery_cypress/agent.ts | 6 +-
.../reporting_and_security.config.ts | 2 +-
x-pack/test/rule_registry/common/constants.ts | 13 +
.../lib/helpers/cleanup_target_indices.ts | 30 +
.../common/lib/helpers/create_alert.ts | 25 +
.../lib/helpers/create_apm_metric_index.ts | 70 +
.../lib/helpers/create_transaction_metric.ts | 42 +
.../common/lib/helpers/delete_alert.ts | 49 +
.../lib/helpers/get_alerts_target_indices.ts | 23 +
.../rule_registry/common/lib/helpers/index.ts | 14 +
.../lib/helpers/wait_until_next_execution.ts | 81 +
x-pack/test/rule_registry/common/types.ts | 22 +
.../rule_registry/spaces_only/config_basic.ts | 16 +
.../spaces_only/tests/basic/bootstrap.ts | 42 +
.../spaces_only/tests/basic/index.ts | 28 +
.../trial/__snapshots__/create_rule.snap | 124 +
.../spaces_only/tests/trial/create_rule.ts | 252 +
.../spaces_only/tests/trial/index.ts | 3 +-
.../security_and_spaces/apis/_find.ts | 16 +-
.../security_and_spaces/apis/get_all.ts | 6 +-
.../tests/pki/pki_auth.ts | 4 +-
.../es_archives/threat_indicator/data.json | 5 +-
.../threat_indicator/mappings.json | 8 +
.../es_archives/threat_indicator2/data.json | 3 +
.../threat_indicator2/mappings.json | 8 +
.../services/endpoint_policy.ts | 10 +-
.../apps/metricbeat/_metricbeat_dashboard.ts | 2 +-
yarn.lock | 75 +-
1635 files changed, 75357 insertions(+), 17717 deletions(-)
create mode 100644 docs/user/troubleshooting.asciidoc
rename packages/kbn-es/src/{artifact.js => artifact.ts} (65%)
rename packages/kbn-es/src/{custom_snapshots.js => custom_snapshots.ts} (82%)
create mode 100644 packages/kbn-es/src/errors.ts
rename packages/kbn-es/src/{index.js => index.ts} (72%)
delete mode 100644 packages/kbn-es/src/install/index.js
rename src/plugins/discover/public/utils/get_single_doc_url.ts => packages/kbn-es/src/install/index.ts (65%)
rename packages/kbn-es/src/install/{archive.js => install_archive.ts} (64%)
rename packages/kbn-es/src/install/{snapshot.js => install_snapshot.ts} (55%)
rename packages/kbn-es/src/install/{source.js => install_source.ts} (73%)
delete mode 100644 packages/kbn-es/src/paths.js
create mode 100644 packages/kbn-es/src/paths.ts
rename packages/kbn-es/src/utils/{build_snapshot.js => build_snapshot.ts} (53%)
delete mode 100644 packages/kbn-es/src/utils/cache.js
create mode 100644 packages/kbn-es/src/utils/cache.ts
rename packages/kbn-es/src/utils/{find_most_recently_changed.test.js => find_most_recently_changed.test.ts} (93%)
rename packages/kbn-es/src/utils/{find_most_recently_changed.js => find_most_recently_changed.ts} (65%)
delete mode 100644 packages/kbn-es/src/utils/index.js
create mode 100644 packages/kbn-es/src/utils/index.ts
rename packages/kbn-es/src/utils/{log.js => log.ts} (80%)
create mode 100644 packages/kbn-test/src/failed_tests_reporter/buildkite_metadata.ts
create mode 100644 packages/kbn-test/src/jest/mocks/apm_agent_mock.ts
create mode 100644 src/core/server/elasticsearch/client/log_query_and_deprecation.test.ts
create mode 100644 src/core/server/elasticsearch/client/log_query_and_deprecation.ts
create mode 100644 src/plugins/charts/public/static/components/empty_placeholder.scss
create mode 100644 src/plugins/data/common/search/aggs/buckets/diversified_sampler.ts
create mode 100644 src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.test.ts
create mode 100644 src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.ts
create mode 100644 src/plugins/data/common/search/aggs/buckets/sampler.ts
create mode 100644 src/plugins/data/common/search/aggs/buckets/sampler_fn.test.ts
create mode 100644 src/plugins/data/common/search/aggs/buckets/sampler_fn.ts
delete mode 100644 src/plugins/discover/public/utils/get_context_url.test.ts
delete mode 100644 src/plugins/discover/public/utils/get_context_url.tsx
create mode 100644 src/plugins/discover/public/utils/use_navigation_props.test.tsx
create mode 100644 src/plugins/discover/public/utils/use_navigation_props.tsx
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/check_for_duplicate_title.ts
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/confirm_modal_promise.tsx
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/constants.ts
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/display_duplicate_title_confirm_modal.ts
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.test.ts
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.ts
rename packages/kbn-es/src/errors.js => src/plugins/visualizations/public/utils/saved_objects_utils/index.ts (63%)
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/save_with_confirmation.test.ts
create mode 100644 src/plugins/visualizations/public/utils/saved_objects_utils/save_with_confirmation.ts
create mode 100644 test/interpreter_functional/test_suites/run_pipeline/esaggs_sampler.ts
create mode 100644 x-pack/plugins/apm/common/agent_key_types.ts
create mode 100644 x-pack/plugins/apm/common/anomaly_detection/apm_ml_job.ts
create mode 100644 x-pack/plugins/apm/common/anomaly_detection/get_anomaly_detection_setup_state.ts
create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/create_agent_key.tsx
create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/create_agent_key/agent_key_callout.tsx
create mode 100644 x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list_status.tsx
delete mode 100644 x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/legacy_jobs_callout.tsx
delete mode 100644 x-pack/plugins/apm/public/components/app/service_inventory/service_list/MLCallout.tsx
rename x-pack/plugins/apm/public/components/fleet_integration/apm_agents/{replace_template_strings.ts => render_mustache.ts} (65%)
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/default_discovery_rule.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/discovery_rule.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/edit_discovery_rule.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/index.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.stories.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.tsx
create mode 100644 x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/supported_agents/java_runtime_attachment.tsx
create mode 100644 x-pack/plugins/apm/public/components/shared/ml_callout/index.tsx
create mode 100644 x-pack/plugins/apm/public/hooks/use_ml_manage_jobs_href.ts
delete mode 100644 x-pack/plugins/apm/server/lib/anomaly_detection/has_legacy_jobs.ts
create mode 100644 x-pack/plugins/apm/server/routes/agent_keys/create_agent_key.ts
create mode 100644 x-pack/plugins/apm/server/routes/correlations/queries/field_stats/get_field_value_stats.ts
create mode 100644 x-pack/plugins/apm/server/routes/settings/anomaly_detection/update_to_v3.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_summary.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_summary.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/utils/handle_private_key_upload.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/utils/read_uploaded_file_as_text.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_key.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_key.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_key_flyout.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_key_flyout.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/constants.ts
rename x-pack/plugins/{reporting/server/browsers/chromium/driver => enterprise_search/public/applications/workplace_search/views/api_keys}/index.ts (80%)
delete mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/github_app.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/github_via_app.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/github_via_app_logic.ts
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_identifier.test.tsx
create mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/source_identifier.tsx
create mode 100644 x-pack/plugins/enterprise_search/server/routes/workplace_search/api_keys.test.ts
create mode 100644 x-pack/plugins/enterprise_search/server/routes/workplace_search/api_keys.ts
create mode 100644 x-pack/plugins/fleet/common/openapi/paths/epm@packages@{pkg_name}@{pkg_version}.yaml
create mode 100644 x-pack/plugins/fleet/common/services/split_pkg_key.ts
create mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/configuration_form/mapper_size_plugin_section.tsx
rename x-pack/plugins/{reporting/server/browsers/download => index_management/server/routes/api/nodes}/index.ts (80%)
create mode 100644 x-pack/plugins/index_management/server/routes/api/nodes/register_nodes_route.test.ts
create mode 100644 x-pack/plugins/index_management/server/routes/api/nodes/register_nodes_route.ts
rename x-pack/plugins/{security_solution/public/detections/containers/detection_engine/alerts/use_preview_index.tsx => index_management/server/test/helpers/index.ts} (59%)
create mode 100644 x-pack/plugins/index_management/server/test/helpers/route_dependencies.ts
create mode 100644 x-pack/plugins/index_management/server/test/helpers/router_mock.ts
rename x-pack/plugins/infra/public/alerting/log_threshold/{log_threshold_alert_type.ts => log_threshold_rule_type.ts} (92%)
create mode 100644 x-pack/plugins/infra/public/test_utils/use_global_storybook_theme.tsx
rename x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/{register_inventory_metric_threshold_alert_type.ts => register_inventory_metric_threshold_rule_type.ts} (98%)
rename x-pack/plugins/infra/server/lib/alerting/log_threshold/{register_log_threshold_alert_type.ts => register_log_threshold_rule_type.ts} (97%)
rename x-pack/plugins/infra/server/lib/alerting/metric_anomaly/{register_metric_anomaly_alert_type.ts => register_metric_anomaly_rule_type.ts} (95%)
rename x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/{evaluate_alert.ts => evaluate_rule.ts} (98%)
rename x-pack/plugins/infra/server/lib/alerting/metric_threshold/{register_metric_threshold_alert_type.ts => register_metric_threshold_rule_type.ts} (97%)
delete mode 100644 x-pack/plugins/infra/server/lib/alerting/register_alert_types.ts
create mode 100644 x-pack/plugins/infra/server/lib/alerting/register_rule_types.ts
create mode 100644 x-pack/plugins/lens/common/expressions/gauge_chart/gauge_chart.ts
rename x-pack/plugins/{maps/public/classes/sources/tiled_single_layer_vector_source => lens/common/expressions/gauge_chart}/index.ts (67%)
create mode 100644 x-pack/plugins/lens/common/expressions/gauge_chart/types.ts
create mode 100644 x-pack/plugins/lens/public/assets/chart_gauge.tsx
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.test.tsx
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/field_input.tsx
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/field_inputs.tsx
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/helpers.test.ts
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/helpers.ts
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/types.ts
create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/pure_utils.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/check_for_duplicate_title.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/confirm_modal_promise.tsx
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/constants.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/display_duplicate_title_confirm_modal.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.test.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.ts
create mode 100644 x-pack/plugins/lens/public/persistence/saved_objects_utils/index.ts
create mode 100644 x-pack/plugins/lens/public/shared_components/datasource_default_values.test.ts
create mode 100644 x-pack/plugins/lens/public/shared_components/datasource_default_values.ts
delete mode 100644 x-pack/plugins/lens/public/shared_components/empty_placeholder.tsx
create mode 100644 x-pack/plugins/lens/public/shared_components/vis_label.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/__snapshots__/chart_component.test.tsx.snap
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/chart_component.test.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/chart_component.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/constants.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.scss
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/expression.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/gauge_visualization.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/index.scss
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/index.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/palette_config.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/suggestions.test.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/suggestions.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_config_panel.scss
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_toolbar.test.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/index.tsx
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/utils.test.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/utils.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/visualization.test.ts
create mode 100644 x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx
rename x-pack/plugins/maps/public/{connected_components/mb_map => classes/layers/ems_vector_tile_layer}/image_utils.js (98%)
delete mode 100644 x-pack/plugins/maps/public/classes/sources/tiled_single_layer_vector_source/tiled_single_layer_vector_source.ts
create mode 100644 x-pack/plugins/maps/public/classes/sources/vector_source/mvt_vector_source.ts
create mode 100644 x-pack/plugins/maps/public/classes/styles/vector/maki_icons.ts
create mode 100644 x-pack/plugins/monitoring/public/application/pages/enterprise_search/ent_search_template.tsx
create mode 100644 x-pack/plugins/monitoring/public/application/pages/enterprise_search/overview.tsx
create mode 100644 x-pack/plugins/monitoring/public/components/cluster/overview/enterprise_search_panel.js
create mode 100644 x-pack/plugins/monitoring/public/components/enterprise_search/overview/index.ts
create mode 100644 x-pack/plugins/monitoring/public/components/enterprise_search/overview/overview.tsx
create mode 100644 x-pack/plugins/monitoring/public/components/enterprise_search/overview/status.tsx
create mode 100644 x-pack/plugins/monitoring/server/lib/enterprise_search/_enterprise_search_stats.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/enterprise_search/create_enterprise_search_query.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/enterprise_search/get_enterprise_search_for_clusters.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/enterprise_search/get_stats.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/enterprise_search/index.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/classes.ts
create mode 100644 x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.js
create mode 100644 x-pack/plugins/monitoring/server/routes/api/v1/enterprise_search/index.js
create mode 100644 x-pack/plugins/monitoring/server/routes/api/v1/enterprise_search/metric_set_overview.js
create mode 100644 x-pack/plugins/monitoring/server/routes/api/v1/enterprise_search/overview.js
create mode 100644 x-pack/plugins/painless_lab/public/shared_imports.ts
delete mode 100644 x-pack/plugins/reporting/common/types/layout.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.test.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/chromium/driver_factory/start_logs.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/chromium/index.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/download/download.test.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.test.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/download/ensure_downloaded.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/index.ts
delete mode 100644 x-pack/plugins/reporting/server/browsers/install.ts
delete mode 100644 x-pack/plugins/reporting/server/config/default_chromium_sandbox_disabled.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/layouts/create_layout.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/layouts/index.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/get_number_of_items.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/get_render_errors.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/get_time_range.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/index.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/observable.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/observable_handler.test.ts
delete mode 100644 x-pack/plugins/reporting/server/lib/screenshots/observable_handler.ts
delete mode 100644 x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts
create mode 100644 x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.mock.ts
create mode 100644 x-pack/plugins/rule_registry/server/rule_data_plugin_service/rule_data_plugin_service.test.ts
create mode 100644 x-pack/plugins/screenshotting/README.md
create mode 100644 x-pack/plugins/screenshotting/common/context.ts
create mode 100644 x-pack/plugins/screenshotting/common/index.ts
create mode 100644 x-pack/plugins/screenshotting/common/layout.ts
create mode 100644 x-pack/plugins/screenshotting/jest.config.js
create mode 100644 x-pack/plugins/screenshotting/kibana.json
create mode 100644 x-pack/plugins/screenshotting/public/context_storage.ts
create mode 100644 x-pack/plugins/screenshotting/public/index.ts
create mode 100755 x-pack/plugins/screenshotting/public/plugin.tsx
rename x-pack/plugins/{reporting/server/browsers/chromium/driver/chromium_driver.ts => screenshotting/server/browsers/chromium/driver.ts} (75%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/chromium/driver_factory/args.ts (81%)
create mode 100644 x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/chromium/driver_factory/metrics.test.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/chromium/driver_factory/metrics.ts (81%)
create mode 100644 x-pack/plugins/screenshotting/server/browsers/chromium/index.ts
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/chromium/paths.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/download/checksum.test.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/download/checksum.ts (62%)
create mode 100644 x-pack/plugins/screenshotting/server/browsers/download/fetch.test.ts
rename x-pack/plugins/{reporting/server/browsers/download/download.ts => screenshotting/server/browsers/download/fetch.ts} (55%)
create mode 100644 x-pack/plugins/screenshotting/server/browsers/download/index.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/browsers/download/index.ts
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/__fixtures__/file.md (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/__fixtures__/file.md.zip (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/extract.test.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/extract.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/extract_error.ts (99%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/index.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/unzip.test.ts (100%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/extract/unzip.ts (100%)
create mode 100644 x-pack/plugins/screenshotting/server/browsers/index.ts
create mode 100644 x-pack/plugins/screenshotting/server/browsers/install.ts
create mode 100644 x-pack/plugins/screenshotting/server/browsers/mock.ts
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/network_policy.test.ts (99%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/network_policy.ts (94%)
rename x-pack/plugins/{reporting => screenshotting}/server/browsers/safe_child_process.ts (70%)
create mode 100644 x-pack/plugins/screenshotting/server/config/create_config.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/config/create_config.ts
create mode 100644 x-pack/plugins/screenshotting/server/config/default_chromium_sandbox_disabled.test.ts
rename x-pack/plugins/{reporting => screenshotting}/server/config/default_chromium_sandbox_disabled.ts (80%)
create mode 100644 x-pack/plugins/screenshotting/server/config/index.ts
create mode 100644 x-pack/plugins/screenshotting/server/config/schema.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/config/schema.ts
create mode 100755 x-pack/plugins/screenshotting/server/index.ts
rename x-pack/plugins/{reporting/server/lib/layouts/layout.ts => screenshotting/server/layouts/base_layout.ts} (79%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/canvas_layout.ts (80%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/create_layout.test.ts (80%)
create mode 100644 x-pack/plugins/screenshotting/server/layouts/create_layout.ts
create mode 100644 x-pack/plugins/screenshotting/server/layouts/index.ts
rename x-pack/plugins/{reporting/server/test_helpers/create_mock_layoutinstance.ts => screenshotting/server/layouts/mock.ts} (59%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/preserve_layout.css (100%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/preserve_layout.test.ts (100%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/preserve_layout.ts (79%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/layouts/print_layout.ts (64%)
create mode 100644 x-pack/plugins/screenshotting/server/mock.ts
create mode 100644 x-pack/plugins/screenshotting/server/plugin.test.ts
create mode 100755 x-pack/plugins/screenshotting/server/plugin.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/constants.ts (92%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_element_position_data.test.ts (69%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_element_position_data.ts (75%)
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/get_number_of_items.test.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_number_of_items.ts (79%)
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/get_render_errors.test.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_render_errors.ts (78%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_screenshots.test.ts (71%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_screenshots.ts (59%)
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/get_time_range.test.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/get_time_range.ts (79%)
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/index.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/index.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/inject_css.ts (78%)
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/mock.ts
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/observable.test.ts
create mode 100644 x-pack/plugins/screenshotting/server/screenshots/observable.ts
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/open_url.ts (54%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/wait_for_render.ts (84%)
rename x-pack/plugins/{reporting/server/lib => screenshotting/server}/screenshots/wait_for_visualizations.ts (80%)
create mode 100644 x-pack/plugins/screenshotting/server/utils.ts
create mode 100644 x-pack/plugins/screenshotting/tsconfig.json
create mode 100644 x-pack/plugins/security_solution/common/detection_engine/constants.ts
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/refresh_button.tsx
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/temporary.tsx
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/trigger.tsx
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/update_default_data_view_modal.tsx
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.test.tsx
create mode 100644 x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/custom_histogram.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/custom_histogram.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/eql_histogram.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/eql_histogram.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/histogram.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/histogram.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/index.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.test.ts
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/reducer.ts
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/threshold_histogram.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/detections/components/rules/query_preview/threshold_histogram.tsx
delete mode 100644 x-pack/plugins/security_solution/public/overview/components/overview_cti_links/cti_no_events.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/overview/components/overview_cti_links/cti_no_events.tsx
delete mode 100644 x-pack/plugins/security_solution/public/overview/components/overview_cti_links/cti_with_events.test.tsx
delete mode 100644 x-pack/plugins/security_solution/public/overview/components/overview_cti_links/cti_with_events.tsx
create mode 100644 x-pack/plugins/security_solution/public/overview/components/overview_cti_links/use_integrations_page_link.tsx
create mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/api.ts
delete mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/helpers.ts
create mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_all_ti_data_sources.ts
delete mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_cti_event_counts.ts
delete mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_is_threat_intel_module_enabled.ts
delete mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_request_event_counts.ts
create mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_data_sources.ts
create mode 100644 x-pack/plugins/security_solution/public/overview/containers/overview_cti_links/use_ti_integrations.ts
delete mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/create_preview_index_route.ts
create mode 100644 x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/threat_intel_source/index.ts
create mode 100644 x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/threat_intel_source/query.threat_intel_source.dsl.test.ts
create mode 100644 x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/threat_intel_source/query.threat_intel_source.dsl.ts
create mode 100644 x-pack/plugins/timelines/public/components/stateful_event_context.ts
create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_selection_row.tsx
create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx
create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.tsx
create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/sections/common/connectors.ts
create mode 100644 x-pack/plugins/triggers_actions_ui/public/common/connectors_seleciton.test.tsx
create mode 100644 x-pack/plugins/triggers_actions_ui/public/common/connectors_selection.tsx
create mode 100644 x-pack/plugins/uptime/common/runtime_types/monitor_management/locations.ts
create mode 100644 x-pack/plugins/uptime/common/runtime_types/monitor_management/state.ts
create mode 100644 x-pack/plugins/uptime/public/components/fleet_package/common/enabled.tsx
create mode 100644 x-pack/plugins/uptime/public/components/fleet_package/common/simple_fields_wrapper.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/add_monitor_btn.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/edit_monitor_config.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/hooks/use_locations.test.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/hooks/use_locations.ts
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/loader/loader.test.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/loader/loader.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_config/locations.test.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_config/locations.tsx
rename x-pack/plugins/uptime/public/components/monitor_management/{ => monitor_config}/monitor_config.tsx (71%)
rename x-pack/plugins/uptime/public/components/monitor_management/{ => monitor_config}/monitor_fields.tsx (76%)
rename x-pack/plugins/uptime/public/components/monitor_management/{ => monitor_config}/monitor_name_location.tsx (60%)
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.test.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx
create mode 100644 x-pack/plugins/uptime/public/components/monitor_management/monitor_list/tags.tsx
create mode 100644 x-pack/plugins/uptime/public/pages/monitor_management.tsx
create mode 100644 x-pack/plugins/uptime/public/state/actions/monitor_management.ts
create mode 100644 x-pack/plugins/uptime/public/state/effects/monitor_management.ts
create mode 100644 x-pack/plugins/uptime/public/state/reducers/monitor_management.ts
create mode 100644 x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ml_rule_types/anomaly_detection/alert.ts
create mode 100644 x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ml_rule_types/anomaly_detection/index.ts
create mode 100644 x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ml_rule_types/index.ts
create mode 100644 x-pack/test/api_integration/apis/management/index_management/cluster_nodes.helpers.ts
create mode 100644 x-pack/test/api_integration/apis/management/index_management/cluster_nodes.ts
rename x-pack/test/api_integration/apis/management/index_management/{constants.js => constants.ts} (100%)
delete mode 100644 x-pack/test/api_integration/apis/observability/index.ts
delete mode 100644 x-pack/test/apm_api_integration/tests/alerts/rule_registry.spec.ts
create mode 100644 x-pack/test/apm_api_integration/tests/settings/anomaly_detection/update_to_v3.spec.ts
create mode 100644 x-pack/test/detection_engine_api_integration/security_and_spaces/tests/preview_rules.ts
create mode 100644 x-pack/test/functional/apps/lens/epoch_millis.ts
create mode 100644 x-pack/test/functional/apps/lens/gauge.ts
create mode 100644 x-pack/test/functional/apps/lens/multi_terms.ts
create mode 100644 x-pack/test/functional/apps/monitoring/enterprise_search/cluster.js
create mode 100644 x-pack/test/functional/apps/monitoring/enterprise_search/overview.js
create mode 100644 x-pack/test/functional/es_archives/lens/epoch_millis/data.json
create mode 100644 x-pack/test/functional/es_archives/lens/epoch_millis/mappings.json
create mode 100644 x-pack/test/functional/es_archives/monitoring/ent_search/with_es/data.json.gz
create mode 100644 x-pack/test/functional/es_archives/monitoring/ent_search/with_es/mappings.json
create mode 100644 x-pack/test/functional/fixtures/kbn_archiver/lens/epoch_millis.json
create mode 100644 x-pack/test/functional/services/monitoring/enterprise_search_overview.js
create mode 100644 x-pack/test/functional/services/monitoring/enterprise_search_summary_status.js
create mode 100644 x-pack/test/rule_registry/common/constants.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/cleanup_target_indices.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/create_alert.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/create_apm_metric_index.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/create_transaction_metric.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/delete_alert.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/get_alerts_target_indices.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/index.ts
create mode 100644 x-pack/test/rule_registry/common/lib/helpers/wait_until_next_execution.ts
create mode 100644 x-pack/test/rule_registry/common/types.ts
create mode 100644 x-pack/test/rule_registry/spaces_only/config_basic.ts
create mode 100644 x-pack/test/rule_registry/spaces_only/tests/basic/bootstrap.ts
create mode 100644 x-pack/test/rule_registry/spaces_only/tests/basic/index.ts
create mode 100644 x-pack/test/rule_registry/spaces_only/tests/trial/__snapshots__/create_rule.snap
create mode 100644 x-pack/test/rule_registry/spaces_only/tests/trial/create_rule.ts
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index a64ab63494b35..61369a37ec3c2 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -177,6 +177,8 @@
/x-pack/test/functional/services/ml/ @elastic/ml-ui
/x-pack/test/functional_basic/apps/ml/ @elastic/ml-ui
/x-pack/test/functional_with_es_ssl/apps/ml/ @elastic/ml-ui
+/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ml_rule_types/ @elastic/ml-ui
+/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/transform_rule_types/ @elastic/ml-ui
# ML team owns and maintains the transform plugin despite it living in the Data management section.
/x-pack/plugins/transform/ @elastic/ml-ui
diff --git a/NOTICE.txt b/NOTICE.txt
index 4ede43610ca7b..1694193892e16 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -295,7 +295,7 @@ MIT License http://www.opensource.org/licenses/mit-license
---
This product includes code that is adapted from mapbox-gl-js, which is
available under a "BSD-3-Clause" license.
-https://github.com/mapbox/mapbox-gl-js/blob/master/src/util/image.js
+https://github.com/mapbox/mapbox-gl-js/blob/v1.13.2/src/util/image.js
Copyright (c) 2016, Mapbox
diff --git a/docs/developer/getting-started/debugging.asciidoc b/docs/developer/getting-started/debugging.asciidoc
index f3308a1267386..1254462d2e4ea 100644
--- a/docs/developer/getting-started/debugging.asciidoc
+++ b/docs/developer/getting-started/debugging.asciidoc
@@ -130,71 +130,3 @@ Once you're finished, you can stop Kibana normally, then stop the {es} and APM s
----
./scripts/compose.py stop
----
-
-=== Using {kib} server logs
-{kib} Logs is a great way to see what's going on in your application and to debug performance issues. Navigating through a large number of generated logs can be overwhelming, and following are some techniques that you can use to optimize the process.
-
-Start by defining a problem area that you are interested in. For example, you might be interested in seeing how a particular {kib} Plugin is performing, so no need to gather logs for all of {kib}. Or you might want to focus on a particular feature, such as requests from the {kib} server to the {es} server.
-Depending on your needs, you can configure {kib} to generate logs for a specific feature.
-[source,yml]
-----
-logging:
- appenders:
- file:
- type: file
- fileName: ./kibana.log
- layout:
- type: json
-
-### gather all the Kibana logs into a file
-logging.root:
- appenders: [file]
- level: all
-
-### or gather a subset of the logs
-logging.loggers:
- ### responses to an HTTP request
- - name: http.server.response
- level: debug
- appenders: [file]
- ### result of a query to the Elasticsearch server
- - name: elasticsearch.query
- level: debug
- appenders: [file]
- ### logs generated by my plugin
- - name: plugins.myPlugin
- level: debug
- appenders: [file]
-----
-WARNING: Kibana's `file` appender is configured to produce logs in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format. It's the only format that includes the meta information necessary for https://www.elastic.co/guide/en/apm/agent/nodejs/current/log-correlation.html[log correlation] out-of-the-box.
-
-The next step is to define what https://www.elastic.co/observability[observability tools] are available.
-For a better experience, set up an https://www.elastic.co/guide/en/apm/get-started/current/observability-integrations.html[Observability integration] provided by Elastic to debug your application with the <>
-To debug something quickly without setting up additional tooling, you can work with <>
-
-[[debugging-logs-apm-ui]]
-==== APM UI
-*Prerequisites* {kib} logs are configured to be in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format to include tracing identifiers.
-
-To debug {kib} with the APM UI, you must set up the APM infrastructure. You can find instructions for the setup process
-https://www.elastic.co/guide/en/apm/get-started/current/observability-integrations.html[on the Observability integrations page].
-
-Once you set up the APM infrastructure, you can enable the APM agent and put {kib} under load to collect APM events. To analyze the collected metrics and logs, use the APM UI as demonstrated https://www.elastic.co/guide/en/kibana/master/transactions.html#transaction-trace-sample[in the docs].
-
-[[plain-kibana-logs]]
-==== Plain {kib} logs
-*Prerequisites* {kib} logs are configured to be in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format to include tracing identifiers.
-
-Open {kib} Logs and search for an operation you are interested in.
-For example, suppose you want to investigate the response times for queries to the `/api/telemetry/v2/clusters/_stats` {kib} endpoint.
-Open Kibana Logs and search for the HTTP server response for the endpoint. It looks similar to the following (some fields are omitted for brevity).
-[source,json]
-----
-{
- "message":"POST /api/telemetry/v2/clusters/_stats 200 1014ms - 43.2KB",
- "log":{"level":"DEBUG","logger":"http.server.response"},
- "trace":{"id":"9b99131a6f66587971ef085ef97dfd07"},
- "transaction":{"id":"d0c5bbf14f5febca"}
-}
-----
-You are interested in the https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html#field-trace-id[trace.id] field, which is a unique identifier of a trace. The `trace.id` provides a way to group multiple events, like transactions, which belong together. You can search for `"trace":{"id":"9b99131a6f66587971ef085ef97dfd07"}` to get all the logs that belong to the same trace. This enables you to see how many {es} requests were triggered during the `9b99131a6f66587971ef085ef97dfd07` trace, what they looked like, what {es} endpoints were hit, and so on.
diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc
index e997c0bc68cde..3d9de2d35b500 100644
--- a/docs/developer/plugin-list.asciidoc
+++ b/docs/developer/plugin-list.asciidoc
@@ -540,6 +540,11 @@ Elastic.
|Add tagging capability to saved objects
+|{kib-repo}blob/{branch}/x-pack/plugins/screenshotting/README.md[screenshotting]
+|This plugin provides functionality to take screenshots of the Kibana pages.
+It uses Chromium and Puppeteer underneath to run the browser in headless mode.
+
+
|{kib-repo}blob/{branch}/x-pack/plugins/searchprofiler/README.md[searchprofiler]
|The search profiler consumes the Profile API
by sending a search API with profile: true enabled in the request body. The response contains
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
index 403d8594999a7..63c29df44019d 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
@@ -88,6 +88,7 @@ readonly links: {
readonly usersAccess: string;
};
readonly workplaceSearch: {
+ readonly apiKeys: string;
readonly box: string;
readonly confluenceCloud: string;
readonly confluenceServer: string;
@@ -289,7 +290,14 @@ readonly links: {
}>;
readonly watcher: Record;
readonly ccs: Record;
- readonly plugins: Record;
+ readonly plugins: {
+ azureRepo: string;
+ gcsRepo: string;
+ hdfsRepo: string;
+ s3Repo: string;
+ snapshotRestoreRepos: string;
+ mapperSize: string;
+ };
readonly snapshotRestore: Record;
readonly ingest: Record;
readonly fleet: Readonly<{
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
index 131d4452c980c..a9828f04672e9 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
@@ -17,5 +17,5 @@ export interface DocLinksStart
| --- | --- | --- |
| [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | string | |
| [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | string | |
-| [links](./kibana-plugin-core-public.doclinksstart.links.md) | { readonly settings: string; readonly elasticStackGetStarted: string; readonly upgrade: { readonly upgradingElasticStack: string; }; readonly apm: { readonly kibanaSettings: string; readonly supportedServiceMaps: string; readonly customLinks: string; readonly droppedTransactionSpans: string; readonly upgrading: string; readonly metaData: string; }; readonly canvas: { readonly guide: string; }; readonly cloud: { readonly indexManagement: string; }; readonly dashboard: { readonly guide: string; readonly drilldowns: string; readonly drilldownsTriggerPicker: string; readonly urlDrilldownTemplateSyntax: string; readonly urlDrilldownVariables: string; }; readonly discover: Record<string, string>; readonly filebeat: { readonly base: string; readonly installation: string; readonly configuration: string; readonly elasticsearchOutput: string; readonly elasticsearchModule: string; readonly startup: string; readonly exportedFields: string; readonly suricataModule: string; readonly zeekModule: string; }; readonly auditbeat: { readonly base: string; readonly auditdModule: string; readonly systemModule: string; }; readonly metricbeat: { readonly base: string; readonly configure: string; readonly httpEndpoint: string; readonly install: string; readonly start: string; }; readonly appSearch: { readonly apiRef: string; readonly apiClients: string; readonly apiKeys: string; readonly authentication: string; readonly crawlRules: string; readonly curations: string; readonly duplicateDocuments: string; readonly entryPoints: string; readonly guide: string; readonly indexingDocuments: string; readonly indexingDocumentsSchema: string; readonly logSettings: string; readonly metaEngines: string; readonly precisionTuning: string; readonly relevanceTuning: string; readonly resultSettings: string; readonly searchUI: string; readonly security: string; readonly synonyms: string; readonly webCrawler: string; readonly webCrawlerEventLogs: string; }; readonly enterpriseSearch: { readonly configuration: string; readonly licenseManagement: string; readonly mailService: string; readonly usersAccess: string; }; readonly workplaceSearch: { readonly box: string; readonly confluenceCloud: string; readonly confluenceServer: string; readonly customSources: string; readonly customSourcePermissions: string; readonly documentPermissions: string; readonly dropbox: string; readonly externalIdentities: string; readonly gitHub: string; readonly gettingStarted: string; readonly gmail: string; readonly googleDrive: string; readonly indexingSchedule: string; readonly jiraCloud: string; readonly jiraServer: string; readonly oneDrive: string; readonly permissions: string; readonly salesforce: string; readonly security: string; readonly serviceNow: string; readonly sharePoint: string; readonly slack: string; readonly synch: string; readonly zendesk: string; }; readonly heartbeat: { readonly base: string; }; readonly libbeat: { readonly getStarted: string; }; readonly logstash: { readonly base: string; }; readonly functionbeat: { readonly base: string; }; readonly winlogbeat: { readonly base: string; }; readonly aggs: { readonly composite: string; readonly composite\_missing\_bucket: string; readonly date\_histogram: string; readonly date\_range: string; readonly date\_format\_pattern: string; readonly filter: string; readonly filters: string; readonly geohash\_grid: string; readonly histogram: string; readonly ip\_range: string; readonly range: string; readonly significant\_terms: string; readonly terms: string; readonly terms\_doc\_count\_error: string; readonly avg: string; readonly avg\_bucket: string; readonly max\_bucket: string; readonly min\_bucket: string; readonly sum\_bucket: string; readonly cardinality: string; readonly count: string; readonly cumulative\_sum: string; readonly derivative: string; readonly geo\_bounds: string; readonly geo\_centroid: string; readonly max: string; readonly median: string; readonly min: string; readonly moving\_avg: string; readonly percentile\_ranks: string; readonly serial\_diff: string; readonly std\_dev: string; readonly sum: string; readonly top\_hits: string; }; readonly runtimeFields: { readonly overview: string; readonly mapping: string; }; readonly scriptedFields: { readonly scriptFields: string; readonly scriptAggs: string; readonly painless: string; readonly painlessApi: string; readonly painlessLangSpec: string; readonly painlessSyntax: string; readonly painlessWalkthrough: string; readonly luceneExpressions: string; }; readonly search: { readonly sessions: string; readonly sessionLimits: string; }; readonly indexPatterns: { readonly introduction: string; readonly fieldFormattersNumber: string; readonly fieldFormattersString: string; readonly runtimeFields: string; }; readonly addData: string; readonly kibana: string; readonly upgradeAssistant: { readonly overview: string; readonly batchReindex: string; readonly remoteReindex: string; }; readonly rollupJobs: string; readonly elasticsearch: Record<string, string>; readonly siem: { readonly privileges: string; readonly guide: string; readonly gettingStarted: string; readonly ml: string; readonly ruleChangeLog: string; readonly detectionsReq: string; readonly networkMap: string; readonly troubleshootGaps: string; }; readonly securitySolution: { readonly trustedApps: string; }; readonly query: { readonly eql: string; readonly kueryQuerySyntax: string; readonly luceneQuerySyntax: string; readonly percolate: string; readonly queryDsl: string; }; readonly date: { readonly dateMath: string; readonly dateMathIndexNames: string; }; readonly management: Record<string, string>; readonly ml: Record<string, string>; readonly transforms: Record<string, string>; readonly visualize: Record<string, string>; readonly apis: Readonly<{ bulkIndexAlias: string; byteSizeUnits: string; createAutoFollowPattern: string; createFollower: string; createIndex: string; createSnapshotLifecyclePolicy: string; createRoleMapping: string; createRoleMappingTemplates: string; createRollupJobsRequest: string; createApiKey: string; createPipeline: string; createTransformRequest: string; cronExpressions: string; executeWatchActionModes: string; indexExists: string; openIndex: string; putComponentTemplate: string; painlessExecute: string; painlessExecuteAPIContexts: string; putComponentTemplateMetadata: string; putSnapshotLifecyclePolicy: string; putIndexTemplateV1: string; putWatch: string; simulatePipeline: string; timeUnits: string; updateTransform: string; }>; readonly observability: Readonly<{ guide: string; infrastructureThreshold: string; logsThreshold: string; metricsThreshold: string; monitorStatus: string; monitorUptime: string; tlsCertificate: string; uptimeDurationAnomaly: string; }>; readonly alerting: Record<string, string>; readonly maps: Readonly<{ guide: string; importGeospatialPrivileges: string; gdalTutorial: string; }>; readonly monitoring: Record<string, string>; readonly security: Readonly<{ apiKeyServiceSettings: string; clusterPrivileges: string; elasticsearchSettings: string; elasticsearchEnableSecurity: string; elasticsearchEnableApiKeys: string; indicesPrivileges: string; kibanaTLS: string; kibanaPrivileges: string; mappingRoles: string; mappingRolesFieldRules: string; runAsPrivilege: string; }>; readonly spaces: Readonly<{ kibanaLegacyUrlAliases: string; kibanaDisableLegacyUrlAliasesApi: string; }>; readonly watcher: Record<string, string>; readonly ccs: Record<string, string>; readonly plugins: Record<string, string>; readonly snapshotRestore: Record<string, string>; readonly ingest: Record<string, string>; readonly fleet: Readonly<{ beatsAgentComparison: string; guide: string; fleetServer: string; fleetServerAddFleetServer: string; settings: string; settingsFleetServerHostSettings: string; settingsFleetServerProxySettings: string; troubleshooting: string; elasticAgent: string; datastreams: string; datastreamsNamingScheme: string; installElasticAgent: string; installElasticAgentStandalone: string; upgradeElasticAgent: string; upgradeElasticAgent712lower: string; learnMoreBlog: string; apiKeysLearnMore: string; onPremRegistry: string; }>; readonly ecs: { readonly guide: string; }; readonly clients: { readonly guide: string; readonly goOverview: string; readonly javaIndex: string; readonly jsIntro: string; readonly netGuide: string; readonly perlGuide: string; readonly phpGuide: string; readonly pythonGuide: string; readonly rubyOverview: string; readonly rustGuide: string; }; readonly endpoints: { readonly troubleshooting: string; }; } | |
+| [links](./kibana-plugin-core-public.doclinksstart.links.md) | { readonly settings: string; readonly elasticStackGetStarted: string; readonly upgrade: { readonly upgradingElasticStack: string; }; readonly apm: { readonly kibanaSettings: string; readonly supportedServiceMaps: string; readonly customLinks: string; readonly droppedTransactionSpans: string; readonly upgrading: string; readonly metaData: string; }; readonly canvas: { readonly guide: string; }; readonly cloud: { readonly indexManagement: string; }; readonly dashboard: { readonly guide: string; readonly drilldowns: string; readonly drilldownsTriggerPicker: string; readonly urlDrilldownTemplateSyntax: string; readonly urlDrilldownVariables: string; }; readonly discover: Record<string, string>; readonly filebeat: { readonly base: string; readonly installation: string; readonly configuration: string; readonly elasticsearchOutput: string; readonly elasticsearchModule: string; readonly startup: string; readonly exportedFields: string; readonly suricataModule: string; readonly zeekModule: string; }; readonly auditbeat: { readonly base: string; readonly auditdModule: string; readonly systemModule: string; }; readonly metricbeat: { readonly base: string; readonly configure: string; readonly httpEndpoint: string; readonly install: string; readonly start: string; }; readonly appSearch: { readonly apiRef: string; readonly apiClients: string; readonly apiKeys: string; readonly authentication: string; readonly crawlRules: string; readonly curations: string; readonly duplicateDocuments: string; readonly entryPoints: string; readonly guide: string; readonly indexingDocuments: string; readonly indexingDocumentsSchema: string; readonly logSettings: string; readonly metaEngines: string; readonly recisionTuning: string; readonly relevanceTuning: string; readonly resultSettings: string; readonly searchUI: string; readonly security: string; readonly synonyms: string; readonly webCrawler: string; readonly webCrawlerEventLogs: string; }; readonly enterpriseSearch: { readonly configuration: string; readonly licenseManagement: string; readonly mailService: string; readonly usersAccess: string; }; readonly workplaceSearch: { readonly apiKeys: string; readonly box: string; readonly confluenceCloud: string; readonly confluenceServer: string; readonly customSources: string; readonly customSourcePermissions: string; readonly documentPermissions: string; readonly dropbox: string; readonly externalIdentities: string; readonly gitHub: string; readonly gettingStarted: string; readonly gmail: string; readonly googleDrive: string; readonly indexingSchedule: string; readonly jiraCloud: string; readonly jiraServer: string; readonly oneDrive: string; readonly permissions: string; readonly salesforce: string; readonly security: string; readonly serviceNow: string; readonly sharePoint: string; readonly slack: string; readonly synch: string; readonly zendesk: string; }; readonly heartbeat: { readonly base: string; }; readonly libbeat: { readonly getStarted: string; }; readonly logstash: { readonly base: string; }; readonly functionbeat: { readonly base: string; }; readonly winlogbeat: { readonly base: string; }; readonly aggs: { readonly composite: string; readonly composite\_missing\_bucket: string; readonly date\_histogram: string; readonly date\_range: string; readonly date\_format\_pattern: string; readonly filter: string; readonly filters: string; readonly geohash\_grid: string; readonly histogram: string; readonly ip\_range: string; readonly range: string; readonly significant\_terms: string; readonly terms: string; readonly terms\_doc\_count\_error: string; readonly avg: string; readonly avg\_bucket: string; readonly max\_bucket: string; readonly min\_bucket: string; readonly sum\_bucket: string; readonly cardinality: string; readonly count: string; readonly cumulative\_sum: string; readonly derivative: string; readonly geo\_bounds: string; readonly geo\_centroid: string; readonly max: string; readonly median: string; readonly min: string; readonly moving\_avg: string; readonly percentile\_ranks: string; readonly serial\_diff: string; readonly std\_dev: string; readonly sum: string; readonly top\_hits: string; }; readonly runtimeFields: { readonly overview: string; readonly mapping: string; }; readonly scriptedFields: { readonly scriptFields: string; readonly scriptAggs: string; readonly painless: string; readonly painlessApi: string; readonly painlessLangSpec: string; readonly painlessSyntax: string; readonly painlessWalkthrough: string; readonly luceneExpressions: string; }; readonly search: { readonly sessions: string; readonly sessionLimits: string; }; readonly indexPatterns: { readonly introduction: string; readonly fieldFormattersNumber: string; readonly fieldFormattersString: string; readonly runtimeFields: string; }; readonly addData: string; readonly kibana: string; readonly upgradeAssistant: { readonly overview: string; readonly batchReindex: string; readonly remoteReindex: string; }; readonly rollupJobs: string; readonly elasticsearch: Record<string, string>; readonly siem: { readonly privileges: string; readonly guide: string; readonly gettingStarted: string; readonly ml: string; readonly ruleChangeLog: string; readonly detectionsReq: string; readonly networkMap: string; readonly troubleshootGaps: string; }; readonly securitySolution: { readonly trustedApps: string; }; readonly query: { readonly eql: string; readonly kueryQuerySyntax: string; readonly luceneQuerySyntax: string; readonly percolate: string; readonly queryDsl: string; }; readonly date: { readonly dateMath: string; readonly dateMathIndexNames: string; }; readonly management: Record<string, string>; readonly ml: Record<string, string>; readonly transforms: Record<string, string>; readonly visualize: Record<string, string>; readonly apis: Readonly<{ bulkIndexAlias: string; byteSizeUnits: string; createAutoFollowPattern: string; createFollower: string; createIndex: string; createSnapshotLifecyclePolicy: string; createRoleMapping: string; createRoleMappingTemplates: string; createRollupJobsRequest: string; createApiKey: string; createPipeline: string; createTransformRequest: string; cronExpressions: string; executeWatchActionModes: string; indexExists: string; openIndex: string; putComponentTemplate: string; painlessExecute: string; painlessExecuteAPIContexts: string; putComponentTemplateMetadata: string; putSnapshotLifecyclePolicy: string; putIndexTemplateV1: string; putWatch: string; simulatePipeline: string; timeUnits: string; updateTransform: string; }>; readonly observability: Readonly<{ guide: string; infrastructureThreshold: string; logsThreshold: string; metricsThreshold: string; monitorStatus: string; monitorUptime: string; tlsCertificate: string; uptimeDurationAnomaly: string; }>; readonly alerting: Record<string, string>; readonly maps: Readonly<{ guide: string; importGeospatialPrivileges: string; gdalTutorial: string; }>; readonly monitoring: Record<string, string>; readonly security: Readonly<{ apiKeyServiceSettings: string; clusterPrivileges: string; elasticsearchSettings: string; elasticsearchEnableSecurity: string; elasticsearchEnableApiKeys: string; indicesPrivileges: string; kibanaTLS: string; kibanaPrivileges: string; mappingRoles: string; mappingRolesFieldRules: string; runAsPrivilege: string; }>; readonly spaces: Readonly<{ kibanaLegacyUrlAliases: string; kibanaDisableLegacyUrlAliasesApi: string; }>; readonly watcher: Record<string, string>; readonly ccs: Record<string, string>; readonly plugins: Record<string, string>; readonly snapshotRestore: Record<string, string>; readonly ingest: Record<string, string>; readonly fleet: Readonly<{ beatsAgentComparison: string; guide: string; fleetServer: string; fleetServerAddFleetServer: string; settings: string; settingsFleetServerHostSettings: string; settingsFleetServerProxySettings: string; troubleshooting: string; elasticAgent: string; datastreams: string; datastreamsNamingScheme: string; installElasticAgent: string; installElasticAgentStandalone: string; upgradeElasticAgent: string; upgradeElasticAgent712lower: string; learnMoreBlog: string; apiKeysLearnMore: string; onPremRegistry: string; }>; readonly ecs: { readonly guide: string; }; readonly clients: { readonly guide: string; readonly goOverview: string; readonly javaIndex: string; readonly jsIntro: string; readonly netGuide: string; readonly perlGuide: string; readonly phpGuide: string; readonly pythonGuide: string; readonly rubyOverview: string; readonly rustGuide: string; }; readonly endpoints: { readonly troubleshooting: string; }; } | |
diff --git a/docs/osquery/osquery.asciidoc b/docs/osquery/osquery.asciidoc
index 396135d8d1751..500dc6959fc00 100644
--- a/docs/osquery/osquery.asciidoc
+++ b/docs/osquery/osquery.asciidoc
@@ -288,13 +288,21 @@ This is useful for teams who need in-depth and detailed control.
[float]
=== Customize Osquery configuration
-By default, all Osquery Manager integrations share the same osquery configuration. However, you can customize how Osquery is configured by editing the Osquery Manager integration for each agent policy
+experimental[] By default, all Osquery Manager integrations share the same osquery configuration. However, you can customize how Osquery is configured by editing the Osquery Manager integration for each agent policy
you want to adjust. The custom configuration is then applied to all agents in the policy.
This powerful feature allows you to configure
https://osquery.readthedocs.io/en/stable/deployment/file-integrity-monitoring[File Integrity Monitoring], https://osquery.readthedocs.io/en/stable/deployment/process-auditing[Process auditing],
and https://osquery.readthedocs.io/en/stable/deployment/configuration/#configuration-specification[others].
-IMPORTANT: Take caution when editing this configuration. The changes you make are distributed to all agents in the policy.
+[IMPORTANT]
+=========================
+
+* Take caution when editing this configuration. The changes you make are distributed to all agents in the policy.
+
+* Take caution when editing `packs` using the Advanced *Osquery config* field.
+Any changes you make to `packs` from this field are not reflected in the UI on the Osquery *Packs* page in {kib}, however, these changes are deployed to agents in the policy.
+While this allows you to use advanced Osquery functionality like pack discovery queries, you do lose the ability to manage packs defined this way from the Osquery *Packs* page.
+=========================
. From the {kib} main menu, click *Fleet*, then the *Agent policies* tab.
@@ -315,6 +323,16 @@ IMPORTANT: Take caution when editing this configuration. The changes you make ar
* (Optional) To load a full configuration file, drag and drop an Osquery `.conf` file into the area at the bottom of the page.
. Click *Save integration* to apply the custom configuration to all agents in the policy.
++
+As an example, the following configuration disables two tables.
++
+```ts
+{
+ "options":{
+ "disable_tables":"curl,process_envs"
+ }
+}
+```
[float]
=== Upgrade Osquery versions
diff --git a/docs/settings/apm-settings.asciidoc b/docs/settings/apm-settings.asciidoc
index 77a250a14f929..27ea7f4dc7cd0 100644
--- a/docs/settings/apm-settings.asciidoc
+++ b/docs/settings/apm-settings.asciidoc
@@ -101,8 +101,8 @@ Changing these settings may disable features of the APM App.
| `xpack.apm.indices.sourcemap` {ess-icon}
| Matcher for all source map indices. Defaults to `apm-*`.
-| `xpack.apm.autocreateApmIndexPattern` {ess-icon}
- | Set to `false` to disable the automatic creation of the APM index pattern when the APM app is opened. Defaults to `true`.
+| `xpack.apm.autoCreateApmDataView` {ess-icon}
+ | Set to `false` to disable the automatic creation of the APM data view when the APM app is opened. Defaults to `true`.
|===
-// end::general-apm-settings[]
\ No newline at end of file
+// end::general-apm-settings[]
diff --git a/docs/settings/fleet-settings.asciidoc b/docs/settings/fleet-settings.asciidoc
index f0dfeb619bb38..a088f31937cc8 100644
--- a/docs/settings/fleet-settings.asciidoc
+++ b/docs/settings/fleet-settings.asciidoc
@@ -87,6 +87,7 @@ Optional properties are:
`data_output_id`:: ID of the output to send data (Need to be identical to `monitoring_output_id`)
`monitoring_output_id`:: ID of the output to send monitoring data. (Need to be identical to `data_output_id`)
`package_policies`:: List of integration policies to add to this policy.
+ `id`::: Unique ID of the integration policy. The ID may be a number or string.
`name`::: (required) Name of the integration policy.
`package`::: (required) Integration that this policy configures
`name`:::: Name of the integration associated with this policy.
@@ -128,6 +129,7 @@ xpack.fleet.agentPolicies:
- package:
name: system
name: System Integration
+ id: preconfigured-system
inputs:
- type: system/metrics
enabled: true
diff --git a/docs/settings/monitoring-settings.asciidoc b/docs/settings/monitoring-settings.asciidoc
index d8bc26b7b3987..8bc98a028b8f6 100644
--- a/docs/settings/monitoring-settings.asciidoc
+++ b/docs/settings/monitoring-settings.asciidoc
@@ -72,6 +72,9 @@ For more information, see
| `monitoring.ui.elasticsearch.ssl`
| Shares the same configuration as <>. These settings configure encrypted communication between {kib} and the monitoring cluster.
+| `monitoring.cluster_alerts.allowedSpaces` {ess-icon}
+ | Specifies the spaces where cluster Stack Monitoring alerts can be created. You must specify all spaces where you want to generate alerts, including the default space. Defaults to `[ "default" ]`.
+
|===
[float]
diff --git a/docs/settings/spaces-settings.asciidoc b/docs/settings/spaces-settings.asciidoc
index dd37943101145..3eb91a0d884ef 100644
--- a/docs/settings/spaces-settings.asciidoc
+++ b/docs/settings/spaces-settings.asciidoc
@@ -12,11 +12,3 @@ The maximum number of spaces that you can use with the {kib} instance. Some {kib
return all spaces using a single `_search` from {es}, so you must
configure this setting lower than the `index.max_result_window` in {es}.
The default is `1000`.
-
-`monitoring.cluster_alerts.allowedSpaces` {ess-icon}::
-Specifies the spaces where cluster alerts are automatically generated.
-You must specify all spaces where you want to generate alerts, including the default space.
-When the default space is unspecified, {kib} is unable to generate an alert for the default space.
-{es} clusters that run on {es} services are all containers. To send monitoring data
-from your self-managed {es} installation to {es} services, set to `false`.
-The default is `true`.
diff --git a/docs/settings/url-drilldown-settings.asciidoc b/docs/settings/url-drilldown-settings.asciidoc
index 702829ec34dcc..36dbabbe7fe1e 100644
--- a/docs/settings/url-drilldown-settings.asciidoc
+++ b/docs/settings/url-drilldown-settings.asciidoc
@@ -6,16 +6,13 @@
Configure the URL drilldown settings in your `kibana.yml` configuration file.
-[cols="2*<"]
-|===
-| [[external-URL-policy]] `externalUrl.policy`
- | Configures the external URL policies. URL drilldowns respect the global *External URL* service, which you can use to deny or allow external URLs.
+[[external-URL-policy]] `externalUrl.policy`::
+Configures the external URL policies. URL drilldowns respect the global *External URL* service, which you can use to deny or allow external URLs.
By default all external URLs are allowed.
-|===
-
-For example, to allow external URLs only to the `example.com` domain with the `https` scheme, except for the `danger.example.com` sub-domain,
++
+For example, to allow only external URLs to the `example.com` domain with the `https` scheme, except for the `danger.example.com` sub-domain,
which is denied even when `https` scheme is used:
-
++
["source","yml"]
-----------
externalUrl.policy:
@@ -25,4 +22,3 @@ externalUrl.policy:
host: example.com
protocol: https
-----------
-
diff --git a/docs/setup/docker.asciidoc b/docs/setup/docker.asciidoc
index 68b308c08aeac..0aa6c680a7761 100644
--- a/docs/setup/docker.asciidoc
+++ b/docs/setup/docker.asciidoc
@@ -152,7 +152,7 @@ services:
==== Persist the {kib} keystore
-By default, {kib] auto-generates a keystore file for secure settings at startup. To persist your {kibana-ref}/secure-settings.html[secure settings], use the `kibana-keystore` utility to bind-mount the parent directory of the keystore to the container. For example:
+By default, {kib} auto-generates a keystore file for secure settings at startup. To persist your {kibana-ref}/secure-settings.html[secure settings], use the `kibana-keystore` utility to bind-mount the parent directory of the keystore to the container. For example:
["source","sh",subs="attributes"]
----
diff --git a/docs/setup/install/deb.asciidoc b/docs/setup/install/deb.asciidoc
index 3f600d7c2bdbc..8e8c43ff8a15d 100644
--- a/docs/setup/install/deb.asciidoc
+++ b/docs/setup/install/deb.asciidoc
@@ -188,9 +188,9 @@ locations for a Debian-based system:
| path.data
| logs
- | Logs files location
- | /var/log/kibana
- | path.logs
+ | Logs files location
+ | /var/log/kibana
+ | path.logs
| plugins
| Plugin files location. Each plugin will be contained in a subdirectory.
diff --git a/docs/setup/install/rpm.asciidoc b/docs/setup/install/rpm.asciidoc
index 329af9af0ccf7..0ef714c73b9ba 100644
--- a/docs/setup/install/rpm.asciidoc
+++ b/docs/setup/install/rpm.asciidoc
@@ -174,7 +174,6 @@ locations for an RPM-based system:
| Configuration files including `kibana.yml`
| /etc/kibana
| <>
- d|
| data
| The location of the data files written to disk by Kibana and its plugins
@@ -182,9 +181,9 @@ locations for an RPM-based system:
| path.data
| logs
- | Logs files location
- | /var/log/kibana
- | path.logs
+ | Logs files location
+ | /var/log/kibana
+ | path.logs
| plugins
| Plugin files location. Each plugin will be contained in a subdirectory.
diff --git a/docs/setup/install/targz.asciidoc b/docs/setup/install/targz.asciidoc
index d9849811a7455..1d8c61a6e9a07 100644
--- a/docs/setup/install/targz.asciidoc
+++ b/docs/setup/install/targz.asciidoc
@@ -125,7 +125,7 @@ important data later on.
| home
| Kibana home directory or `$KIBANA_HOME`
d| Directory created by unpacking the archive
- d|
+ |
| bin
| Binary scripts including `kibana` to start the Kibana server
@@ -137,7 +137,6 @@ important data later on.
| Configuration files including `kibana.yml`
| $KIBANA_HOME\config
| <>
- d|
| data
| The location of the data files written to disk by Kibana and its plugins
diff --git a/docs/setup/upgrade.asciidoc b/docs/setup/upgrade.asciidoc
index a139b8a50ca4d..c828b837d8efd 100644
--- a/docs/setup/upgrade.asciidoc
+++ b/docs/setup/upgrade.asciidoc
@@ -44,13 +44,20 @@ a|
[[upgrade-before-you-begin]]
=== Before you begin
-WARNING: {kib} automatically runs upgrade migrations when required. To roll back to an earlier version in case of an upgrade failure, you **must** have a {ref}/snapshot-restore.html[backup snapshot] available. This snapshot must include the `kibana` feature state or all `kibana*` indices. For more information see <>.
+[WARNING]
+====
+{kib} automatically runs upgrade migrations when required. To roll back to an
+earlier version in case of an upgrade failure, you **must** have a
+{ref}/snapshot-restore.html[backup snapshot] that includes the `kibana` feature
+state. Snapshots include this feature state by default.
+
+For more information, refer to <>.
+====
Before you upgrade {kib}:
* Consult the <>.
-* {ref}/snapshots-take-snapshot.html[Take a snapshot] of your data. To roll back to an earlier version, the snapshot must include the `kibana` feature state or all `.kibana*` indices.
-* Although not a requirement for rollbacks, we recommend taking a snapshot of all {kib} indices created by the plugins you use such as the `.reporting*` indices created by the reporting plugin.
+* {ref}/snapshots-take-snapshot.html[Take a snapshot] of your data. To roll back to an earlier version, the snapshot must include the `kibana` feature state.
* Before you upgrade production servers, test the upgrades in a dev environment.
* See <> for common reasons upgrades fail and how to prevent these.
* If you are using custom plugins, check that a compatible version is
diff --git a/docs/setup/upgrade/upgrade-migrations.asciidoc b/docs/setup/upgrade/upgrade-migrations.asciidoc
index c47c2c1745e94..e9e1b757fd71d 100644
--- a/docs/setup/upgrade/upgrade-migrations.asciidoc
+++ b/docs/setup/upgrade/upgrade-migrations.asciidoc
@@ -151,17 +151,18 @@ In order to rollback after a failed upgrade migration, the saved object indices
[float]
===== Rollback by restoring a backup snapshot:
-1. Before proceeding, {ref}/snapshots-take-snapshot.html[take a snapshot] that contains the `kibana` feature state or all `.kibana*` indices.
+1. Before proceeding, {ref}/snapshots-take-snapshot.html[take a snapshot] that contains the `kibana` feature state.
+ Snapshots include this feature state by default.
2. Shutdown all {kib} instances to be 100% sure that there are no instances currently performing a migration.
3. Delete all saved object indices with `DELETE /.kibana*`
-4. {ref}/snapshots-restore-snapshot.html[Restore] the `kibana` feature state or all `.kibana* indices and their aliases from the snapshot.
+4. {ref}/snapshots-restore-snapshot.html[Restore] the `kibana` feature state from the snapshot.
5. Start up all {kib} instances on the older version you wish to rollback to.
[float]
===== (Not recommended) Rollback without a backup snapshot:
1. Shutdown all {kib} instances to be 100% sure that there are no {kib} instances currently performing a migration.
-2. {ref}/snapshots-take-snapshot.html[Take a snapshot] that includes the `kibana` feature state or all `.kibana*` indices.
+2. {ref}/snapshots-take-snapshot.html[Take a snapshot] that includes the `kibana` feature state. Snapshots include this feature state by default.
3. Delete the version specific indices created by the failed upgrade migration. E.g. if you wish to rollback from a failed upgrade to v7.12.0 `DELETE /.kibana_7.12.0_*,.kibana_task_manager_7.12.0_*`
4. Inspect the output of `GET /_cat/aliases`. If either the `.kibana` and/or `.kibana_task_manager` alias is missing, these will have to be created manually. Find the latest index from the output of `GET /_cat/indices` and create the missing alias to point to the latest index. E.g. if the `.kibana` alias was missing and the latest index is `.kibana_3` create a new alias with `POST /.kibana_3/_aliases/.kibana`.
5. Remove the write block from the rollback indices. `PUT /.kibana,.kibana_task_manager/_settings {"index.blocks.write": false}`
diff --git a/docs/user/index.asciidoc b/docs/user/index.asciidoc
index 75d0da1c597b6..57668b3f5bccf 100644
--- a/docs/user/index.asciidoc
+++ b/docs/user/index.asciidoc
@@ -45,3 +45,5 @@ include::management.asciidoc[]
include::api.asciidoc[]
include::plugins.asciidoc[]
+
+include::troubleshooting.asciidoc[]
diff --git a/docs/user/troubleshooting.asciidoc b/docs/user/troubleshooting.asciidoc
new file mode 100644
index 0000000000000..8b32471c98d86
--- /dev/null
+++ b/docs/user/troubleshooting.asciidoc
@@ -0,0 +1,70 @@
+[[kibana-troubleshooting]]
+== Troubleshooting
+
+=== Using {kib} server logs
+{kib} Logs is a great way to see what's going on in your application and to debug performance issues. Navigating through a large number of generated logs can be overwhelming, and following are some techniques that you can use to optimize the process.
+
+Start by defining a problem area that you are interested in. For example, you might be interested in seeing how a particular {kib} Plugin is performing, so no need to gather logs for all of {kib}. Or you might want to focus on a particular feature, such as requests from the {kib} server to the {es} server.
+Depending on your needs, you can configure {kib} to generate logs for a specific feature.
+[source,yml]
+----
+logging:
+ appenders:
+ file:
+ type: file
+ fileName: ./kibana.log
+ layout:
+ type: json
+
+### gather all the Kibana logs into a file
+logging.root:
+ appenders: [file]
+ level: all
+
+### or gather a subset of the logs
+logging.loggers:
+ ### responses to an HTTP request
+ - name: http.server.response
+ level: debug
+ appenders: [file]
+ ### result of a query to the Elasticsearch server
+ - name: elasticsearch.query
+ level: debug
+ appenders: [file]
+ ### logs generated by my plugin
+ - name: plugins.myPlugin
+ level: debug
+ appenders: [file]
+----
+WARNING: Kibana's `file` appender is configured to produce logs in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format. It's the only format that includes the meta information necessary for https://www.elastic.co/guide/en/apm/agent/nodejs/current/log-correlation.html[log correlation] out-of-the-box.
+
+The next step is to define what https://www.elastic.co/observability[observability tools] are available.
+For a better experience, set up an https://www.elastic.co/guide/en/apm/get-started/current/observability-integrations.html[Observability integration] provided by Elastic to debug your application with the <>
+To debug something quickly without setting up additional tooling, you can work with <>
+
+[[debugging-logs-apm-ui]]
+==== APM UI
+*Prerequisites* {kib} logs are configured to be in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format to include tracing identifiers.
+
+To debug {kib} with the APM UI, you must set up the APM infrastructure. You can find instructions for the setup process
+https://www.elastic.co/guide/en/apm/get-started/current/observability-integrations.html[on the Observability integrations page].
+
+Once you set up the APM infrastructure, you can enable the APM agent and put {kib} under load to collect APM events. To analyze the collected metrics and logs, use the APM UI as demonstrated https://www.elastic.co/guide/en/kibana/master/transactions.html#transaction-trace-sample[in the docs].
+
+[[plain-kibana-logs]]
+==== Plain {kib} logs
+*Prerequisites* {kib} logs are configured to be in https://www.elastic.co/guide/en/ecs/master/ecs-reference.html[ECS JSON] format to include tracing identifiers.
+
+Open {kib} Logs and search for an operation you are interested in.
+For example, suppose you want to investigate the response times for queries to the `/api/telemetry/v2/clusters/_stats` {kib} endpoint.
+Open Kibana Logs and search for the HTTP server response for the endpoint. It looks similar to the following (some fields are omitted for brevity).
+[source,json]
+----
+{
+ "message":"POST /api/telemetry/v2/clusters/_stats 200 1014ms - 43.2KB",
+ "log":{"level":"DEBUG","logger":"http.server.response"},
+ "trace":{"id":"9b99131a6f66587971ef085ef97dfd07"},
+ "transaction":{"id":"d0c5bbf14f5febca"}
+}
+----
+You are interested in the https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html#field-trace-id[trace.id] field, which is a unique identifier of a trace. The `trace.id` provides a way to group multiple events, like transactions, which belong together. You can search for `"trace":{"id":"9b99131a6f66587971ef085ef97dfd07"}` to get all the logs that belong to the same trace. This enables you to see how many {es} requests were triggered during the `9b99131a6f66587971ef085ef97dfd07` trace, what they looked like, what {es} endpoints were hit, and so on.
diff --git a/package.json b/package.json
index 80a633f2d80ed..6c896944044ab 100644
--- a/package.json
+++ b/package.json
@@ -109,7 +109,6 @@
"@elastic/ems-client": "8.0.0",
"@elastic/eui": "41.0.0",
"@elastic/filesaver": "1.1.2",
- "@elastic/maki": "6.3.0",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
"@elastic/react-search-ui": "^1.6.0",
@@ -196,8 +195,10 @@
"archiver": "^5.2.0",
"axios": "^0.21.1",
"base64-js": "^1.3.1",
+ "bitmap-sdf": "^1.0.3",
"brace": "0.11.1",
"broadcast-channel": "^4.7.0",
+ "canvg": "^3.0.9",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.10",
"chokidar": "^3.4.3",
@@ -520,7 +521,6 @@
"@types/ejs": "^3.0.6",
"@types/elastic__apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types",
"@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types",
- "@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.10.8",
"@types/eslint": "^7.28.0",
"@types/express": "^4.17.13",
@@ -531,7 +531,6 @@
"@types/file-saver": "^2.0.0",
"@types/flot": "^0.0.31",
"@types/geojson": "7946.0.7",
- "@types/getopts": "^2.0.1",
"@types/getos": "^3.0.0",
"@types/glob": "^7.1.2",
"@types/gulp": "^4.0.6",
@@ -568,6 +567,9 @@
"@types/kbn__config": "link:bazel-bin/packages/kbn-config/npm_module_types",
"@types/kbn__config-schema": "link:bazel-bin/packages/kbn-config-schema/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
+ "@types/kbn__dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module_types",
+ "@types/kbn__docs-utils": "link:bazel-bin/packages/kbn-docs-utils/npm_module_types",
+ "@types/kbn__es-archiver": "link:bazel-bin/packages/kbn-es-archiver/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
"@types/license-checker": "15.0.0",
diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel
index 96b1846147689..a7f0707575fcd 100644
--- a/packages/BUILD.bazel
+++ b/packages/BUILD.bazel
@@ -86,6 +86,9 @@ filegroup(
"//packages/kbn-config:build_types",
"//packages/kbn-config-schema:build_types",
"//packages/kbn-crypto:build_types",
+ "//packages/kbn-dev-utils:build_types",
+ "//packages/kbn-docs-utils:build_types",
+ "//packages/kbn-es-archiver:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
],
diff --git a/packages/elastic-eslint-config-kibana/react.js b/packages/elastic-eslint-config-kibana/react.js
index 29000bdb15684..0b1cce15de9ad 100644
--- a/packages/elastic-eslint-config-kibana/react.js
+++ b/packages/elastic-eslint-config-kibana/react.js
@@ -1,5 +1,5 @@
const semver = require('semver');
-const { kibanaPackageJson: PKG } = require('@kbn/dev-utils');
+const { kibanaPackageJson: PKG } = require('@kbn/utils');
module.exports = {
plugins: [
diff --git a/packages/elastic-eslint-config-kibana/typescript.js b/packages/elastic-eslint-config-kibana/typescript.js
index 1a0ef81ae2f1e..3ada725cb1805 100644
--- a/packages/elastic-eslint-config-kibana/typescript.js
+++ b/packages/elastic-eslint-config-kibana/typescript.js
@@ -4,7 +4,7 @@
// as this package was moved from typescript-eslint-parser to @typescript-eslint/parser
const semver = require('semver');
-const { kibanaPackageJson: PKG } = require('@kbn/dev-utils');
+const { kibanaPackageJson: PKG } = require('@kbn/utils');
const eslintConfigPrettierTypescriptEslintRules = require('eslint-config-prettier/@typescript-eslint').rules;
diff --git a/packages/kbn-apm-config-loader/src/init_apm.test.ts b/packages/kbn-apm-config-loader/src/init_apm.test.ts
index 95f0a15a448c8..cabab421519bd 100644
--- a/packages/kbn-apm-config-loader/src/init_apm.test.ts
+++ b/packages/kbn-apm-config-loader/src/init_apm.test.ts
@@ -12,13 +12,13 @@ import { initApm } from './init_apm';
import apm from 'elastic-apm-node';
describe('initApm', () => {
- let apmAddFilterSpy: jest.SpyInstance;
- let apmStartSpy: jest.SpyInstance;
+ let apmAddFilterMock: jest.Mock;
+ let apmStartMock: jest.Mock;
let getConfig: jest.Mock;
beforeEach(() => {
- apmAddFilterSpy = jest.spyOn(apm, 'addFilter').mockImplementation(() => undefined);
- apmStartSpy = jest.spyOn(apm, 'start').mockImplementation(() => undefined as any);
+ apmAddFilterMock = apm.addFilter as jest.Mock;
+ apmStartMock = apm.start as jest.Mock;
getConfig = jest.fn();
mockLoadConfiguration.mockImplementation(() => ({
@@ -27,7 +27,8 @@ describe('initApm', () => {
});
afterEach(() => {
- jest.restoreAllMocks();
+ apmAddFilterMock.mockReset();
+ apmStartMock.mockReset();
mockLoadConfiguration.mockReset();
});
@@ -48,8 +49,8 @@ describe('initApm', () => {
it('registers a filter using `addFilter`', () => {
initApm(['foo', 'bar'], 'rootDir', true, 'service-name');
- expect(apmAddFilterSpy).toHaveBeenCalledTimes(1);
- expect(apmAddFilterSpy).toHaveBeenCalledWith(expect.any(Function));
+ expect(apmAddFilterMock).toHaveBeenCalledTimes(1);
+ expect(apmAddFilterMock).toHaveBeenCalledWith(expect.any(Function));
});
it('starts apm with the config returned from `getConfig`', () => {
@@ -60,7 +61,7 @@ describe('initApm', () => {
initApm(['foo', 'bar'], 'rootDir', true, 'service-name');
- expect(apmStartSpy).toHaveBeenCalledTimes(1);
- expect(apmStartSpy).toHaveBeenCalledWith(config);
+ expect(apmStartMock).toHaveBeenCalledTimes(1);
+ expect(apmStartMock).toHaveBeenCalledWith(config);
});
});
diff --git a/packages/kbn-cli-dev-mode/BUILD.bazel b/packages/kbn-cli-dev-mode/BUILD.bazel
index 66e00706e9e58..cdc40e85c972a 100644
--- a/packages/kbn-cli-dev-mode/BUILD.bazel
+++ b/packages/kbn-cli-dev-mode/BUILD.bazel
@@ -50,7 +50,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-optimizer",
"//packages/kbn-server-http-tools",
@@ -60,12 +60,12 @@ TYPES_DEPS = [
"@npm//chokidar",
"@npm//elastic-apm-node",
"@npm//execa",
+ "@npm//getopts",
"@npm//moment",
"@npm//rxjs",
"@npm//supertest",
"@npm//@types/hapi__h2o2",
"@npm//@types/hapi__hapi",
- "@npm//@types/getopts",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
diff --git a/packages/kbn-cli-dev-mode/src/cli_dev_mode.test.ts b/packages/kbn-cli-dev-mode/src/cli_dev_mode.test.ts
index e5e009e51e69e..0066644d0825a 100644
--- a/packages/kbn-cli-dev-mode/src/cli_dev_mode.test.ts
+++ b/packages/kbn-cli-dev-mode/src/cli_dev_mode.test.ts
@@ -8,11 +8,9 @@
import Path from 'path';
import * as Rx from 'rxjs';
-import {
- REPO_ROOT,
- createAbsolutePathSerializer,
- createAnyInstanceSerializer,
-} from '@kbn/dev-utils';
+import { createAbsolutePathSerializer, createAnyInstanceSerializer } from '@kbn/dev-utils';
+
+import { REPO_ROOT } from '@kbn/utils';
import { TestLog } from './log';
import { CliDevMode, SomeCliArgs } from './cli_dev_mode';
diff --git a/packages/kbn-cli-dev-mode/src/cli_dev_mode.ts b/packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
index 2396b316aa3a2..9cf688b675e67 100644
--- a/packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
+++ b/packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
@@ -22,7 +22,8 @@ import {
takeUntil,
} from 'rxjs/operators';
import { CliArgs } from '@kbn/config';
-import { REPO_ROOT, CiStatsReporter } from '@kbn/dev-utils';
+import { CiStatsReporter } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Log, CliLog } from './log';
import { Optimizer } from './optimizer';
diff --git a/packages/kbn-cli-dev-mode/src/get_server_watch_paths.test.ts b/packages/kbn-cli-dev-mode/src/get_server_watch_paths.test.ts
index 9fa13b013f195..25bc59bf78458 100644
--- a/packages/kbn-cli-dev-mode/src/get_server_watch_paths.test.ts
+++ b/packages/kbn-cli-dev-mode/src/get_server_watch_paths.test.ts
@@ -8,7 +8,8 @@
import Path from 'path';
-import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils';
+import { createAbsolutePathSerializer } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { getServerWatchPaths } from './get_server_watch_paths';
@@ -65,7 +66,7 @@ it('produces the right watch and ignore list', () => {
/x-pack/test/plugin_functional/plugins/resolver_test/target/**,
/x-pack/test/plugin_functional/plugins/resolver_test/scripts/**,
/x-pack/test/plugin_functional/plugins/resolver_test/docs/**,
- /x-pack/plugins/reporting/chromium,
+ /x-pack/plugins/screenshotting/chromium,
/x-pack/plugins/security_solution/cypress,
/x-pack/plugins/apm/scripts,
/x-pack/plugins/apm/ftr_e2e,
diff --git a/packages/kbn-cli-dev-mode/src/get_server_watch_paths.ts b/packages/kbn-cli-dev-mode/src/get_server_watch_paths.ts
index e1bd431d280a4..acfc9aeecdc80 100644
--- a/packages/kbn-cli-dev-mode/src/get_server_watch_paths.ts
+++ b/packages/kbn-cli-dev-mode/src/get_server_watch_paths.ts
@@ -9,7 +9,7 @@
import Path from 'path';
import Fs from 'fs';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
interface Options {
pluginPaths: string[];
@@ -56,7 +56,7 @@ export function getServerWatchPaths({ pluginPaths, pluginScanDirs }: Options) {
/\.(md|sh|txt)$/,
/debug\.log$/,
...pluginInternalDirsIgnore,
- fromRoot('x-pack/plugins/reporting/chromium'),
+ fromRoot('x-pack/plugins/screenshotting/chromium'),
fromRoot('x-pack/plugins/security_solution/cypress'),
fromRoot('x-pack/plugins/apm/scripts'),
fromRoot('x-pack/plugins/apm/ftr_e2e'), // prevents restarts for APM cypress tests
diff --git a/packages/kbn-crypto/BUILD.bazel b/packages/kbn-crypto/BUILD.bazel
index 81ee6d770103c..f71c8b866fd5d 100644
--- a/packages/kbn-crypto/BUILD.bazel
+++ b/packages/kbn-crypto/BUILD.bazel
@@ -34,7 +34,7 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"@npm//@types/flot",
"@npm//@types/jest",
"@npm//@types/node",
diff --git a/packages/kbn-dev-utils/BUILD.bazel b/packages/kbn-dev-utils/BUILD.bazel
index 4fd99e0144cb6..89df1870a3cec 100644
--- a/packages/kbn-dev-utils/BUILD.bazel
+++ b/packages/kbn-dev-utils/BUILD.bazel
@@ -1,9 +1,10 @@
-load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
-load("//src/dev/bazel:index.bzl", "jsts_transpiler")
+load("@npm//@bazel/typescript:index.bzl", "ts_config")
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_BASE_NAME = "kbn-dev-utils"
PKG_REQUIRE_NAME = "@kbn/dev-utils"
+TYPES_PKG_REQUIRE_NAME = "@types/kbn__dev-utils"
SOURCE_FILES = glob(
[
@@ -43,7 +44,6 @@ NPM_MODULE_EXTRA_FILES = [
]
RUNTIME_DEPS = [
- "//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@babel/core",
"@npm//axios",
@@ -66,7 +66,6 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@babel/parser",
"@npm//@babel/types",
@@ -124,7 +123,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
- deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
+ deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
@@ -143,3 +142,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)
+
+pkg_npm_types(
+ name = "npm_module_types",
+ srcs = SRCS,
+ deps = [":tsc_types"],
+ package_name = TYPES_PKG_REQUIRE_NAME,
+ tsconfig = ":tsconfig",
+ visibility = ["//visibility:public"],
+)
+
+filegroup(
+ name = "build_types",
+ srcs = [
+ ":npm_module_types",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/packages/kbn-dev-utils/package.json b/packages/kbn-dev-utils/package.json
index 9d6e6dde86fac..ab4f489e7d345 100644
--- a/packages/kbn-dev-utils/package.json
+++ b/packages/kbn-dev-utils/package.json
@@ -4,7 +4,6 @@
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js",
- "types": "./target_types/index.d.ts",
"kibana": {
"devOnly": true
}
diff --git a/packages/kbn-dev-utils/src/index.ts b/packages/kbn-dev-utils/src/index.ts
index 381e99ac677f5..9b207ad9e9966 100644
--- a/packages/kbn-dev-utils/src/index.ts
+++ b/packages/kbn-dev-utils/src/index.ts
@@ -6,7 +6,6 @@
* Side Public License, v 1.
*/
-export * from '@kbn/utils';
export { withProcRunner, ProcRunner } from './proc_runner';
export * from './tooling_log';
export * from './serializers';
diff --git a/packages/kbn-dev-utils/src/tooling_log/__snapshots__/tooling_log_text_writer.test.ts.snap b/packages/kbn-dev-utils/src/tooling_log/__snapshots__/tooling_log_text_writer.test.ts.snap
index 7ff982acafbe4..5fa074d4c7739 100644
--- a/packages/kbn-dev-utils/src/tooling_log/__snapshots__/tooling_log_text_writer.test.ts.snap
+++ b/packages/kbn-dev-utils/src/tooling_log/__snapshots__/tooling_log_text_writer.test.ts.snap
@@ -170,6 +170,14 @@ exports[`level:warning/type:warning snapshots: output 1`] = `
"
`;
+exports[`never ignores write messages from the kibana elasticsearch.deprecation logger context 1`] = `
+" │[elasticsearch.deprecation]
+ │{ foo: { bar: { '1': [Array] } }, bar: { bar: { '1': [Array] } } }
+ │
+ │Infinity
+"
+`;
+
exports[`throws error if created with invalid level 1`] = `"Invalid log level \\"foo\\" (expected one of silent,error,warning,success,info,debug,verbose)"`;
exports[`throws error if writeTo config is not defined or doesn't have a write method 1`] = `"ToolingLogTextWriter requires the \`writeTo\` option be set to a stream (like process.stdout)"`;
diff --git a/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.test.ts b/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.test.ts
index b4668f29b6e21..fbccfdcdf6ac0 100644
--- a/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.test.ts
+++ b/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.test.ts
@@ -88,3 +88,55 @@ it('formats %s patterns and indents multi-line messages correctly', () => {
const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
expect(output).toMatchSnapshot();
});
+
+it('does not write messages from sources in ignoreSources', () => {
+ const write = jest.fn();
+ const writer = new ToolingLogTextWriter({
+ ignoreSources: ['myIgnoredSource'],
+ level: 'debug',
+ writeTo: {
+ write,
+ },
+ });
+
+ writer.write({
+ source: 'myIgnoredSource',
+ type: 'success',
+ indent: 10,
+ args: [
+ '%s\n%O\n\n%d',
+ 'foo bar',
+ { foo: { bar: { 1: [1, 2, 3] } }, bar: { bar: { 1: [1, 2, 3] } } },
+ Infinity,
+ ],
+ });
+
+ const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
+ expect(output).toEqual('');
+});
+
+it('never ignores write messages from the kibana elasticsearch.deprecation logger context', () => {
+ const write = jest.fn();
+ const writer = new ToolingLogTextWriter({
+ ignoreSources: ['myIgnoredSource'],
+ level: 'debug',
+ writeTo: {
+ write,
+ },
+ });
+
+ writer.write({
+ source: 'myIgnoredSource',
+ type: 'write',
+ indent: 10,
+ args: [
+ '%s\n%O\n\n%d',
+ '[elasticsearch.deprecation]',
+ { foo: { bar: { 1: [1, 2, 3] } }, bar: { bar: { 1: [1, 2, 3] } } },
+ Infinity,
+ ],
+ });
+
+ const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
+ expect(output).toMatchSnapshot();
+});
diff --git a/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.ts b/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.ts
index 660dae3fa1f55..4fe33241cf77e 100644
--- a/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.ts
+++ b/packages/kbn-dev-utils/src/tooling_log/tooling_log_text_writer.ts
@@ -92,7 +92,15 @@ export class ToolingLogTextWriter implements Writer {
}
if (this.ignoreSources && msg.source && this.ignoreSources.includes(msg.source)) {
- return false;
+ if (msg.type === 'write') {
+ const txt = format(msg.args[0], ...msg.args.slice(1));
+ // Ensure that Elasticsearch deprecation log messages from Kibana aren't ignored
+ if (!/elasticsearch\.deprecation/.test(txt)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
}
const prefix = has(MSG_PREFIXES, msg.type) ? MSG_PREFIXES[msg.type] : '';
diff --git a/packages/kbn-docs-utils/BUILD.bazel b/packages/kbn-docs-utils/BUILD.bazel
index 6bb37b3500152..edfd3ee96c181 100644
--- a/packages/kbn-docs-utils/BUILD.bazel
+++ b/packages/kbn-docs-utils/BUILD.bazel
@@ -1,9 +1,10 @@
-load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
-load("//src/dev/bazel:index.bzl", "jsts_transpiler")
+load("@npm//@bazel/typescript:index.bzl", "ts_config")
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_BASE_NAME = "kbn-docs-utils"
PKG_REQUIRE_NAME = "@kbn/docs-utils"
+TYPES_PKG_REQUIRE_NAME = "@types/kbn__docs-utils"
SOURCE_FILES = glob(
[
@@ -37,7 +38,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-utils",
"@npm//ts-morph",
"@npm//@types/dedent",
@@ -77,7 +78,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
- deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
+ deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
@@ -96,3 +97,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)
+
+pkg_npm_types(
+ name = "npm_module_types",
+ srcs = SRCS,
+ deps = [":tsc_types"],
+ package_name = TYPES_PKG_REQUIRE_NAME,
+ tsconfig = ":tsconfig",
+ visibility = ["//visibility:public"],
+)
+
+filegroup(
+ name = "build_types",
+ srcs = [
+ ":npm_module_types",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/packages/kbn-docs-utils/package.json b/packages/kbn-docs-utils/package.json
index dcff832583f59..84fc3ccb0cded 100644
--- a/packages/kbn-docs-utils/package.json
+++ b/packages/kbn-docs-utils/package.json
@@ -4,7 +4,6 @@
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": "true",
"main": "target_node/index.js",
- "types": "target_types/index.d.ts",
"kibana": {
"devOnly": true
}
diff --git a/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts b/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
index 2e4ce08540714..3c9137b260a3e 100644
--- a/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
+++ b/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
@@ -9,7 +9,8 @@
import Fs from 'fs';
import Path from 'path';
-import { REPO_ROOT, run, CiStatsReporter, createFlagError } from '@kbn/dev-utils';
+import { run, CiStatsReporter, createFlagError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Project } from 'ts-morph';
import { writePluginDocs } from './mdx/write_plugin_mdx_docs';
@@ -241,7 +242,7 @@ export function runBuildApiDocsCli() {
boolean: ['references'],
help: `
--plugin Optionally, run for only a specific plugin
- --stats Optionally print API stats. Must be one or more of: any, comments or exports.
+ --stats Optionally print API stats. Must be one or more of: any, comments or exports.
--references Collect references for API items
`,
},
diff --git a/packages/kbn-docs-utils/src/api_docs/find_plugins.ts b/packages/kbn-docs-utils/src/api_docs/find_plugins.ts
index 78cba3f3a9476..774452a6f1f9f 100644
--- a/packages/kbn-docs-utils/src/api_docs/find_plugins.ts
+++ b/packages/kbn-docs-utils/src/api_docs/find_plugins.ts
@@ -12,7 +12,8 @@ import globby from 'globby';
import loadJsonFile from 'load-json-file';
import { getPluginSearchPaths } from '@kbn/config';
-import { simpleKibanaPlatformPluginDiscovery, REPO_ROOT } from '@kbn/dev-utils';
+import { simpleKibanaPlatformPluginDiscovery } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { ApiScope, PluginOrPackage } from './types';
export function findPlugins(): PluginOrPackage[] {
diff --git a/packages/kbn-es-archiver/BUILD.bazel b/packages/kbn-es-archiver/BUILD.bazel
index 2dc311ed74406..da8aaf913ab67 100644
--- a/packages/kbn-es-archiver/BUILD.bazel
+++ b/packages/kbn-es-archiver/BUILD.bazel
@@ -1,9 +1,10 @@
-load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
-load("//src/dev/bazel:index.bzl", "jsts_transpiler")
+load("@npm//@bazel/typescript:index.bzl", "ts_config")
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_BASE_NAME = "kbn-es-archiver"
PKG_REQUIRE_NAME = "@kbn/es-archiver"
+TYPES_PKG_REQUIRE_NAME = "@types/kbn__es-archiver"
SOURCE_FILES = glob(
[
@@ -43,7 +44,7 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-test",
"//packages/kbn-utils",
"@npm//@elastic/elasticsearch",
@@ -90,7 +91,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
- deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
+ deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
@@ -109,3 +110,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)
+
+pkg_npm_types(
+ name = "npm_module_types",
+ srcs = SRCS,
+ deps = [":tsc_types"],
+ package_name = TYPES_PKG_REQUIRE_NAME,
+ tsconfig = ":tsconfig",
+ visibility = ["//visibility:public"],
+)
+
+filegroup(
+ name = "build_types",
+ srcs = [
+ ":npm_module_types",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/packages/kbn-es-archiver/package.json b/packages/kbn-es-archiver/package.json
index 0cce08eaf0352..bff3990a0c1bc 100644
--- a/packages/kbn-es-archiver/package.json
+++ b/packages/kbn-es-archiver/package.json
@@ -4,7 +4,6 @@
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": "true",
"main": "target_node/index.js",
- "types": "target_types/index.d.ts",
"kibana": {
"devOnly": true
}
diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/kbn-es-archiver/src/actions/load.ts
index 0a7235c566b52..c5bea5e29a687 100644
--- a/packages/kbn-es-archiver/src/actions/load.ts
+++ b/packages/kbn-es-archiver/src/actions/load.ts
@@ -9,7 +9,8 @@
import { resolve, relative } from 'path';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { KbnClient } from '@kbn/test';
import type { Client } from '@elastic/elasticsearch';
import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils';
diff --git a/packages/kbn-es-archiver/src/actions/rebuild_all.ts b/packages/kbn-es-archiver/src/actions/rebuild_all.ts
index 360fdb438f2db..27fcae0c7cec5 100644
--- a/packages/kbn-es-archiver/src/actions/rebuild_all.ts
+++ b/packages/kbn-es-archiver/src/actions/rebuild_all.ts
@@ -10,8 +10,8 @@ import { resolve, relative } from 'path';
import { Stats, createReadStream, createWriteStream } from 'fs';
import { stat, rename } from 'fs/promises';
import { Readable, Writable } from 'stream';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
-import { createPromiseFromStreams } from '@kbn/utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';
import {
prioritizeMappings,
readDirectory,
diff --git a/packages/kbn-es-archiver/src/actions/save.ts b/packages/kbn-es-archiver/src/actions/save.ts
index 9cb5be05ac060..e5e3f06b8436d 100644
--- a/packages/kbn-es-archiver/src/actions/save.ts
+++ b/packages/kbn-es-archiver/src/actions/save.ts
@@ -10,8 +10,8 @@ import { resolve, relative } from 'path';
import { createWriteStream, mkdirSync } from 'fs';
import { Readable, Writable } from 'stream';
import type { Client } from '@elastic/elasticsearch';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
-import { createListStream, createPromiseFromStreams } from '@kbn/utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { createListStream, createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';
import {
createStats,
diff --git a/packages/kbn-es-archiver/src/actions/unload.ts b/packages/kbn-es-archiver/src/actions/unload.ts
index 1c5f4cd5d7d03..22830b7289174 100644
--- a/packages/kbn-es-archiver/src/actions/unload.ts
+++ b/packages/kbn-es-archiver/src/actions/unload.ts
@@ -10,9 +10,9 @@ import { resolve, relative } from 'path';
import { createReadStream } from 'fs';
import { Readable, Writable } from 'stream';
import type { Client } from '@elastic/elasticsearch';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
import { KbnClient } from '@kbn/test';
-import { createPromiseFromStreams } from '@kbn/utils';
+import { createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';
import {
isGzip,
diff --git a/packages/kbn-es-archiver/src/es_archiver.ts b/packages/kbn-es-archiver/src/es_archiver.ts
index 354197a98fa46..e13e20f25a703 100644
--- a/packages/kbn-es-archiver/src/es_archiver.ts
+++ b/packages/kbn-es-archiver/src/es_archiver.ts
@@ -10,7 +10,8 @@ import Fs from 'fs';
import Path from 'path';
import type { Client } from '@elastic/elasticsearch';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { KbnClient } from '@kbn/test';
import {
diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts
index ae21649690a99..2590074a25411 100644
--- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts
+++ b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts
@@ -6,13 +6,14 @@
* Side Public License, v 1.
*/
+import { ToolingLog } from '@kbn/dev-utils';
+
import {
createListStream,
createPromiseFromStreams,
createConcatStream,
createMapStream,
- ToolingLog,
-} from '@kbn/dev-utils';
+} from '@kbn/utils';
import { createGenerateDocRecordsStream } from './generate_doc_records_stream';
import { Progress } from '../progress';
diff --git a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.test.ts b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.test.ts
index bcf28a4976a1c..9c0ff4a8f91ec 100644
--- a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.test.ts
+++ b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.test.ts
@@ -6,12 +6,9 @@
* Side Public License, v 1.
*/
-import {
- createListStream,
- createPromiseFromStreams,
- ToolingLog,
- createRecursiveSerializer,
-} from '@kbn/dev-utils';
+import { ToolingLog, createRecursiveSerializer } from '@kbn/dev-utils';
+
+import { createListStream, createPromiseFromStreams } from '@kbn/utils';
import { Progress } from '../progress';
import { createIndexDocRecordsStream } from './index_doc_records_stream';
diff --git a/packages/kbn-es/BUILD.bazel b/packages/kbn-es/BUILD.bazel
index 91dc48cec7d0c..2ea9c32858dd3 100644
--- a/packages/kbn-es/BUILD.bazel
+++ b/packages/kbn-es/BUILD.bazel
@@ -1,5 +1,5 @@
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
-load("//src/dev/bazel:index.bzl", "jsts_transpiler")
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm")
PKG_BASE_NAME = "kbn-es"
PKG_REQUIRE_NAME = "@kbn/es"
diff --git a/packages/kbn-es/src/artifact.test.js b/packages/kbn-es/src/artifact.test.js
index c65109bc34610..884804ed75a65 100644
--- a/packages/kbn-es/src/artifact.test.js
+++ b/packages/kbn-es/src/artifact.test.js
@@ -90,10 +90,10 @@ const artifactTest = (requestedLicense, expectedLicense, fetchTimesCalled = 1) =
`${PERMANENT_SNAPSHOT_BASE_URL}/${MOCK_VERSION}/manifest.json`
);
}
- expect(artifact.getUrl()).toEqual(MOCK_URL + `/${expectedLicense}`);
- expect(artifact.getChecksumUrl()).toEqual(MOCK_URL + `/${expectedLicense}.sha512`);
- expect(artifact.getChecksumType()).toEqual('sha512');
- expect(artifact.getFilename()).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.${expectedLicense}`);
+ expect(artifact.spec.url).toEqual(MOCK_URL + `/${expectedLicense}`);
+ expect(artifact.spec.checksumUrl).toEqual(MOCK_URL + `/${expectedLicense}.sha512`);
+ expect(artifact.spec.checksumType).toEqual('sha512');
+ expect(artifact.spec.filename).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.${expectedLicense}`);
};
};
@@ -158,7 +158,7 @@ describe('Artifact', () => {
it('should return artifact metadata for the correct architecture', async () => {
const artifact = await Artifact.getSnapshot('oss', MOCK_VERSION, log);
- expect(artifact.getFilename()).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.oss`);
+ expect(artifact.spec.filename).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.oss`);
});
});
@@ -182,7 +182,7 @@ describe('Artifact', () => {
describe('with latest unverified snapshot', () => {
beforeEach(() => {
- process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = 1;
+ process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = '1';
mockFetch(MOCKS.valid);
});
diff --git a/packages/kbn-es/src/artifact.js b/packages/kbn-es/src/artifact.ts
similarity index 65%
rename from packages/kbn-es/src/artifact.js
rename to packages/kbn-es/src/artifact.ts
index 0fa2c7a1727d0..9c5935c96e8cd 100644
--- a/packages/kbn-es/src/artifact.js
+++ b/packages/kbn-es/src/artifact.ts
@@ -6,25 +6,69 @@
* Side Public License, v 1.
*/
-const fetch = require('node-fetch');
-const AbortController = require('abort-controller');
-const fs = require('fs');
-const { promisify } = require('util');
-const { pipeline, Transform } = require('stream');
-const chalk = require('chalk');
-const { createHash } = require('crypto');
-const path = require('path');
+import fs from 'fs';
+import { promisify } from 'util';
+import path from 'path';
+import { createHash } from 'crypto';
+import { pipeline, Transform } from 'stream';
+import { setTimeout } from 'timers/promises';
+
+import fetch, { Headers } from 'node-fetch';
+import AbortController from 'abort-controller';
+import chalk from 'chalk';
+import { ToolingLog } from '@kbn/dev-utils';
+
+import { cache } from './utils/cache';
+import { resolveCustomSnapshotUrl } from './custom_snapshots';
+import { createCliError, isCliError } from './errors';
const asyncPipeline = promisify(pipeline);
const DAILY_SNAPSHOTS_BASE_URL = 'https://storage.googleapis.com/kibana-ci-es-snapshots-daily';
const PERMANENT_SNAPSHOTS_BASE_URL =
'https://storage.googleapis.com/kibana-ci-es-snapshots-permanent';
-const { cache } = require('./utils');
-const { resolveCustomSnapshotUrl } = require('./custom_snapshots');
-const { createCliError, isCliError } = require('./errors');
+type ChecksumType = 'sha512';
+export type ArtifactLicense = 'oss' | 'basic' | 'trial';
+
+interface ArtifactManifest {
+ id: string;
+ bucket: string;
+ branch: string;
+ sha: string;
+ sha_short: string;
+ version: string;
+ generated: string;
+ archives: Array<{
+ filename: string;
+ checksum: string;
+ url: string;
+ version: string;
+ platform: string;
+ architecture: string;
+ license: string;
+ }>;
+}
+
+export interface ArtifactSpec {
+ url: string;
+ checksumUrl: string;
+ checksumType: ChecksumType;
+ filename: string;
+}
+
+interface ArtifactDownloaded {
+ cached: false;
+ checksum: string;
+ etag?: string;
+ contentLength: number;
+ first500Bytes: Buffer;
+ headers: Headers;
+}
+interface ArtifactCached {
+ cached: true;
+}
-function getChecksumType(checksumUrl) {
+function getChecksumType(checksumUrl: string): ChecksumType {
if (checksumUrl.endsWith('.sha512')) {
return 'sha512';
}
@@ -32,15 +76,18 @@ function getChecksumType(checksumUrl) {
throw new Error(`unable to determine checksum type: ${checksumUrl}`);
}
-function headersToString(headers, indent = '') {
+function headersToString(headers: Headers, indent = '') {
return [...headers.entries()].reduce(
(acc, [key, value]) => `${acc}\n${indent}${key}: ${value}`,
''
);
}
-async function retry(log, fn) {
- async function doAttempt(attempt) {
+async function retry(log: ToolingLog, fn: () => Promise): Promise {
+ let attempt = 0;
+ while (true) {
+ attempt += 1;
+
try {
return await fn();
} catch (error) {
@@ -49,13 +96,10 @@ async function retry(log, fn) {
}
log.warning('...failure, retrying in 5 seconds:', error.message);
- await new Promise((resolve) => setTimeout(resolve, 5000));
+ await setTimeout(5000);
log.info('...retrying');
- return await doAttempt(attempt + 1);
}
}
-
- return await doAttempt(1);
}
// Setting this flag provides an easy way to run the latest un-promoted snapshot without having to look it up
@@ -63,7 +107,7 @@ function shouldUseUnverifiedSnapshot() {
return !!process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED;
}
-async function fetchSnapshotManifest(url, log) {
+async function fetchSnapshotManifest(url: string, log: ToolingLog) {
log.info('Downloading snapshot manifest from %s', chalk.bold(url));
const abc = new AbortController();
@@ -73,7 +117,11 @@ async function fetchSnapshotManifest(url, log) {
return { abc, resp, json };
}
-async function getArtifactSpecForSnapshot(urlVersion, license, log) {
+async function getArtifactSpecForSnapshot(
+ urlVersion: string,
+ license: string,
+ log: ToolingLog
+): Promise {
const desiredVersion = urlVersion.replace('-SNAPSHOT', '');
const desiredLicense = license === 'oss' ? 'oss' : 'default';
@@ -103,17 +151,16 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
throw new Error(`Unable to read snapshot manifest: ${resp.statusText}\n ${json}`);
}
- const manifest = JSON.parse(json);
-
+ const manifest: ArtifactManifest = JSON.parse(json);
const platform = process.platform === 'win32' ? 'windows' : process.platform;
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
const archive = manifest.archives.find(
- (archive) =>
- archive.version === desiredVersion &&
- archive.platform === platform &&
- archive.license === desiredLicense &&
- archive.architecture === arch
+ (a) =>
+ a.version === desiredVersion &&
+ a.platform === platform &&
+ a.license === desiredLicense &&
+ a.architecture === arch
);
if (!archive) {
@@ -130,93 +177,65 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
};
}
-exports.Artifact = class Artifact {
+export class Artifact {
/**
* Fetch an Artifact from the Artifact API for a license level and version
- * @param {('oss'|'basic'|'trial')} license
- * @param {string} version
- * @param {ToolingLog} log
*/
- static async getSnapshot(license, version, log) {
+ static async getSnapshot(license: ArtifactLicense, version: string, log: ToolingLog) {
const urlVersion = `${encodeURIComponent(version)}-SNAPSHOT`;
const customSnapshotArtifactSpec = resolveCustomSnapshotUrl(urlVersion, license);
if (customSnapshotArtifactSpec) {
- return new Artifact(customSnapshotArtifactSpec, log);
+ return new Artifact(log, customSnapshotArtifactSpec);
}
const artifactSpec = await getArtifactSpecForSnapshot(urlVersion, license, log);
- return new Artifact(artifactSpec, log);
+ return new Artifact(log, artifactSpec);
}
/**
* Fetch an Artifact from the Elasticsearch past releases url
- * @param {string} url
- * @param {ToolingLog} log
*/
- static async getArchive(url, log) {
+ static async getArchive(url: string, log: ToolingLog) {
const shaUrl = `${url}.sha512`;
- const artifactSpec = {
- url: url,
+ return new Artifact(log, {
+ url,
filename: path.basename(url),
checksumUrl: shaUrl,
checksumType: getChecksumType(shaUrl),
- };
-
- return new Artifact(artifactSpec, log);
- }
-
- constructor(spec, log) {
- this._spec = spec;
- this._log = log;
- }
-
- getUrl() {
- return this._spec.url;
- }
-
- getChecksumUrl() {
- return this._spec.checksumUrl;
+ });
}
- getChecksumType() {
- return this._spec.checksumType;
- }
-
- getFilename() {
- return this._spec.filename;
- }
+ constructor(private readonly log: ToolingLog, public readonly spec: ArtifactSpec) {}
/**
* Download the artifact to disk, skips the download if the cache is
* up-to-date, verifies checksum when downloaded
- * @param {string} dest
- * @return {Promise}
*/
- async download(dest, { useCached = false }) {
- await retry(this._log, async () => {
+ async download(dest: string, { useCached = false }: { useCached?: boolean } = {}) {
+ await retry(this.log, async () => {
const cacheMeta = cache.readMeta(dest);
const tmpPath = `${dest}.tmp`;
if (useCached) {
if (cacheMeta.exists) {
- this._log.info(
+ this.log.info(
'use-cached passed, forcing to use existing snapshot',
chalk.bold(cacheMeta.ts)
);
return;
} else {
- this._log.info('use-cached passed but no cached snapshot found. Continuing to download');
+ this.log.info('use-cached passed but no cached snapshot found. Continuing to download');
}
}
- const artifactResp = await this._download(tmpPath, cacheMeta.etag, cacheMeta.ts);
+ const artifactResp = await this.fetchArtifact(tmpPath, cacheMeta.etag, cacheMeta.ts);
if (artifactResp.cached) {
return;
}
- await this._verifyChecksum(artifactResp);
+ await this.verifyChecksum(artifactResp);
// cache the etag for future downloads
cache.writeMeta(dest, { etag: artifactResp.etag });
@@ -228,18 +247,18 @@ exports.Artifact = class Artifact {
/**
* Fetch the artifact with an etag
- * @param {string} tmpPath
- * @param {string} etag
- * @param {string} ts
- * @return {{ cached: true }|{ checksum: string, etag: string, first500Bytes: Buffer }}
*/
- async _download(tmpPath, etag, ts) {
- const url = this.getUrl();
+ private async fetchArtifact(
+ tmpPath: string,
+ etag: string,
+ ts: string
+ ): Promise {
+ const url = this.spec.url;
if (etag) {
- this._log.info('verifying cache of %s', chalk.bold(url));
+ this.log.info('verifying cache of %s', chalk.bold(url));
} else {
- this._log.info('downloading artifact from %s', chalk.bold(url));
+ this.log.info('downloading artifact from %s', chalk.bold(url));
}
const abc = new AbortController();
@@ -251,7 +270,7 @@ exports.Artifact = class Artifact {
});
if (resp.status === 304) {
- this._log.info('etags match, reusing cache from %s', chalk.bold(ts));
+ this.log.info('etags match, reusing cache from %s', chalk.bold(ts));
abc.abort();
return {
@@ -270,10 +289,10 @@ exports.Artifact = class Artifact {
}
if (etag) {
- this._log.info('cache invalid, redownloading');
+ this.log.info('cache invalid, redownloading');
}
- const hash = createHash(this.getChecksumType());
+ const hash = createHash(this.spec.checksumType);
let first500Bytes = Buffer.alloc(0);
let contentLength = 0;
@@ -300,8 +319,9 @@ exports.Artifact = class Artifact {
);
return {
+ cached: false,
checksum: hash.digest('hex'),
- etag: resp.headers.get('etag'),
+ etag: resp.headers.get('etag') ?? undefined,
contentLength,
first500Bytes,
headers: resp.headers,
@@ -310,14 +330,12 @@ exports.Artifact = class Artifact {
/**
* Verify the checksum of the downloaded artifact with the checksum at checksumUrl
- * @param {{ checksum: string, contentLength: number, first500Bytes: Buffer }} artifactResp
- * @return {Promise}
*/
- async _verifyChecksum(artifactResp) {
- this._log.info('downloading artifact checksum from %s', chalk.bold(this.getChecksumUrl()));
+ private async verifyChecksum(artifactResp: ArtifactDownloaded) {
+ this.log.info('downloading artifact checksum from %s', chalk.bold(this.spec.checksumUrl));
const abc = new AbortController();
- const resp = await fetch(this.getChecksumUrl(), {
+ const resp = await fetch(this.spec.checksumUrl, {
signal: abc.signal,
});
@@ -338,7 +356,7 @@ exports.Artifact = class Artifact {
const lenString = `${len} / ${artifactResp.contentLength}`;
throw createCliError(
- `artifact downloaded from ${this.getUrl()} does not match expected checksum\n` +
+ `artifact downloaded from ${this.spec.url} does not match expected checksum\n` +
` expected: ${expectedChecksum}\n` +
` received: ${artifactResp.checksum}\n` +
` headers: ${headersToString(artifactResp.headers, ' ')}\n` +
@@ -346,6 +364,6 @@ exports.Artifact = class Artifact {
);
}
- this._log.info('checksum verified');
+ this.log.info('checksum verified');
}
-};
+}
diff --git a/packages/kbn-es/src/custom_snapshots.js b/packages/kbn-es/src/custom_snapshots.ts
similarity index 82%
rename from packages/kbn-es/src/custom_snapshots.js
rename to packages/kbn-es/src/custom_snapshots.ts
index 9dd8097244947..f3e6d3ecaf857 100644
--- a/packages/kbn-es/src/custom_snapshots.js
+++ b/packages/kbn-es/src/custom_snapshots.ts
@@ -6,13 +6,15 @@
* Side Public License, v 1.
*/
-const { basename } = require('path');
+import Path from 'path';
-function isVersionFlag(a) {
+import type { ArtifactSpec } from './artifact';
+
+function isVersionFlag(a: string) {
return a.startsWith('--version');
}
-function getCustomSnapshotUrl() {
+export function getCustomSnapshotUrl() {
// force use of manually created snapshots until ReindexPutMappings fix
if (
!process.env.ES_SNAPSHOT_MANIFEST &&
@@ -28,7 +30,10 @@ function getCustomSnapshotUrl() {
}
}
-function resolveCustomSnapshotUrl(urlVersion, license) {
+export function resolveCustomSnapshotUrl(
+ urlVersion: string,
+ license: string
+): ArtifactSpec | undefined {
const customSnapshotUrl = getCustomSnapshotUrl();
if (!customSnapshotUrl) {
@@ -48,8 +53,6 @@ function resolveCustomSnapshotUrl(urlVersion, license) {
url: overrideUrl,
checksumUrl: overrideUrl + '.sha512',
checksumType: 'sha512',
- filename: basename(overrideUrl),
+ filename: Path.basename(overrideUrl),
};
}
-
-module.exports = { getCustomSnapshotUrl, resolveCustomSnapshotUrl };
diff --git a/packages/kbn-es/src/errors.ts b/packages/kbn-es/src/errors.ts
new file mode 100644
index 0000000000000..a0c526dc48a9c
--- /dev/null
+++ b/packages/kbn-es/src/errors.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
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+interface CliError extends Error {
+ isCliError: boolean;
+}
+
+export function createCliError(message: string) {
+ return Object.assign(new Error(message), {
+ isCliError: true,
+ });
+}
+
+function isObj(x: unknown): x is Record {
+ return typeof x === 'object' && x !== null;
+}
+
+export function isCliError(error: unknown): error is CliError {
+ return isObj(error) && error.isCliError === true;
+}
diff --git a/packages/kbn-es/src/index.js b/packages/kbn-es/src/index.ts
similarity index 72%
rename from packages/kbn-es/src/index.js
rename to packages/kbn-es/src/index.ts
index 3b12de68234fa..68fd931794c0c 100644
--- a/packages/kbn-es/src/index.js
+++ b/packages/kbn-es/src/index.ts
@@ -6,5 +6,7 @@
* Side Public License, v 1.
*/
-exports.run = require('./cli').run;
-exports.Cluster = require('./cluster').Cluster;
+// @ts-expect-error not typed yet
+export { run } from './cli';
+// @ts-expect-error not typed yet
+export { Cluster } from './cluster';
diff --git a/packages/kbn-es/src/install/index.js b/packages/kbn-es/src/install/index.js
deleted file mode 100644
index 07582f73c663a..0000000000000
--- a/packages/kbn-es/src/install/index.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-exports.installArchive = require('./archive').installArchive;
-exports.installSnapshot = require('./snapshot').installSnapshot;
-exports.downloadSnapshot = require('./snapshot').downloadSnapshot;
-exports.installSource = require('./source').installSource;
diff --git a/src/plugins/discover/public/utils/get_single_doc_url.ts b/packages/kbn-es/src/install/index.ts
similarity index 65%
rename from src/plugins/discover/public/utils/get_single_doc_url.ts
rename to packages/kbn-es/src/install/index.ts
index 913463e6d44a4..e827dee2247f9 100644
--- a/src/plugins/discover/public/utils/get_single_doc_url.ts
+++ b/packages/kbn-es/src/install/index.ts
@@ -6,6 +6,6 @@
* Side Public License, v 1.
*/
-export const getSingleDocUrl = (indexPatternId: string, rowIndex: string, rowId: string) => {
- return `/app/discover#/doc/${indexPatternId}/${rowIndex}?id=${encodeURIComponent(rowId)}`;
-};
+export { installArchive } from './install_archive';
+export { installSnapshot, downloadSnapshot } from './install_snapshot';
+export { installSource } from './install_source';
diff --git a/packages/kbn-es/src/install/archive.js b/packages/kbn-es/src/install/install_archive.ts
similarity index 64%
rename from packages/kbn-es/src/install/archive.js
rename to packages/kbn-es/src/install/install_archive.ts
index 76db5a4427e6d..ee04d9e4b62b5 100644
--- a/packages/kbn-es/src/install/archive.js
+++ b/packages/kbn-es/src/install/install_archive.ts
@@ -6,29 +6,40 @@
* Side Public License, v 1.
*/
-const fs = require('fs');
-const path = require('path');
-const chalk = require('chalk');
-const execa = require('execa');
-const del = require('del');
-const url = require('url');
-const { extract } = require('@kbn/dev-utils');
-const { log: defaultLog } = require('../utils');
-const { BASE_PATH, ES_CONFIG, ES_KEYSTORE_BIN } = require('../paths');
-const { Artifact } = require('../artifact');
-const { parseSettings, SettingsFilter } = require('../settings');
+import fs from 'fs';
+import path from 'path';
+
+import chalk from 'chalk';
+import execa from 'execa';
+import del from 'del';
+import { extract, ToolingLog } from '@kbn/dev-utils';
+
+import { BASE_PATH, ES_CONFIG, ES_KEYSTORE_BIN } from '../paths';
+import { Artifact } from '../artifact';
+import { parseSettings, SettingsFilter } from '../settings';
+import { log as defaultLog } from '../utils/log';
+
+interface InstallArchiveOptions {
+ license?: string;
+ password?: string;
+ basePath?: string;
+ installPath?: string;
+ log?: ToolingLog;
+ esArgs?: string[];
+}
+
+const isHttpUrl = (str: string) => {
+ try {
+ return ['http:', 'https:'].includes(new URL(str).protocol);
+ } catch {
+ return false;
+ }
+};
/**
* Extracts an ES archive and optionally installs plugins
- *
- * @param {String} archive - path to tar
- * @param {Object} options
- * @property {('oss'|'basic'|'trial')} options.license
- * @property {String} options.basePath
- * @property {String} options.installPath
- * @property {ToolingLog} options.log
*/
-exports.installArchive = async function installArchive(archive, options = {}) {
+export async function installArchive(archive: string, options: InstallArchiveOptions = {}) {
const {
license = 'basic',
password = 'changeme',
@@ -39,9 +50,9 @@ exports.installArchive = async function installArchive(archive, options = {}) {
} = options;
let dest = archive;
- if (['http:', 'https:'].includes(url.parse(archive).protocol)) {
+ if (isHttpUrl(archive)) {
const artifact = await Artifact.getArchive(archive, log);
- dest = path.resolve(basePath, 'cache', artifact.getFilename());
+ dest = path.resolve(basePath, 'cache', artifact.spec.filename);
await artifact.download(dest);
}
@@ -75,28 +86,23 @@ exports.installArchive = async function installArchive(archive, options = {}) {
}
return { installPath };
-};
+}
/**
* Appends single line to elasticsearch.yml config file
- *
- * @param {String} installPath
- * @param {String} key
- * @param {String} value
*/
-async function appendToConfig(installPath, key, value) {
+async function appendToConfig(installPath: string, key: string, value: string) {
fs.appendFileSync(path.resolve(installPath, ES_CONFIG), `${key}: ${value}\n`, 'utf8');
}
/**
* Creates and configures Keystore
- *
- * @param {String} installPath
- * @param {ToolingLog} log
- * @param {Array<[string, string]>} secureSettings List of custom Elasticsearch secure settings to
- * add into the keystore.
*/
-async function configureKeystore(installPath, log = defaultLog, secureSettings) {
+async function configureKeystore(
+ installPath: string,
+ log: ToolingLog = defaultLog,
+ secureSettings: Array<[string, string]>
+) {
const env = { JAVA_HOME: '' };
await execa(ES_KEYSTORE_BIN, ['create'], { cwd: installPath, env });
diff --git a/packages/kbn-es/src/install/snapshot.js b/packages/kbn-es/src/install/install_snapshot.ts
similarity index 55%
rename from packages/kbn-es/src/install/snapshot.js
rename to packages/kbn-es/src/install/install_snapshot.ts
index cf1ce50f7e413..84d713745eb82 100644
--- a/packages/kbn-es/src/install/snapshot.js
+++ b/packages/kbn-es/src/install/install_snapshot.ts
@@ -6,56 +6,58 @@
* Side Public License, v 1.
*/
-const chalk = require('chalk');
-const path = require('path');
-const { BASE_PATH } = require('../paths');
-const { installArchive } = require('./archive');
-const { log: defaultLog } = require('../utils');
-const { Artifact } = require('../artifact');
+import path from 'path';
+
+import chalk from 'chalk';
+import { ToolingLog } from '@kbn/dev-utils';
+
+import { BASE_PATH } from '../paths';
+import { installArchive } from './install_archive';
+import { log as defaultLog } from '../utils/log';
+import { Artifact, ArtifactLicense } from '../artifact';
+
+interface DownloadSnapshotOptions {
+ version: string;
+ license?: ArtifactLicense;
+ basePath?: string;
+ installPath?: string;
+ log?: ToolingLog;
+ useCached?: boolean;
+}
/**
* Download an ES snapshot
- *
- * @param {Object} options
- * @property {('oss'|'basic'|'trial')} options.license
- * @property {String} options.version
- * @property {String} options.basePath
- * @property {String} options.installPath
- * @property {ToolingLog} options.log
*/
-exports.downloadSnapshot = async function installSnapshot({
+export async function downloadSnapshot({
license = 'basic',
version,
basePath = BASE_PATH,
installPath = path.resolve(basePath, version),
log = defaultLog,
useCached = false,
-}) {
+}: DownloadSnapshotOptions) {
log.info('version: %s', chalk.bold(version));
log.info('install path: %s', chalk.bold(installPath));
log.info('license: %s', chalk.bold(license));
const artifact = await Artifact.getSnapshot(license, version, log);
- const dest = path.resolve(basePath, 'cache', artifact.getFilename());
+ const dest = path.resolve(basePath, 'cache', artifact.spec.filename);
await artifact.download(dest, { useCached });
return {
downloadPath: dest,
};
-};
+}
+
+interface InstallSnapshotOptions extends DownloadSnapshotOptions {
+ password?: string;
+ esArgs?: string[];
+}
/**
* Installs ES from snapshot
- *
- * @param {Object} options
- * @property {('oss'|'basic'|'trial')} options.license
- * @property {String} options.password
- * @property {String} options.version
- * @property {String} options.basePath
- * @property {String} options.installPath
- * @property {ToolingLog} options.log
*/
-exports.installSnapshot = async function installSnapshot({
+export async function installSnapshot({
license = 'basic',
password = 'password',
version,
@@ -64,8 +66,8 @@ exports.installSnapshot = async function installSnapshot({
log = defaultLog,
esArgs,
useCached = false,
-}) {
- const { downloadPath } = await exports.downloadSnapshot({
+}: InstallSnapshotOptions) {
+ const { downloadPath } = await downloadSnapshot({
license,
version,
basePath,
@@ -82,4 +84,4 @@ exports.installSnapshot = async function installSnapshot({
log,
esArgs,
});
-};
+}
diff --git a/packages/kbn-es/src/install/source.js b/packages/kbn-es/src/install/install_source.ts
similarity index 73%
rename from packages/kbn-es/src/install/source.js
rename to packages/kbn-es/src/install/install_source.ts
index 81a1019509906..d8c272677058e 100644
--- a/packages/kbn-es/src/install/source.js
+++ b/packages/kbn-es/src/install/install_source.ts
@@ -6,28 +6,35 @@
* Side Public License, v 1.
*/
-const path = require('path');
-const fs = require('fs');
-const os = require('os');
-const chalk = require('chalk');
-const crypto = require('crypto');
-const simpleGit = require('simple-git/promise');
-const { installArchive } = require('./archive');
-const { log: defaultLog, cache, buildSnapshot, archiveForPlatform } = require('../utils');
-const { BASE_PATH } = require('../paths');
+import path from 'path';
+import fs from 'fs';
+import os from 'os';
+import crypto from 'crypto';
+
+import chalk from 'chalk';
+import simpleGit from 'simple-git/promise';
+import { ToolingLog } from '@kbn/dev-utils';
+
+import { installArchive } from './install_archive';
+import { log as defaultLog } from '../utils/log';
+import { cache } from '../utils/cache';
+import { buildSnapshot, archiveForPlatform } from '../utils/build_snapshot';
+import { BASE_PATH } from '../paths';
+
+interface InstallSourceOptions {
+ sourcePath: string;
+ license?: string;
+ password?: string;
+ basePath?: string;
+ installPath?: string;
+ log?: ToolingLog;
+ esArgs?: string[];
+}
/**
* Installs ES from source
- *
- * @param {Object} options
- * @property {('oss'|'basic'|'trial')} options.license
- * @property {String} options.password
- * @property {String} options.sourcePath
- * @property {String} options.basePath
- * @property {String} options.installPath
- * @property {ToolingLog} options.log
*/
-exports.installSource = async function installSource({
+export async function installSource({
license = 'basic',
password = 'changeme',
sourcePath,
@@ -35,7 +42,7 @@ exports.installSource = async function installSource({
installPath = path.resolve(basePath, 'source'),
log = defaultLog,
esArgs,
-}) {
+}: InstallSourceOptions) {
log.info('source path: %s', chalk.bold(sourcePath));
log.info('install path: %s', chalk.bold(installPath));
log.info('license: %s', chalk.bold(license));
@@ -62,14 +69,9 @@ exports.installSource = async function installSource({
log,
esArgs,
});
-};
+}
-/**
- *
- * @param {String} cwd
- * @param {ToolingLog} log
- */
-async function sourceInfo(cwd, license, log = defaultLog) {
+async function sourceInfo(cwd: string, license: string, log: ToolingLog = defaultLog) {
if (!fs.existsSync(cwd)) {
throw new Error(`${cwd} does not exist`);
}
diff --git a/packages/kbn-es/src/paths.js b/packages/kbn-es/src/paths.js
deleted file mode 100644
index 5c8d3b654ecf9..0000000000000
--- a/packages/kbn-es/src/paths.js
+++ /dev/null
@@ -1,24 +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
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-const os = require('os');
-const path = require('path');
-
-function maybeUseBat(bin) {
- return os.platform().startsWith('win') ? `${bin}.bat` : bin;
-}
-
-const tempDir = os.tmpdir();
-
-exports.BASE_PATH = path.resolve(tempDir, 'kbn-es');
-
-exports.GRADLE_BIN = maybeUseBat('./gradlew');
-exports.ES_BIN = maybeUseBat('bin/elasticsearch');
-exports.ES_CONFIG = 'config/elasticsearch.yml';
-
-exports.ES_KEYSTORE_BIN = maybeUseBat('./bin/elasticsearch-keystore');
diff --git a/packages/kbn-es/src/paths.ts b/packages/kbn-es/src/paths.ts
new file mode 100644
index 0000000000000..c1b859af4e1f5
--- /dev/null
+++ b/packages/kbn-es/src/paths.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import Os from 'os';
+import Path from 'path';
+
+function maybeUseBat(bin: string) {
+ return Os.platform().startsWith('win') ? `${bin}.bat` : bin;
+}
+
+const tempDir = Os.tmpdir();
+
+export const BASE_PATH = Path.resolve(tempDir, 'kbn-es');
+
+export const GRADLE_BIN = maybeUseBat('./gradlew');
+export const ES_BIN = maybeUseBat('bin/elasticsearch');
+export const ES_CONFIG = 'config/elasticsearch.yml';
+
+export const ES_KEYSTORE_BIN = maybeUseBat('./bin/elasticsearch-keystore');
diff --git a/packages/kbn-es/src/utils/build_snapshot.js b/packages/kbn-es/src/utils/build_snapshot.ts
similarity index 53%
rename from packages/kbn-es/src/utils/build_snapshot.js
rename to packages/kbn-es/src/utils/build_snapshot.ts
index ec26ba69e658b..542e63dcc0748 100644
--- a/packages/kbn-es/src/utils/build_snapshot.js
+++ b/packages/kbn-es/src/utils/build_snapshot.ts
@@ -6,25 +6,25 @@
* Side Public License, v 1.
*/
-const execa = require('execa');
-const path = require('path');
-const os = require('os');
-const readline = require('readline');
-const { createCliError } = require('../errors');
-const { findMostRecentlyChanged } = require('../utils');
-const { GRADLE_BIN } = require('../paths');
+import path from 'path';
+import os from 'os';
-const onceEvent = (emitter, event) => new Promise((resolve) => emitter.once(event, resolve));
+import { ToolingLog, withProcRunner } from '@kbn/dev-utils';
+
+import { createCliError } from '../errors';
+import { findMostRecentlyChanged } from './find_most_recently_changed';
+import { GRADLE_BIN } from '../paths';
+
+interface BuildSnapshotOptions {
+ license: string;
+ sourcePath: string;
+ log: ToolingLog;
+ platform?: string;
+}
/**
* Creates archive from source
*
- * @param {Object} options
- * @property {('oss'|'basic'|'trial')} options.license
- * @property {String} options.sourcePath
- * @property {ToolingLog} options.log
- * @returns {Object} containing archive and optional plugins
- *
* Gradle tasks:
* $ ./gradlew tasks --all | grep 'distribution.*assemble\s'
* :distribution:archives:darwin-tar:assemble
@@ -34,39 +34,27 @@ const onceEvent = (emitter, event) => new Promise((resolve) => emitter.once(even
* :distribution:archives:oss-linux-tar:assemble
* :distribution:archives:oss-windows-zip:assemble
*/
-exports.buildSnapshot = async ({ license, sourcePath, log, platform = os.platform() }) => {
+export async function buildSnapshot({
+ license,
+ sourcePath,
+ log,
+ platform = os.platform(),
+}: BuildSnapshotOptions) {
const { task, ext } = exports.archiveForPlatform(platform, license);
const buildArgs = [`:distribution:archives:${task}:assemble`];
log.info('%s %s', GRADLE_BIN, buildArgs.join(' '));
log.debug('cwd:', sourcePath);
- const build = execa(GRADLE_BIN, buildArgs, {
- cwd: sourcePath,
- stdio: ['ignore', 'pipe', 'pipe'],
+ await withProcRunner(log, async (procs) => {
+ await procs.run('gradle', {
+ cmd: GRADLE_BIN,
+ args: buildArgs,
+ cwd: sourcePath,
+ wait: true,
+ });
});
- const stdout = readline.createInterface({ input: build.stdout });
- const stderr = readline.createInterface({ input: build.stderr });
-
- stdout.on('line', (line) => log.debug(line));
- stderr.on('line', (line) => log.error(line));
-
- const [exitCode] = await Promise.all([
- Promise.race([
- onceEvent(build, 'exit'),
- onceEvent(build, 'error').then((error) => {
- throw createCliError(`Error spawning gradle: ${error.message}`);
- }),
- ]),
- onceEvent(stdout, 'close'),
- onceEvent(stderr, 'close'),
- ]);
-
- if (exitCode > 0) {
- throw createCliError('unable to build ES');
- }
-
const archivePattern = `distribution/archives/${task}/build/distributions/elasticsearch-*.${ext}`;
const esArchivePath = findMostRecentlyChanged(path.resolve(sourcePath, archivePattern));
@@ -75,9 +63,9 @@ exports.buildSnapshot = async ({ license, sourcePath, log, platform = os.platfor
}
return esArchivePath;
-};
+}
-exports.archiveForPlatform = (platform, license) => {
+export function archiveForPlatform(platform: NodeJS.Platform, license: string) {
const taskPrefix = license === 'oss' ? 'oss-' : '';
switch (platform) {
@@ -88,6 +76,6 @@ exports.archiveForPlatform = (platform, license) => {
case 'linux':
return { format: 'tar', ext: 'tar.gz', task: `${taskPrefix}linux-tar`, platform: 'linux' };
default:
- throw new Error(`unknown platform: ${platform}`);
+ throw new Error(`unsupported platform: ${platform}`);
}
-};
+}
diff --git a/packages/kbn-es/src/utils/cache.js b/packages/kbn-es/src/utils/cache.js
deleted file mode 100644
index 248faf23bbc46..0000000000000
--- a/packages/kbn-es/src/utils/cache.js
+++ /dev/null
@@ -1,41 +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
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-const fs = require('fs');
-const path = require('path');
-
-exports.readMeta = function readMeta(file) {
- try {
- const meta = fs.readFileSync(`${file}.meta`, {
- encoding: 'utf8',
- });
-
- return {
- exists: fs.existsSync(file),
- ...JSON.parse(meta),
- };
- } catch (e) {
- if (e.code !== 'ENOENT') {
- throw e;
- }
-
- return {
- exists: false,
- };
- }
-};
-
-exports.writeMeta = function readMeta(file, details = {}) {
- const meta = {
- ts: new Date(),
- ...details,
- };
-
- fs.mkdirSync(path.dirname(file), { recursive: true });
- fs.writeFileSync(`${file}.meta`, JSON.stringify(meta, null, 2));
-};
diff --git a/packages/kbn-es/src/utils/cache.ts b/packages/kbn-es/src/utils/cache.ts
new file mode 100644
index 0000000000000..819119b6ce010
--- /dev/null
+++ b/packages/kbn-es/src/utils/cache.ts
@@ -0,0 +1,40 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import Fs from 'fs';
+import Path from 'path';
+
+export const cache = {
+ readMeta(path: string) {
+ try {
+ const meta = Fs.readFileSync(`${path}.meta`, {
+ encoding: 'utf8',
+ });
+
+ return {
+ ...JSON.parse(meta),
+ };
+ } catch (e) {
+ if (e.code !== 'ENOENT') {
+ throw e;
+ }
+
+ return {};
+ }
+ },
+
+ writeMeta(path: string, details = {}) {
+ const meta = {
+ ts: new Date(),
+ ...details,
+ };
+
+ Fs.mkdirSync(Path.dirname(path), { recursive: true });
+ Fs.writeFileSync(`${path}.meta`, JSON.stringify(meta, null, 2));
+ },
+};
diff --git a/packages/kbn-es/src/utils/find_most_recently_changed.test.js b/packages/kbn-es/src/utils/find_most_recently_changed.test.ts
similarity index 93%
rename from packages/kbn-es/src/utils/find_most_recently_changed.test.js
rename to packages/kbn-es/src/utils/find_most_recently_changed.test.ts
index 8198495e7197f..721e5baba7513 100644
--- a/packages/kbn-es/src/utils/find_most_recently_changed.test.js
+++ b/packages/kbn-es/src/utils/find_most_recently_changed.test.ts
@@ -6,6 +6,8 @@
* Side Public License, v 1.
*/
+import { findMostRecentlyChanged } from './find_most_recently_changed';
+
jest.mock('fs', () => ({
statSync: jest.fn().mockImplementation((path) => {
if (path.includes('oldest')) {
@@ -31,8 +33,6 @@ jest.mock('fs', () => ({
}),
}));
-const { findMostRecentlyChanged } = require('./find_most_recently_changed');
-
test('returns newest file', () => {
const file = findMostRecentlyChanged('/data/*.yml');
expect(file).toEqual('/data/newest.yml');
diff --git a/packages/kbn-es/src/utils/find_most_recently_changed.js b/packages/kbn-es/src/utils/find_most_recently_changed.ts
similarity index 65%
rename from packages/kbn-es/src/utils/find_most_recently_changed.js
rename to packages/kbn-es/src/utils/find_most_recently_changed.ts
index 16d300f080b8d..29e1edcc5fcc9 100644
--- a/packages/kbn-es/src/utils/find_most_recently_changed.js
+++ b/packages/kbn-es/src/utils/find_most_recently_changed.ts
@@ -6,25 +6,22 @@
* Side Public License, v 1.
*/
-const path = require('path');
-const fs = require('fs');
-const glob = require('glob');
+import path from 'path';
+import fs from 'fs';
+import glob from 'glob';
/**
* Find the most recently modified file that matches the pattern pattern
- *
- * @param {String} pattern absolute path with glob expressions
- * @return {String} Absolute path
*/
-exports.findMostRecentlyChanged = function findMostRecentlyChanged(pattern) {
+export function findMostRecentlyChanged(pattern: string) {
if (!path.isAbsolute(pattern)) {
throw new TypeError(`Pattern must be absolute, got ${pattern}`);
}
- const ctime = (path) => fs.statSync(path).ctime.getTime();
+ const ctime = (p: string) => fs.statSync(p).ctime.getTime();
return glob
.sync(pattern)
.sort((a, b) => ctime(a) - ctime(b))
.pop();
-};
+}
diff --git a/packages/kbn-es/src/utils/index.js b/packages/kbn-es/src/utils/index.js
deleted file mode 100644
index ed83495e5310a..0000000000000
--- a/packages/kbn-es/src/utils/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-exports.cache = require('./cache');
-exports.log = require('./log').log;
-exports.parseEsLog = require('./parse_es_log').parseEsLog;
-exports.findMostRecentlyChanged = require('./find_most_recently_changed').findMostRecentlyChanged;
-exports.extractConfigFiles = require('./extract_config_files').extractConfigFiles;
-exports.NativeRealm = require('./native_realm').NativeRealm;
-exports.buildSnapshot = require('./build_snapshot').buildSnapshot;
-exports.archiveForPlatform = require('./build_snapshot').archiveForPlatform;
diff --git a/packages/kbn-es/src/utils/index.ts b/packages/kbn-es/src/utils/index.ts
new file mode 100644
index 0000000000000..ce0a222dafd3b
--- /dev/null
+++ b/packages/kbn-es/src/utils/index.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export { cache } from './cache';
+export { log } from './log';
+// @ts-expect-error not typed yet
+export { parseEsLog } from './parse_es_log';
+export { findMostRecentlyChanged } from './find_most_recently_changed';
+// @ts-expect-error not typed yet
+export { extractConfigFiles } from './extract_config_files';
+// @ts-expect-error not typed yet
+export { NativeRealm } from './native_realm';
+export { buildSnapshot } from './build_snapshot';
+export { archiveForPlatform } from './build_snapshot';
diff --git a/packages/kbn-es/src/utils/log.js b/packages/kbn-es/src/utils/log.ts
similarity index 80%
rename from packages/kbn-es/src/utils/log.js
rename to packages/kbn-es/src/utils/log.ts
index b33ae509c6c45..a0299f885cf6a 100644
--- a/packages/kbn-es/src/utils/log.js
+++ b/packages/kbn-es/src/utils/log.ts
@@ -6,11 +6,9 @@
* Side Public License, v 1.
*/
-const { ToolingLog } = require('@kbn/dev-utils');
+import { ToolingLog } from '@kbn/dev-utils';
-const log = new ToolingLog({
+export const log = new ToolingLog({
level: 'verbose',
writeTo: process.stdout,
});
-
-exports.log = log;
diff --git a/packages/kbn-eslint-import-resolver-kibana/BUILD.bazel b/packages/kbn-eslint-import-resolver-kibana/BUILD.bazel
index a4d96f76053e1..759f4ac706471 100644
--- a/packages/kbn-eslint-import-resolver-kibana/BUILD.bazel
+++ b/packages/kbn-eslint-import-resolver-kibana/BUILD.bazel
@@ -1,4 +1,5 @@
-load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
+load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
+load("//src/dev/bazel:index.bzl", "pkg_npm")
PKG_BASE_NAME = "kbn-eslint-import-resolver-kibana"
PKG_REQUIRE_NAME = "@kbn/eslint-import-resolver-kibana"
diff --git a/packages/kbn-eslint-plugin-eslint/helpers/exports.js b/packages/kbn-eslint-plugin-eslint/helpers/exports.js
index b7af8e83d7661..971364633356c 100644
--- a/packages/kbn-eslint-plugin-eslint/helpers/exports.js
+++ b/packages/kbn-eslint-plugin-eslint/helpers/exports.js
@@ -9,7 +9,7 @@
const Fs = require('fs');
const Path = require('path');
const ts = require('typescript');
-const { REPO_ROOT } = require('@kbn/dev-utils');
+const { REPO_ROOT } = require('@kbn/utils');
const { ExportSet } = require('./export_set');
/** @typedef {import("@typescript-eslint/types").TSESTree.ExportAllDeclaration} ExportAllDeclaration */
diff --git a/packages/kbn-optimizer/BUILD.bazel b/packages/kbn-optimizer/BUILD.bazel
index a389086c9ee3c..3bd41249e2d51 100644
--- a/packages/kbn-optimizer/BUILD.bazel
+++ b/packages/kbn-optimizer/BUILD.bazel
@@ -38,10 +38,12 @@ RUNTIME_DEPS = [
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-utils",
+ "@npm//@babel/core",
"@npm//chalk",
"@npm//clean-webpack-plugin",
"@npm//compression-webpack-plugin",
"@npm//cpy",
+ "@npm//dedent",
"@npm//del",
"@npm//execa",
"@npm//jest-diff",
@@ -64,7 +66,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
@@ -79,7 +81,9 @@ TYPES_DEPS = [
"@npm//pirates",
"@npm//rxjs",
"@npm//zlib",
+ "@npm//@types/babel__core",
"@npm//@types/compression-webpack-plugin",
+ "@npm//@types/dedent",
"@npm//@types/jest",
"@npm//@types/json-stable-stringify",
"@npm//@types/js-yaml",
diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml
index 41c4d3bdd1b35..1de3a8a1b3976 100644
--- a/packages/kbn-optimizer/limits.yml
+++ b/packages/kbn-optimizer/limits.yml
@@ -117,3 +117,4 @@ pageLoadAssetSize:
dataViewManagement: 5000
reporting: 57003
visTypeHeatmap: 25340
+ screenshotting: 17017
diff --git a/packages/kbn-optimizer/src/babel_runtime_helpers/find_babel_runtime_helpers_in_entry_bundles.ts b/packages/kbn-optimizer/src/babel_runtime_helpers/find_babel_runtime_helpers_in_entry_bundles.ts
index f00905f3f4920..c07a9764af76f 100644
--- a/packages/kbn-optimizer/src/babel_runtime_helpers/find_babel_runtime_helpers_in_entry_bundles.ts
+++ b/packages/kbn-optimizer/src/babel_runtime_helpers/find_babel_runtime_helpers_in_entry_bundles.ts
@@ -8,7 +8,8 @@
import Path from 'path';
-import { run, REPO_ROOT } from '@kbn/dev-utils';
+import { run } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { OptimizerConfig } from '../optimizer';
import { parseStats, inAnyEntryChunk } from './parse_stats';
diff --git a/packages/kbn-optimizer/src/node/node_auto_tranpilation.ts b/packages/kbn-optimizer/src/node/node_auto_tranpilation.ts
index 6f5dabf410ffa..2710ba8a54210 100644
--- a/packages/kbn-optimizer/src/node/node_auto_tranpilation.ts
+++ b/packages/kbn-optimizer/src/node/node_auto_tranpilation.ts
@@ -39,7 +39,7 @@ import Crypto from 'crypto';
import * as babel from '@babel/core';
import { addHook } from 'pirates';
-import { REPO_ROOT, UPSTREAM_BRANCH } from '@kbn/dev-utils';
+import { REPO_ROOT, UPSTREAM_BRANCH } from '@kbn/utils';
import sourceMapSupport from 'source-map-support';
import { Cache } from './cache';
diff --git a/packages/kbn-optimizer/src/optimizer/get_changes.test.ts b/packages/kbn-optimizer/src/optimizer/get_changes.test.ts
index d3cc5cceefddf..d1754248dba17 100644
--- a/packages/kbn-optimizer/src/optimizer/get_changes.test.ts
+++ b/packages/kbn-optimizer/src/optimizer/get_changes.test.ts
@@ -9,7 +9,8 @@
jest.mock('execa');
import { getChanges } from './get_changes';
-import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils';
+import { createAbsolutePathSerializer } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
const execa: jest.Mock = jest.requireMock('execa');
diff --git a/packages/kbn-optimizer/src/optimizer/get_changes.ts b/packages/kbn-optimizer/src/optimizer/get_changes.ts
index c5f8abe99c322..b59f938eb8c37 100644
--- a/packages/kbn-optimizer/src/optimizer/get_changes.ts
+++ b/packages/kbn-optimizer/src/optimizer/get_changes.ts
@@ -10,7 +10,7 @@ import Path from 'path';
import execa from 'execa';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
export type Changes = Map;
diff --git a/packages/kbn-plugin-generator/BUILD.bazel b/packages/kbn-plugin-generator/BUILD.bazel
index c935d1763dae8..488f09bdd5d52 100644
--- a/packages/kbn-plugin-generator/BUILD.bazel
+++ b/packages/kbn-plugin-generator/BUILD.bazel
@@ -51,7 +51,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-utils",
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"@npm//del",
"@npm//execa",
"@npm//globby",
diff --git a/packages/kbn-plugin-helpers/BUILD.bazel b/packages/kbn-plugin-helpers/BUILD.bazel
index d7744aecac26e..47f205f1530b7 100644
--- a/packages/kbn-plugin-helpers/BUILD.bazel
+++ b/packages/kbn-plugin-helpers/BUILD.bazel
@@ -42,7 +42,7 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-optimizer",
"//packages/kbn-utils",
"@npm//del",
diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js
index c1d0f69e4ea07..fc92d18698132 100644
--- a/packages/kbn-pm/dist/index.js
+++ b/packages/kbn-pm/dist/index.js
@@ -6639,7 +6639,15 @@ class ToolingLogTextWriter {
}
if (this.ignoreSources && msg.source && this.ignoreSources.includes(msg.source)) {
- return false;
+ if (msg.type === 'write') {
+ const txt = (0, _util.format)(msg.args[0], ...msg.args.slice(1)); // Ensure that Elasticsearch deprecation log messages from Kibana aren't ignored
+
+ if (!/elasticsearch\.deprecation/.test(txt)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
}
const prefix = has(MSG_PREFIXES, msg.type) ? MSG_PREFIXES[msg.type] : '';
diff --git a/packages/kbn-rule-data-utils/src/technical_field_names.ts b/packages/kbn-rule-data-utils/src/technical_field_names.ts
index 349719c019c22..fde8deade36b5 100644
--- a/packages/kbn-rule-data-utils/src/technical_field_names.ts
+++ b/packages/kbn-rule-data-utils/src/technical_field_names.ts
@@ -24,6 +24,7 @@ const VERSION = `${KIBANA_NAMESPACE}.version` as const;
// Fields pertaining to the alert
const ALERT_ACTION_GROUP = `${ALERT_NAMESPACE}.action_group` as const;
+const ALERT_BUILDING_BLOCK_TYPE = `${ALERT_NAMESPACE}.building_block_type` as const;
const ALERT_DURATION = `${ALERT_NAMESPACE}.duration.us` as const;
const ALERT_END = `${ALERT_NAMESPACE}.end` as const;
const ALERT_EVALUATION_THRESHOLD = `${ALERT_NAMESPACE}.evaluation.threshold` as const;
@@ -91,6 +92,7 @@ const fields = {
TAGS,
TIMESTAMP,
ALERT_ACTION_GROUP,
+ ALERT_BUILDING_BLOCK_TYPE,
ALERT_DURATION,
ALERT_END,
ALERT_EVALUATION_THRESHOLD,
@@ -141,6 +143,7 @@ const fields = {
export {
ALERT_ACTION_GROUP,
+ ALERT_BUILDING_BLOCK_TYPE,
ALERT_DURATION,
ALERT_END,
ALERT_EVALUATION_THRESHOLD,
diff --git a/packages/kbn-storybook/BUILD.bazel b/packages/kbn-storybook/BUILD.bazel
index f2a7bf25fb407..5dbe22b56c63f 100644
--- a/packages/kbn-storybook/BUILD.bazel
+++ b/packages/kbn-storybook/BUILD.bazel
@@ -32,6 +32,7 @@ RUNTIME_DEPS = [
"//packages/kbn-dev-utils",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
+ "//packages/kbn-utils",
"@npm//@storybook/addons",
"@npm//@storybook/api",
"@npm//@storybook/components",
@@ -47,9 +48,10 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
+ "//packages/kbn-utils",
"@npm//@storybook/addons",
"@npm//@storybook/api",
"@npm//@storybook/components",
diff --git a/packages/kbn-storybook/src/lib/constants.ts b/packages/kbn-storybook/src/lib/constants.ts
index 722f789fde786..69b05c94ea1b0 100644
--- a/packages/kbn-storybook/src/lib/constants.ts
+++ b/packages/kbn-storybook/src/lib/constants.ts
@@ -7,7 +7,7 @@
*/
import { resolve } from 'path';
-import { REPO_ROOT as KIBANA_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT as KIBANA_ROOT } from '@kbn/utils';
export const REPO_ROOT = KIBANA_ROOT;
export const ASSET_DIR = resolve(KIBANA_ROOT, 'built_assets/storybook');
diff --git a/packages/kbn-storybook/src/lib/theme_switcher.tsx b/packages/kbn-storybook/src/lib/theme_switcher.tsx
index 3d6f7999545a0..8cc805ee2e494 100644
--- a/packages/kbn-storybook/src/lib/theme_switcher.tsx
+++ b/packages/kbn-storybook/src/lib/theme_switcher.tsx
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import React from 'react';
+import React, { useCallback, useEffect } from 'react';
import { Icons, IconButton, TooltipLinkList, WithTooltip } from '@storybook/components';
import { useGlobals } from '@storybook/api';
@@ -17,14 +17,52 @@ type Link = ArrayItem['links']>;
const defaultTheme = 'v8.light';
export function ThemeSwitcher() {
- const [globals, updateGlobals] = useGlobals();
- const selectedTheme = globals.euiTheme;
+ const [{ euiTheme: selectedTheme }, updateGlobals] = useGlobals();
- if (!selectedTheme) {
- updateGlobals({ euiTheme: defaultTheme });
- }
+ const selectTheme = useCallback(
+ (themeId: string) => {
+ updateGlobals({ euiTheme: themeId });
+ },
+ [updateGlobals]
+ );
- function Menu({ onHide }: { onHide: () => void }) {
+ useEffect(() => {
+ if (!selectedTheme) {
+ selectTheme(defaultTheme);
+ }
+ }, [selectTheme, selectedTheme]);
+
+ return (
+ (
+
+ )}
+ >
+ {/* @ts-ignore Remove when @storybook has moved to @emotion v11 */}
+
+
+
+
+ );
+}
+
+const ThemeSwitcherTooltip = React.memo(
+ ({
+ onHide,
+ onChangeSelectedTheme,
+ selectedTheme,
+ }: {
+ onHide: () => void;
+ onChangeSelectedTheme: (themeId: string) => void;
+ selectedTheme: string;
+ }) => {
const links = [
{
id: 'v8.light',
@@ -38,8 +76,8 @@ export function ThemeSwitcher() {
(link): Link => ({
...link,
onClick: (_event, item) => {
- if (item.id !== selectedTheme) {
- updateGlobals({ euiTheme: item.id });
+ if (item.id != null && item.id !== selectedTheme) {
+ onChangeSelectedTheme(item.id);
}
onHide();
},
@@ -49,18 +87,4 @@ export function ThemeSwitcher() {
return ;
}
-
- return (
- }
- >
- {/* @ts-ignore Remove when @storybook has moved to @emotion v11 */}
-
-
-
-
- );
-}
+);
diff --git a/packages/kbn-telemetry-tools/BUILD.bazel b/packages/kbn-telemetry-tools/BUILD.bazel
index 1183de2586424..d2ea3a704f154 100644
--- a/packages/kbn-telemetry-tools/BUILD.bazel
+++ b/packages/kbn-telemetry-tools/BUILD.bazel
@@ -38,8 +38,9 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-utility-types",
+ "@npm//tslib",
"@npm//@types/glob",
"@npm//@types/jest",
"@npm//@types/listr",
diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel
index c42c33483703e..eae0fe2cdf5dc 100644
--- a/packages/kbn-test/BUILD.bazel
+++ b/packages/kbn-test/BUILD.bazel
@@ -44,11 +44,13 @@ RUNTIME_DEPS = [
"@npm//axios",
"@npm//@babel/traverse",
"@npm//chance",
+ "@npm//dedent",
"@npm//del",
"@npm//enzyme",
"@npm//execa",
"@npm//exit-hook",
"@npm//form-data",
+ "@npm//getopts",
"@npm//globby",
"@npm//he",
"@npm//history",
@@ -59,6 +61,7 @@ RUNTIME_DEPS = [
"@npm//@jest/reporters",
"@npm//joi",
"@npm//mustache",
+ "@npm//normalize-path",
"@npm//parse-link-header",
"@npm//prettier",
"@npm//react-dom",
@@ -72,12 +75,17 @@ RUNTIME_DEPS = [
]
TYPES_DEPS = [
- "//packages/kbn-dev-utils",
+ "//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-i18n-react:npm_module_types",
+ "//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@elastic/elasticsearch",
+ "@npm//axios",
+ "@npm//elastic-apm-node",
"@npm//del",
+ "@npm//exit-hook",
"@npm//form-data",
+ "@npm//getopts",
"@npm//jest",
"@npm//jest-cli",
"@npm//jest-snapshot",
@@ -85,6 +93,7 @@ TYPES_DEPS = [
"@npm//rxjs",
"@npm//xmlbuilder",
"@npm//@types/chance",
+ "@npm//@types/dedent",
"@npm//@types/enzyme",
"@npm//@types/he",
"@npm//@types/history",
@@ -92,6 +101,7 @@ TYPES_DEPS = [
"@npm//@types/joi",
"@npm//@types/lodash",
"@npm//@types/mustache",
+ "@npm//@types/normalize-path",
"@npm//@types/node",
"@npm//@types/parse-link-header",
"@npm//@types/prettier",
diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js
index db64f070b37d9..e2607100babc5 100644
--- a/packages/kbn-test/jest-preset.js
+++ b/packages/kbn-test/jest-preset.js
@@ -28,6 +28,7 @@ module.exports = {
moduleNameMapper: {
'@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1',
'@elastic/eui$': '/node_modules/@elastic/eui/test-env',
+ 'elastic-apm-node': '/node_modules/@kbn/test/target_node/jest/mocks/apm_agent_mock.js',
'\\.module.(css|scss)$':
'/node_modules/@kbn/test/target_node/jest/mocks/css_module_mock.js',
'\\.(css|less|scss)$': '/node_modules/@kbn/test/target_node/jest/mocks/style_mock.js',
diff --git a/packages/kbn-test/src/es/es_test_config.ts b/packages/kbn-test/src/es/es_test_config.ts
index db5d705710a75..70000c8068e9f 100644
--- a/packages/kbn-test/src/es/es_test_config.ts
+++ b/packages/kbn-test/src/es/es_test_config.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { kibanaPackageJson as pkg } from '@kbn/dev-utils';
+import { kibanaPackageJson as pkg } from '@kbn/utils';
import Url from 'url';
import { adminTestUser } from '../kbn';
diff --git a/packages/kbn-test/src/failed_tests_reporter/buildkite_metadata.ts b/packages/kbn-test/src/failed_tests_reporter/buildkite_metadata.ts
new file mode 100644
index 0000000000000..d63f0166390cb
--- /dev/null
+++ b/packages/kbn-test/src/failed_tests_reporter/buildkite_metadata.ts
@@ -0,0 +1,38 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export interface BuildkiteMetadata {
+ buildId?: string;
+ jobId?: string;
+ url?: string;
+ jobName?: string;
+ jobUrl?: string;
+}
+
+export function getBuildkiteMetadata(): BuildkiteMetadata {
+ // Buildkite steps that use `parallelism` need a numerical suffix added to identify them
+ // We should also increment the number by one, since it's 0-based
+ const jobNumberSuffix = process.env.BUILDKITE_PARALLEL_JOB
+ ? ` #${parseInt(process.env.BUILDKITE_PARALLEL_JOB, 10) + 1}`
+ : '';
+
+ const buildUrl = process.env.BUILDKITE_BUILD_URL;
+ const jobUrl = process.env.BUILDKITE_JOB_ID
+ ? `${buildUrl}#${process.env.BUILDKITE_JOB_ID}`
+ : undefined;
+
+ return {
+ buildId: process.env.BUJILDKITE_BUILD_ID,
+ jobId: process.env.BUILDKITE_JOB_ID,
+ url: buildUrl,
+ jobUrl,
+ jobName: process.env.BUILDKITE_LABEL
+ ? `${process.env.BUILDKITE_LABEL}${jobNumberSuffix}`
+ : undefined,
+ };
+}
diff --git a/packages/kbn-test/src/failed_tests_reporter/github_api.ts b/packages/kbn-test/src/failed_tests_reporter/github_api.ts
index adaae11b7aa16..bb7570225a013 100644
--- a/packages/kbn-test/src/failed_tests_reporter/github_api.ts
+++ b/packages/kbn-test/src/failed_tests_reporter/github_api.ts
@@ -42,6 +42,7 @@ export class GithubApi {
private readonly token: string | undefined;
private readonly dryRun: boolean;
private readonly x: AxiosInstance;
+ private requestCount: number = 0;
/**
* Create a GithubApi helper object, if token is undefined requests won't be
@@ -68,6 +69,10 @@ export class GithubApi {
});
}
+ getRequestCount() {
+ return this.requestCount;
+ }
+
private failedTestIssuesPageCache: {
pages: GithubIssue[][];
nextRequest: RequestOptions | undefined;
@@ -191,53 +196,50 @@ export class GithubApi {
}> {
const executeRequest = !this.dryRun || options.safeForDryRun;
const maxAttempts = options.maxAttempts || 5;
- const attempt = options.attempt || 1;
-
- this.log.verbose('Github API', executeRequest ? 'Request' : 'Dry Run', options);
-
- if (!executeRequest) {
- return {
- status: 200,
- statusText: 'OK',
- headers: {},
- data: dryRunResponse,
- };
- }
- try {
- return await this.x.request(options);
- } catch (error) {
- const unableToReachGithub = isAxiosRequestError(error);
- const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500;
- const errorResponseLog =
- isAxiosResponseError(error) &&
- `[${error.config.method} ${error.config.url}] ${error.response.status} ${error.response.statusText} Error`;
+ let attempt = 0;
+ while (true) {
+ attempt += 1;
+ this.log.verbose('Github API', executeRequest ? 'Request' : 'Dry Run', options);
+
+ if (!executeRequest) {
+ return {
+ status: 200,
+ statusText: 'OK',
+ headers: {},
+ data: dryRunResponse,
+ };
+ }
- if ((unableToReachGithub || githubApiFailed) && attempt < maxAttempts) {
- const waitMs = 1000 * attempt;
+ try {
+ this.requestCount += 1;
+ return await this.x.request(options);
+ } catch (error) {
+ const unableToReachGithub = isAxiosRequestError(error);
+ const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500;
+ const errorResponseLog =
+ isAxiosResponseError(error) &&
+ `[${error.config.method} ${error.config.url}] ${error.response.status} ${error.response.statusText} Error`;
+
+ if ((unableToReachGithub || githubApiFailed) && attempt < maxAttempts) {
+ const waitMs = 1000 * attempt;
+
+ if (errorResponseLog) {
+ this.log.error(`${errorResponseLog}: waiting ${waitMs}ms to retry`);
+ } else {
+ this.log.error(`Unable to reach github, waiting ${waitMs}ms to retry`);
+ }
+
+ await new Promise((resolve) => setTimeout(resolve, waitMs));
+ continue;
+ }
if (errorResponseLog) {
- this.log.error(`${errorResponseLog}: waiting ${waitMs}ms to retry`);
- } else {
- this.log.error(`Unable to reach github, waiting ${waitMs}ms to retry`);
+ throw new Error(`${errorResponseLog}: ${JSON.stringify(error.response.data)}`);
}
- await new Promise((resolve) => setTimeout(resolve, waitMs));
- return await this.request(
- {
- ...options,
- maxAttempts,
- attempt: attempt + 1,
- },
- dryRunResponse
- );
+ throw error;
}
-
- if (errorResponseLog) {
- throw new Error(`${errorResponseLog}: ${JSON.stringify(error.response.data)}`);
- }
-
- throw error;
}
}
}
diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts
index e481da019945c..33dab240ec8b4 100644
--- a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts
+++ b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts
@@ -14,6 +14,7 @@ import { ToolingLog } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';
import { escape } from 'he';
+import { BuildkiteMetadata } from './buildkite_metadata';
import { TestFailure } from './get_failures';
const findScreenshots = (dirPath: string, allScreenshots: string[] = []) => {
@@ -37,7 +38,11 @@ const findScreenshots = (dirPath: string, allScreenshots: string[] = []) => {
return allScreenshots;
};
-export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) {
+export function reportFailuresToFile(
+ log: ToolingLog,
+ failures: TestFailure[],
+ bkMeta: BuildkiteMetadata
+) {
if (!failures?.length) {
return;
}
@@ -76,28 +81,15 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) {
.flat()
.join('\n');
- // Buildkite steps that use `parallelism` need a numerical suffix added to identify them
- // We should also increment the number by one, since it's 0-based
- const jobNumberSuffix = process.env.BUILDKITE_PARALLEL_JOB
- ? ` #${parseInt(process.env.BUILDKITE_PARALLEL_JOB, 10) + 1}`
- : '';
-
- const buildUrl = process.env.BUILDKITE_BUILD_URL || '';
- const jobUrl = process.env.BUILDKITE_JOB_ID
- ? `${buildUrl}#${process.env.BUILDKITE_JOB_ID}`
- : '';
-
const failureJSON = JSON.stringify(
{
...failure,
hash,
- buildId: process.env.BUJILDKITE_BUILD_ID || '',
- jobId: process.env.BUILDKITE_JOB_ID || '',
- url: buildUrl,
- jobUrl,
- jobName: process.env.BUILDKITE_LABEL
- ? `${process.env.BUILDKITE_LABEL}${jobNumberSuffix}`
- : '',
+ buildId: bkMeta.buildId,
+ jobId: bkMeta.jobId,
+ url: bkMeta.url,
+ jobUrl: bkMeta.jobUrl,
+ jobName: bkMeta.jobName,
},
null,
2
@@ -149,11 +141,11 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) {
${
- jobUrl
+ bkMeta.jobUrl
? `
Buildkite Job
- ${escape(jobUrl)}
+ ${escape(bkMeta.jobUrl)}
`
: ''
diff --git a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts
index 193bc668ce003..ecd3007685b76 100644
--- a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts
+++ b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts
@@ -9,7 +9,7 @@
import Path from 'path';
import { REPO_ROOT } from '@kbn/utils';
-import { run, createFailError, createFlagError } from '@kbn/dev-utils';
+import { run, createFailError, createFlagError, CiStatsReporter } from '@kbn/dev-utils';
import globby from 'globby';
import normalize from 'normalize-path';
@@ -22,6 +22,7 @@ import { addMessagesToReport } from './add_messages_to_report';
import { getReportMessageIter } from './report_metadata';
import { reportFailuresToEs } from './report_failures_to_es';
import { reportFailuresToFile } from './report_failures_to_file';
+import { getBuildkiteMetadata } from './buildkite_metadata';
const DEFAULT_PATTERNS = [Path.resolve(REPO_ROOT, 'target/junit/**/*.xml')];
@@ -71,108 +72,127 @@ export function runFailedTestsReporterCli() {
dryRun: !updateGithub,
});
- const buildUrl = flags['build-url'] || (updateGithub ? '' : 'http://buildUrl');
- if (typeof buildUrl !== 'string' || !buildUrl) {
- throw createFlagError('Missing --build-url or process.env.BUILD_URL');
- }
+ const bkMeta = getBuildkiteMetadata();
- const patterns = (flags._.length ? flags._ : DEFAULT_PATTERNS).map((p) =>
- normalize(Path.resolve(p))
- );
- log.info('Searching for reports at', patterns);
- const reportPaths = await globby(patterns, {
- absolute: true,
- });
+ try {
+ const buildUrl = flags['build-url'] || (updateGithub ? '' : 'http://buildUrl');
+ if (typeof buildUrl !== 'string' || !buildUrl) {
+ throw createFlagError('Missing --build-url or process.env.BUILD_URL');
+ }
- if (!reportPaths.length) {
- throw createFailError(`Unable to find any junit reports with patterns [${patterns}]`);
- }
+ const patterns = (flags._.length ? flags._ : DEFAULT_PATTERNS).map((p) =>
+ normalize(Path.resolve(p))
+ );
+ log.info('Searching for reports at', patterns);
+ const reportPaths = await globby(patterns, {
+ absolute: true,
+ });
- log.info('found', reportPaths.length, 'junit reports', reportPaths);
- const newlyCreatedIssues: Array<{
- failure: TestFailure;
- newIssue: GithubIssueMini;
- }> = [];
+ if (!reportPaths.length) {
+ throw createFailError(`Unable to find any junit reports with patterns [${patterns}]`);
+ }
- for (const reportPath of reportPaths) {
- const report = await readTestReport(reportPath);
- const messages = Array.from(getReportMessageIter(report));
- const failures = await getFailures(report);
+ log.info('found', reportPaths.length, 'junit reports', reportPaths);
+ const newlyCreatedIssues: Array<{
+ failure: TestFailure;
+ newIssue: GithubIssueMini;
+ }> = [];
- if (indexInEs) {
- await reportFailuresToEs(log, failures);
- }
+ for (const reportPath of reportPaths) {
+ const report = await readTestReport(reportPath);
+ const messages = Array.from(getReportMessageIter(report));
+ const failures = await getFailures(report);
- for (const failure of failures) {
- const pushMessage = (msg: string) => {
- messages.push({
- classname: failure.classname,
- name: failure.name,
- message: msg,
- });
- };
-
- if (failure.likelyIrrelevant) {
- pushMessage(
- 'Failure is likely irrelevant' +
- (updateGithub ? ', so an issue was not created or updated' : '')
- );
- continue;
+ if (indexInEs) {
+ await reportFailuresToEs(log, failures);
}
- let existingIssue: GithubIssueMini | undefined = await githubApi.findFailedTestIssue(
- (i) =>
- getIssueMetadata(i.body, 'test.class') === failure.classname &&
- getIssueMetadata(i.body, 'test.name') === failure.name
- );
+ for (const failure of failures) {
+ const pushMessage = (msg: string) => {
+ messages.push({
+ classname: failure.classname,
+ name: failure.name,
+ message: msg,
+ });
+ };
+
+ if (failure.likelyIrrelevant) {
+ pushMessage(
+ 'Failure is likely irrelevant' +
+ (updateGithub ? ', so an issue was not created or updated' : '')
+ );
+ continue;
+ }
- if (!existingIssue) {
- const newlyCreated = newlyCreatedIssues.find(
- ({ failure: f }) => f.classname === failure.classname && f.name === failure.name
+ let existingIssue: GithubIssueMini | undefined = await githubApi.findFailedTestIssue(
+ (i) =>
+ getIssueMetadata(i.body, 'test.class') === failure.classname &&
+ getIssueMetadata(i.body, 'test.name') === failure.name
);
- if (newlyCreated) {
- existingIssue = newlyCreated.newIssue;
+ if (!existingIssue) {
+ const newlyCreated = newlyCreatedIssues.find(
+ ({ failure: f }) => f.classname === failure.classname && f.name === failure.name
+ );
+
+ if (newlyCreated) {
+ existingIssue = newlyCreated.newIssue;
+ }
}
- }
- if (existingIssue) {
- const newFailureCount = await updateFailureIssue(
- buildUrl,
- existingIssue,
- githubApi,
- branch
- );
- const url = existingIssue.html_url;
- failure.githubIssue = url;
- failure.failureCount = updateGithub ? newFailureCount : newFailureCount - 1;
- pushMessage(`Test has failed ${newFailureCount - 1} times on tracked branches: ${url}`);
- if (updateGithub) {
- pushMessage(`Updated existing issue: ${url} (fail count: ${newFailureCount})`);
+ if (existingIssue) {
+ const newFailureCount = await updateFailureIssue(
+ buildUrl,
+ existingIssue,
+ githubApi,
+ branch
+ );
+ const url = existingIssue.html_url;
+ failure.githubIssue = url;
+ failure.failureCount = updateGithub ? newFailureCount : newFailureCount - 1;
+ pushMessage(
+ `Test has failed ${newFailureCount - 1} times on tracked branches: ${url}`
+ );
+ if (updateGithub) {
+ pushMessage(`Updated existing issue: ${url} (fail count: ${newFailureCount})`);
+ }
+ continue;
}
- continue;
- }
- const newIssue = await createFailureIssue(buildUrl, failure, githubApi, branch);
- pushMessage('Test has not failed recently on tracked branches');
- if (updateGithub) {
- pushMessage(`Created new issue: ${newIssue.html_url}`);
- failure.githubIssue = newIssue.html_url;
+ const newIssue = await createFailureIssue(buildUrl, failure, githubApi, branch);
+ pushMessage('Test has not failed recently on tracked branches');
+ if (updateGithub) {
+ pushMessage(`Created new issue: ${newIssue.html_url}`);
+ failure.githubIssue = newIssue.html_url;
+ }
+ newlyCreatedIssues.push({ failure, newIssue });
+ failure.failureCount = updateGithub ? 1 : 0;
}
- newlyCreatedIssues.push({ failure, newIssue });
- failure.failureCount = updateGithub ? 1 : 0;
- }
- // mutates report to include messages and writes updated report to disk
- await addMessagesToReport({
- report,
- messages,
- log,
- reportPath,
- dryRun: !flags['report-update'],
- });
+ // mutates report to include messages and writes updated report to disk
+ await addMessagesToReport({
+ report,
+ messages,
+ log,
+ reportPath,
+ dryRun: !flags['report-update'],
+ });
- reportFailuresToFile(log, failures);
+ reportFailuresToFile(log, failures, bkMeta);
+ }
+ } finally {
+ await CiStatsReporter.fromEnv(log).metrics([
+ {
+ group: 'github api request count',
+ id: `failed test reporter`,
+ value: githubApi.getRequestCount(),
+ meta: Object.fromEntries(
+ Object.entries(bkMeta).map(
+ ([k, v]) => [`buildkite${k[0].toUpperCase()}${k.slice(1)}`, v] as const
+ )
+ ),
+ },
+ ]);
}
},
{
diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/validate_ci_group_tags.js b/packages/kbn-test/src/functional_test_runner/lib/mocha/validate_ci_group_tags.js
index 3446c5be5d4a7..4f798839d7231 100644
--- a/packages/kbn-test/src/functional_test_runner/lib/mocha/validate_ci_group_tags.js
+++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/validate_ci_group_tags.js
@@ -8,7 +8,7 @@
import Path from 'path';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
/**
* Traverse the suites configured and ensure that each suite has no more than one ciGroup assigned
diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts
index e87f316a100a7..53ce4c74c1388 100644
--- a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts
+++ b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts
@@ -14,7 +14,7 @@ jest.mock('@kbn/utils', () => {
return { REPO_ROOT: '/dev/null/root' };
});
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Lifecycle } from './lifecycle';
import { SuiteTracker } from './suite_tracker';
import { Suite } from '../fake_mocha_types';
diff --git a/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js b/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js
index 03947f7e267ba..63d2b56350ba1 100644
--- a/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js
+++ b/packages/kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js
@@ -9,7 +9,7 @@
const Fs = require('fs');
const Path = require('path');
-const { REPO_ROOT: REPO_ROOT_FOLLOWING_SYMLINKS } = require('@kbn/dev-utils');
+const { REPO_ROOT: REPO_ROOT_FOLLOWING_SYMLINKS } = require('@kbn/utils');
const BASE_REPO_ROOT = Path.resolve(
Fs.realpathSync(Path.resolve(REPO_ROOT_FOLLOWING_SYMLINKS, 'package.json')),
'..'
diff --git a/packages/kbn-test/src/functional_tests/tasks.ts b/packages/kbn-test/src/functional_tests/tasks.ts
index 6dde114d3a98e..6a6c7edb98c79 100644
--- a/packages/kbn-test/src/functional_tests/tasks.ts
+++ b/packages/kbn-test/src/functional_tests/tasks.ts
@@ -9,7 +9,8 @@
import { relative } from 'path';
import * as Rx from 'rxjs';
import { startWith, switchMap, take } from 'rxjs/operators';
-import { withProcRunner, ToolingLog, REPO_ROOT, getTimeReporter } from '@kbn/dev-utils';
+import { withProcRunner, ToolingLog, getTimeReporter } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import dedent from 'dedent';
import {
diff --git a/packages/kbn-test/src/jest/mocks/apm_agent_mock.ts b/packages/kbn-test/src/jest/mocks/apm_agent_mock.ts
new file mode 100644
index 0000000000000..1615f710504ad
--- /dev/null
+++ b/packages/kbn-test/src/jest/mocks/apm_agent_mock.ts
@@ -0,0 +1,63 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import type { Agent } from 'elastic-apm-node';
+
+/**
+ * `elastic-apm-node` patches the runtime at import time
+ * causing memory leak with jest module sandbox, so it
+ * needs to be mocked for tests
+ */
+const agent: jest.Mocked = {
+ start: jest.fn().mockImplementation(() => agent),
+ isStarted: jest.fn().mockReturnValue(false),
+ getServiceName: jest.fn().mockReturnValue('mock-service'),
+ setFramework: jest.fn(),
+ addPatch: jest.fn(),
+ removePatch: jest.fn(),
+ clearPatches: jest.fn(),
+ lambda: jest.fn(),
+ handleUncaughtExceptions: jest.fn(),
+ captureError: jest.fn(),
+ currentTraceparent: null,
+ currentTraceIds: {},
+ startTransaction: jest.fn().mockReturnValue(null),
+ setTransactionName: jest.fn(),
+ endTransaction: jest.fn(),
+ currentTransaction: null,
+ startSpan: jest.fn(),
+ currentSpan: null,
+ setLabel: jest.fn().mockReturnValue(false),
+ addLabels: jest.fn().mockReturnValue(false),
+ setUserContext: jest.fn(),
+ setCustomContext: jest.fn(),
+ addFilter: jest.fn(),
+ addErrorFilter: jest.fn(),
+ addSpanFilter: jest.fn(),
+ addTransactionFilter: jest.fn(),
+ addMetadataFilter: jest.fn(),
+ flush: jest.fn(),
+ destroy: jest.fn(),
+ registerMetric: jest.fn(),
+ setTransactionOutcome: jest.fn(),
+ setSpanOutcome: jest.fn(),
+ middleware: {
+ connect: jest.fn().mockReturnValue(jest.fn()),
+ },
+ logger: {
+ fatal: jest.fn(),
+ error: jest.fn(),
+ warn: jest.fn(),
+ info: jest.fn(),
+ debug: jest.fn(),
+ trace: jest.fn(),
+ },
+};
+
+// eslint-disable-next-line import/no-default-export
+export default agent;
diff --git a/packages/kbn-test/src/kbn/users.ts b/packages/kbn-test/src/kbn/users.ts
index 230354089dcac..88480fde74ddc 100644
--- a/packages/kbn-test/src/kbn/users.ts
+++ b/packages/kbn-test/src/kbn/users.ts
@@ -14,7 +14,7 @@ export const kibanaTestUser = {
};
export const kibanaServerTestUser = {
- username: env.TEST_KIBANA_SERVER_USER || 'kibana',
+ username: env.TEST_KIBANA_SERVER_USER || 'kibana_system',
password: env.TEST_KIBANA_SERVER_PASS || 'changeme',
};
diff --git a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts
index 4adae7d1cd031..6da34228bbe7f 100644
--- a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts
+++ b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts
@@ -12,7 +12,8 @@ import { existsSync } from 'fs';
import Path from 'path';
import FormData from 'form-data';
-import { ToolingLog, isAxiosResponseError, createFailError, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog, isAxiosResponseError, createFailError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { KbnClientRequester, uriencode, ReqOptions } from './kbn_client_requester';
import { KbnClientSavedObjects } from './kbn_client_saved_objects';
diff --git a/packages/kbn-typed-react-router-config/BUILD.bazel b/packages/kbn-typed-react-router-config/BUILD.bazel
index b347915ae3310..d759948a6c576 100644
--- a/packages/kbn-typed-react-router-config/BUILD.bazel
+++ b/packages/kbn-typed-react-router-config/BUILD.bazel
@@ -41,10 +41,10 @@ TYPES_DEPS = [
"@npm//query-string",
"@npm//utility-types",
"@npm//@types/jest",
- "@npm//@types/history",
"@npm//@types/node",
"@npm//@types/react-router-config",
"@npm//@types/react-router-dom",
+ "@npm//@types/history",
]
jsts_transpiler(
diff --git a/packages/kbn-typed-react-router-config/src/create_router.test.tsx b/packages/kbn-typed-react-router-config/src/create_router.test.tsx
index e82fcf791804e..ac337f8bb5b87 100644
--- a/packages/kbn-typed-react-router-config/src/create_router.test.tsx
+++ b/packages/kbn-typed-react-router-config/src/create_router.test.tsx
@@ -267,7 +267,6 @@ describe('createRouter', () => {
const matches = router.matchRoutes('/', history.location);
- // @ts-expect-error 4.3.5 upgrade - router doesn't seem able to merge properly when two routes match
expect(matches[1]?.match.params).toEqual({
query: {
rangeFrom: 'now-30m',
@@ -286,7 +285,6 @@ describe('createRouter', () => {
expect(matchedRoutes.length).toEqual(4);
- // @ts-expect-error 4.3.5 upgrade - router doesn't seem able to merge properly when two routes match
expect(matchedRoutes[matchedRoutes.length - 1].match).toEqual({
isExact: true,
params: {
diff --git a/packages/kbn-typed-react-router-config/src/create_router.ts b/packages/kbn-typed-react-router-config/src/create_router.ts
index 186f949d9c8e8..89ff4fc6b0c6c 100644
--- a/packages/kbn-typed-react-router-config/src/create_router.ts
+++ b/packages/kbn-typed-react-router-config/src/create_router.ts
@@ -23,7 +23,7 @@ function toReactRouterPath(path: string) {
return path.replace(/(?:{([^\/]+)})/g, ':$1');
}
-export function createRouter(routes: TRoute[]): Router {
+export function createRouter(routes: TRoutes): Router {
const routesByReactRouterConfig = new Map();
const reactRouterConfigsByRoute = new Map();
@@ -181,8 +181,10 @@ export function createRouter(routes: TRoute[]): Router {
+ return link(path, ...args);
+ },
getParams: (...args: any[]) => {
const matches = matchRoutes(...args);
return matches.length
@@ -195,13 +197,11 @@ export function createRouter(routes: TRoute[]): Router {
return matchRoutes(...args) as any;
},
- getRoutePath: (route: Route) => {
+ getRoutePath: (route) => {
return reactRouterConfigsByRoute.get(route)!.path as string;
},
getRoutesToMatch: (path: string) => {
- return getRoutesToMatch(path) as unknown as FlattenRoutesOf;
+ return getRoutesToMatch(path) as unknown as FlattenRoutesOf;
},
};
-
- return router;
}
diff --git a/packages/kbn-typed-react-router-config/src/types/index.ts b/packages/kbn-typed-react-router-config/src/types/index.ts
index 3c09b60054a0c..c1ae5afd816ee 100644
--- a/packages/kbn-typed-react-router-config/src/types/index.ts
+++ b/packages/kbn-typed-react-router-config/src/types/index.ts
@@ -115,7 +115,7 @@ export interface RouteMatch {
params: t.Type;
}
? t.TypeOf
- : AnyObj;
+ : {};
};
}
@@ -160,11 +160,10 @@ interface ReadonlyPlainRoute {
}
export type Route = PlainRoute | ReadonlyPlainRoute;
-type AnyObj = Record;
interface DefaultOutput {
- path: AnyObj;
- query: AnyObj;
+ path: {};
+ query: {};
}
type OutputOfRouteMatch = TRouteMatch extends {
@@ -191,21 +190,20 @@ type TypeOfRouteMatch = TRouteMatch extends {
route: { params: t.Type };
}
? t.TypeOf
- : AnyObj;
+ : {};
type TypeOfMatches = TRouteMatches extends [RouteMatch]
? TypeOfRouteMatch
: TRouteMatches extends [RouteMatch, ...infer TNextRouteMatches]
? TypeOfRouteMatch &
- (TNextRouteMatches extends RouteMatch[] ? TypeOfMatches : AnyObj)
- : AnyObj;
+ (TNextRouteMatches extends RouteMatch[] ? TypeOfMatches : {})
+ : {};
export type TypeOf<
TRoutes extends Route[],
TPath extends PathsOf,
TWithDefaultOutput extends boolean = true
-> = TypeOfMatches> &
- (TWithDefaultOutput extends true ? DefaultOutput : AnyObj);
+> = TypeOfMatches> & (TWithDefaultOutput extends true ? DefaultOutput : {});
export type TypeAsArgs = keyof TObject extends never
? []
@@ -278,7 +276,7 @@ type MapRoute = MaybeUnion<
>;
}
>
- : AnyObj
+ : {}
>;
type MapRoutes = TRoutes extends [Route]
@@ -343,7 +341,7 @@ type MapRoutes = TRoutes extends [Route]
MapRoute &
MapRoute &
MapRoute
- : AnyObj;
+ : {};
// const element = null as any;
diff --git a/src/cli/serve/integration_tests/invalid_config.test.ts b/src/cli/serve/integration_tests/invalid_config.test.ts
index 2de902582a548..ca051f37a816e 100644
--- a/src/cli/serve/integration_tests/invalid_config.test.ts
+++ b/src/cli/serve/integration_tests/invalid_config.test.ts
@@ -8,7 +8,7 @@
import { spawnSync } from 'child_process';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
const INVALID_CONFIG_PATH = require.resolve('./__fixtures__/invalid_config.yml');
diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts
index 24c085ef64de3..fed3aa3093166 100644
--- a/src/core/public/doc_links/doc_links_service.ts
+++ b/src/core/public/doc_links/doc_links_service.ts
@@ -113,6 +113,7 @@ export class DocLinksService {
usersAccess: `${ENTERPRISE_SEARCH_DOCS}users-access.html`,
},
workplaceSearch: {
+ apiKeys: `${WORKPLACE_SEARCH_DOCS}workplace-search-api-authentication.html`,
box: `${WORKPLACE_SEARCH_DOCS}workplace-search-box-connector.html`,
confluenceCloud: `${WORKPLACE_SEARCH_DOCS}workplace-search-confluence-cloud-connector.html`,
confluenceServer: `${WORKPLACE_SEARCH_DOCS}workplace-search-confluence-server-connector.html`,
@@ -485,6 +486,7 @@ export class DocLinksService {
hdfsRepo: `${PLUGIN_DOCS}repository-hdfs.html`,
s3Repo: `${PLUGIN_DOCS}repository-s3.html`,
snapshotRestoreRepos: `${PLUGIN_DOCS}repository.html`,
+ mapperSize: `${PLUGIN_DOCS}mapper-size-usage.html`,
},
snapshotRestore: {
guide: `${ELASTICSEARCH_DOCS}snapshot-restore.html`,
@@ -671,6 +673,7 @@ export interface DocLinksStart {
readonly usersAccess: string;
};
readonly workplaceSearch: {
+ readonly apiKeys: string;
readonly box: string;
readonly confluenceCloud: string;
readonly confluenceServer: string;
@@ -872,7 +875,14 @@ export interface DocLinksStart {
}>;
readonly watcher: Record;
readonly ccs: Record;
- readonly plugins: Record;
+ readonly plugins: {
+ azureRepo: string;
+ gcsRepo: string;
+ hdfsRepo: string;
+ s3Repo: string;
+ snapshotRestoreRepos: string;
+ mapperSize: string;
+ };
readonly snapshotRestore: Record;
readonly ingest: Record;
readonly fleet: Readonly<{
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index 30225acb3dd8d..63e0898b5fb90 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -571,6 +571,7 @@ export interface DocLinksStart {
readonly usersAccess: string;
};
readonly workplaceSearch: {
+ readonly apiKeys: string;
readonly box: string;
readonly confluenceCloud: string;
readonly confluenceServer: string;
@@ -772,7 +773,14 @@ export interface DocLinksStart {
}>;
readonly watcher: Record;
readonly ccs: Record;
- readonly plugins: Record;
+ readonly plugins: {
+ azureRepo: string;
+ gcsRepo: string;
+ hdfsRepo: string;
+ s3Repo: string;
+ snapshotRestoreRepos: string;
+ mapperSize: string;
+ };
readonly snapshotRestore: Record;
readonly ingest: Record;
readonly fleet: Readonly<{
diff --git a/src/core/server/capabilities/integration_tests/capabilities_service.test.ts b/src/core/server/capabilities/integration_tests/capabilities_service.test.ts
index 2e80fbb9d20c0..c1f6ffb5add77 100644
--- a/src/core/server/capabilities/integration_tests/capabilities_service.test.ts
+++ b/src/core/server/capabilities/integration_tests/capabilities_service.test.ts
@@ -7,7 +7,7 @@
*/
import supertest from 'supertest';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { HttpService, InternalHttpServicePreboot, InternalHttpServiceSetup } from '../../http';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts
index ddb87d31383c8..4d7b4e1ba5548 100644
--- a/src/core/server/core_context.mock.ts
+++ b/src/core/server/core_context.mock.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { CoreContext } from './core_context';
import { Env, IConfigService } from './config';
diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts
index 7988e81045d17..f252993415afa 100644
--- a/src/core/server/elasticsearch/client/configure_client.test.ts
+++ b/src/core/server/elasticsearch/client/configure_client.test.ts
@@ -6,21 +6,16 @@
* Side Public License, v 1.
*/
-import { Buffer } from 'buffer';
-import { Readable } from 'stream';
-
-import { errors } from '@elastic/elasticsearch';
-import type {
- TransportRequestOptions,
- TransportRequestParams,
- DiagnosticResult,
- RequestBody,
-} from '@elastic/elasticsearch';
+jest.mock('./log_query_and_deprecation.ts', () => ({
+ __esModule: true,
+ instrumentEsQueryAndDeprecationLogger: jest.fn(),
+}));
import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks';
import { loggingSystemMock } from '../../logging/logging_system.mock';
import type { ElasticsearchClientConfig } from './client_config';
import { configureClient } from './configure_client';
+import { instrumentEsQueryAndDeprecationLogger } from './log_query_and_deprecation';
const createFakeConfig = (
parts: Partial = {}
@@ -36,40 +31,9 @@ const createFakeClient = () => {
const client = new actualEs.Client({
nodes: ['http://localhost'], // Enforcing `nodes` because it's mandatory
});
- jest.spyOn(client.diagnostic, 'on');
return client;
};
-const createApiResponse = ({
- body,
- statusCode = 200,
- headers = {},
- warnings = [],
- params,
- requestOptions = {},
-}: {
- body: T;
- statusCode?: number;
- headers?: Record;
- warnings?: string[];
- params?: TransportRequestParams;
- requestOptions?: TransportRequestOptions;
-}): DiagnosticResult => {
- return {
- body,
- statusCode,
- headers,
- warnings,
- meta: {
- body,
- request: {
- params: params!,
- options: requestOptions,
- } as any,
- } as any,
- };
-};
-
describe('configureClient', () => {
let logger: ReturnType;
let config: ElasticsearchClientConfig;
@@ -84,6 +48,7 @@ describe('configureClient', () => {
afterEach(() => {
parseClientOptionsMock.mockReset();
ClientMock.mockReset();
+ jest.clearAllMocks();
});
it('calls `parseClientOptions` with the correct parameters', () => {
@@ -113,366 +78,14 @@ describe('configureClient', () => {
expect(client).toBe(ClientMock.mock.results[0].value);
});
- it('listens to client on `response` events', () => {
+ it('calls instrumentEsQueryAndDeprecationLogger', () => {
const client = configureClient(config, { logger, type: 'test', scoped: false });
- expect(client.diagnostic.on).toHaveBeenCalledTimes(1);
- expect(client.diagnostic.on).toHaveBeenCalledWith('response', expect.any(Function));
- });
-
- describe('Client logging', () => {
- function createResponseWithBody(body?: RequestBody) {
- return createApiResponse({
- body: {},
- statusCode: 200,
- params: {
- method: 'GET',
- path: '/foo',
- querystring: { hello: 'dolly' },
- body,
- },
- });
- }
-
- describe('logs each query', () => {
- it('creates a query logger context based on the `type` parameter', () => {
- configureClient(createFakeConfig(), { logger, type: 'test123' });
- expect(logger.get).toHaveBeenCalledWith('query', 'test123');
- });
-
- it('when request body is an object', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createResponseWithBody({
- seq_no_primary_term: true,
- query: {
- term: { user: 'kimchy' },
- },
- });
-
- client.diagnostic.emit('response', null, response);
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?hello=dolly
- {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}}",
- undefined,
- ],
- ]
- `);
- });
-
- it('when request body is a string', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createResponseWithBody(
- JSON.stringify({
- seq_no_primary_term: true,
- query: {
- term: { user: 'kimchy' },
- },
- })
- );
-
- client.diagnostic.emit('response', null, response);
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?hello=dolly
- {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}}",
- undefined,
- ],
- ]
- `);
- });
-
- it('when request body is a buffer', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createResponseWithBody(
- Buffer.from(
- JSON.stringify({
- seq_no_primary_term: true,
- query: {
- term: { user: 'kimchy' },
- },
- })
- )
- );
-
- client.diagnostic.emit('response', null, response);
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?hello=dolly
- [buffer]",
- undefined,
- ],
- ]
- `);
- });
-
- it('when request body is a readable stream', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createResponseWithBody(
- Readable.from(
- JSON.stringify({
- seq_no_primary_term: true,
- query: {
- term: { user: 'kimchy' },
- },
- })
- )
- );
-
- client.diagnostic.emit('response', null, response);
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?hello=dolly
- [stream]",
- undefined,
- ],
- ]
- `);
- });
-
- it('when request body is not defined', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createResponseWithBody();
-
- client.diagnostic.emit('response', null, response);
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?hello=dolly",
- undefined,
- ],
- ]
- `);
- });
-
- it('properly encode queries', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createApiResponse({
- body: {},
- statusCode: 200,
- params: {
- method: 'GET',
- path: '/foo',
- querystring: { city: 'Münich' },
- },
- });
-
- client.diagnostic.emit('response', null, response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "200
- GET /foo?city=M%C3%BCnich",
- undefined,
- ],
- ]
- `);
- });
-
- it('logs queries even in case of errors', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createApiResponse({
- statusCode: 500,
- body: {
- error: {
- type: 'internal server error',
- },
- },
- params: {
- method: 'GET',
- path: '/foo',
- querystring: { hello: 'dolly' },
- body: {
- seq_no_primary_term: true,
- query: {
- term: { user: 'kimchy' },
- },
- },
- },
- });
- client.diagnostic.emit('response', new errors.ResponseError(response), response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "500
- GET /foo?hello=dolly
- {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}} [internal server error]: internal server error",
- undefined,
- ],
- ]
- `);
- });
-
- it('logs debug when the client emits an @elastic/elasticsearch error', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createApiResponse({ body: {} });
- client.diagnostic.emit('response', new errors.TimeoutError('message', response), response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "[TimeoutError]: message",
- undefined,
- ],
- ]
- `);
- });
-
- it('logs debug when the client emits an ResponseError returned by elasticsearch', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- const response = createApiResponse({
- statusCode: 400,
- headers: {},
- params: {
- method: 'GET',
- path: '/_path',
- querystring: { hello: 'dolly' },
- },
- body: {
- error: {
- type: 'illegal_argument_exception',
- reason: 'request [/_path] contains unrecognized parameter: [name]',
- },
- },
- });
- client.diagnostic.emit('response', new errors.ResponseError(response), response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "400
- GET /_path?hello=dolly [illegal_argument_exception]: request [/_path] contains unrecognized parameter: [name]",
- undefined,
- ],
- ]
- `);
- });
-
- it('logs default error info when the error response body is empty', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- let response: DiagnosticResult = createApiResponse({
- statusCode: 400,
- headers: {},
- params: {
- method: 'GET',
- path: '/_path',
- },
- body: {
- error: {},
- },
- });
- client.diagnostic.emit('response', new errors.ResponseError(response), response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "400
- GET /_path [undefined]: {\\"error\\":{}}",
- undefined,
- ],
- ]
- `);
-
- logger.debug.mockClear();
-
- response = createApiResponse({
- statusCode: 400,
- headers: {},
- params: {
- method: 'GET',
- path: '/_path',
- },
- body: undefined,
- });
- client.diagnostic.emit('response', new errors.ResponseError(response), response);
-
- expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
- Array [
- Array [
- "400
- GET /_path [undefined]: Response Error",
- undefined,
- ],
- ]
- `);
- });
-
- it('adds meta information to logs', () => {
- const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });
-
- let response = createApiResponse({
- statusCode: 400,
- headers: {},
- params: {
- method: 'GET',
- path: '/_path',
- },
- requestOptions: {
- opaqueId: 'opaque-id',
- },
- body: {
- error: {},
- },
- });
- client.diagnostic.emit('response', null, response);
-
- expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(`
- Object {
- "http": Object {
- "request": Object {
- "id": "opaque-id",
- },
- },
- }
- `);
-
- logger.debug.mockClear();
-
- response = createApiResponse({
- statusCode: 400,
- headers: {},
- params: {
- method: 'GET',
- path: '/_path',
- },
- requestOptions: {
- opaqueId: 'opaque-id',
- },
- body: {} as any,
- });
- client.diagnostic.emit('response', new errors.ResponseError(response), response);
-
- expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(`
- Object {
- "http": Object {
- "request": Object {
- "id": "opaque-id",
- },
- },
- }
- `);
- });
+ expect(instrumentEsQueryAndDeprecationLogger).toHaveBeenCalledTimes(1);
+ expect(instrumentEsQueryAndDeprecationLogger).toHaveBeenCalledWith({
+ logger,
+ client,
+ type: 'test',
});
});
});
diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts
index fc8a06660cc5e..e48a36fa4fe58 100644
--- a/src/core/server/elasticsearch/client/configure_client.ts
+++ b/src/core/server/elasticsearch/client/configure_client.ts
@@ -6,21 +6,17 @@
* Side Public License, v 1.
*/
-import { Buffer } from 'buffer';
-import { stringify } from 'querystring';
-import { Client, errors, Transport, HttpConnection } from '@elastic/elasticsearch';
+import { Client, Transport, HttpConnection } from '@elastic/elasticsearch';
import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana';
import type {
TransportRequestParams,
TransportRequestOptions,
TransportResult,
- DiagnosticResult,
- RequestBody,
} from '@elastic/elasticsearch';
import { Logger } from '../../logging';
import { parseClientOptions, ElasticsearchClientConfig } from './client_config';
-import type { ElasticsearchErrorDetails } from './types';
+import { instrumentEsQueryAndDeprecationLogger } from './log_query_and_deprecation';
const noop = () => undefined;
@@ -61,91 +57,8 @@ export const configureClient = (
Transport: KibanaTransport,
Connection: HttpConnection,
});
- addLogging(client, logger.get('query', type));
- return client as KibanaClient;
-};
-
-const convertQueryString = (qs: string | Record | undefined): string => {
- if (qs === undefined || typeof qs === 'string') {
- return qs ?? '';
- }
- return stringify(qs);
-};
-
-function ensureString(body: RequestBody): string {
- if (typeof body === 'string') return body;
- if (Buffer.isBuffer(body)) return '[buffer]';
- if ('readable' in body && body.readable && typeof body._read === 'function') return '[stream]';
- return JSON.stringify(body);
-}
-
-/**
- * Returns a debug message from an Elasticsearch error in the following format:
- * [error type] error reason
- */
-export function getErrorMessage(error: errors.ElasticsearchClientError): string {
- if (error instanceof errors.ResponseError) {
- const errorBody = error.meta.body as ElasticsearchErrorDetails;
- return `[${errorBody?.error?.type}]: ${errorBody?.error?.reason ?? error.message}`;
- }
- return `[${error.name}]: ${error.message}`;
-}
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type });
-/**
- * returns a string in format:
- *
- * status code
- * method URL
- * request body
- *
- * so it could be copy-pasted into the Dev console
- */
-function getResponseMessage(event: DiagnosticResult): string {
- const errorMeta = getRequestDebugMeta(event);
- const body = errorMeta.body ? `\n${errorMeta.body}` : '';
- return `${errorMeta.statusCode}\n${errorMeta.method} ${errorMeta.url}${body}`;
-}
-
-/**
- * Returns stringified debug information from an Elasticsearch request event
- * useful for logging in case of an unexpected failure.
- */
-export function getRequestDebugMeta(event: DiagnosticResult): {
- url: string;
- body: string;
- statusCode: number | null;
- method: string;
-} {
- const params = event.meta.request.params;
- // definition is wrong, `params.querystring` can be either a string or an object
- const querystring = convertQueryString(params.querystring);
- return {
- url: `${params.path}${querystring ? `?${querystring}` : ''}`,
- body: params.body ? `${ensureString(params.body)}` : '',
- method: params.method,
- statusCode: event.statusCode!,
- };
-}
-
-const addLogging = (client: Client, logger: Logger) => {
- client.diagnostic.on('response', (error, event) => {
- if (event) {
- const opaqueId = event.meta.request.options.opaqueId;
- const meta = opaqueId
- ? {
- http: { request: { id: event.meta.request.options.opaqueId } },
- }
- : undefined; // do not clutter logs if opaqueId is not present
- if (error) {
- if (error instanceof errors.ResponseError) {
- logger.debug(`${getResponseMessage(event)} ${getErrorMessage(error)}`, meta);
- } else {
- logger.debug(getErrorMessage(error), meta);
- }
- } else {
- logger.debug(getResponseMessage(event), meta);
- }
- }
- });
+ return client as KibanaClient;
};
diff --git a/src/core/server/elasticsearch/client/index.ts b/src/core/server/elasticsearch/client/index.ts
index 2cf5a0229a489..123c498f1ee21 100644
--- a/src/core/server/elasticsearch/client/index.ts
+++ b/src/core/server/elasticsearch/client/index.ts
@@ -21,5 +21,6 @@ export type { IScopedClusterClient } from './scoped_cluster_client';
export type { ElasticsearchClientConfig } from './client_config';
export { ClusterClient } from './cluster_client';
export type { IClusterClient, ICustomClusterClient } from './cluster_client';
-export { configureClient, getRequestDebugMeta, getErrorMessage } from './configure_client';
+export { configureClient } from './configure_client';
+export { getRequestDebugMeta, getErrorMessage } from './log_query_and_deprecation';
export { retryCallCluster, migrationRetryCallCluster } from './retry_call_cluster';
diff --git a/src/core/server/elasticsearch/client/log_query_and_deprecation.test.ts b/src/core/server/elasticsearch/client/log_query_and_deprecation.test.ts
new file mode 100644
index 0000000000000..30d5d8b87ed1c
--- /dev/null
+++ b/src/core/server/elasticsearch/client/log_query_and_deprecation.test.ts
@@ -0,0 +1,624 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { Buffer } from 'buffer';
+import { Readable } from 'stream';
+
+import {
+ Client,
+ ConnectionRequestParams,
+ errors,
+ TransportRequestOptions,
+ TransportRequestParams,
+} from '@elastic/elasticsearch';
+import type { DiagnosticResult, RequestBody } from '@elastic/elasticsearch';
+
+import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks';
+import { loggingSystemMock } from '../../logging/logging_system.mock';
+import { instrumentEsQueryAndDeprecationLogger } from './log_query_and_deprecation';
+
+const createApiResponse = ({
+ body,
+ statusCode = 200,
+ headers = {},
+ warnings = null,
+ params,
+ requestOptions = {},
+}: {
+ body: T;
+ statusCode?: number;
+ headers?: Record;
+ warnings?: string[] | null;
+ params?: TransportRequestParams | ConnectionRequestParams;
+ requestOptions?: TransportRequestOptions;
+}): DiagnosticResult => {
+ return {
+ body,
+ statusCode,
+ headers,
+ warnings,
+ meta: {
+ body,
+ request: {
+ params: params!,
+ options: requestOptions,
+ } as any,
+ } as any,
+ };
+};
+
+const createFakeClient = () => {
+ const actualEs = jest.requireActual('@elastic/elasticsearch');
+ const client = new actualEs.Client({
+ nodes: ['http://localhost'], // Enforcing `nodes` because it's mandatory
+ });
+ jest.spyOn(client.diagnostic, 'on');
+ return client as Client;
+};
+
+describe('instrumentQueryAndDeprecationLogger', () => {
+ let logger: ReturnType;
+ const client = createFakeClient();
+
+ beforeEach(() => {
+ logger = loggingSystemMock.createLogger();
+ parseClientOptionsMock.mockReturnValue({});
+ ClientMock.mockImplementation(() => createFakeClient());
+ });
+
+ afterEach(() => {
+ parseClientOptionsMock.mockReset();
+ ClientMock.mockReset();
+ jest.clearAllMocks();
+ });
+
+ function createResponseWithBody(body?: RequestBody) {
+ return createApiResponse({
+ body: {},
+ statusCode: 200,
+ params: {
+ method: 'GET',
+ path: '/foo',
+ querystring: { hello: 'dolly' },
+ body,
+ },
+ });
+ }
+
+ it('creates a query logger context based on the `type` parameter', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test123' });
+ expect(logger.get).toHaveBeenCalledWith('query', 'test123');
+ });
+
+ describe('logs each query', () => {
+ it('when request body is an object', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createResponseWithBody({
+ seq_no_primary_term: true,
+ query: {
+ term: { user: 'kimchy' },
+ },
+ });
+
+ client.diagnostic.emit('response', null, response);
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?hello=dolly
+ {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}}",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('when request body is a string', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createResponseWithBody(
+ JSON.stringify({
+ seq_no_primary_term: true,
+ query: {
+ term: { user: 'kimchy' },
+ },
+ })
+ );
+
+ client.diagnostic.emit('response', null, response);
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?hello=dolly
+ {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}}",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('when request body is a buffer', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createResponseWithBody(
+ Buffer.from(
+ JSON.stringify({
+ seq_no_primary_term: true,
+ query: {
+ term: { user: 'kimchy' },
+ },
+ })
+ )
+ );
+
+ client.diagnostic.emit('response', null, response);
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?hello=dolly
+ [buffer]",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('when request body is a readable stream', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createResponseWithBody(
+ Readable.from(
+ JSON.stringify({
+ seq_no_primary_term: true,
+ query: {
+ term: { user: 'kimchy' },
+ },
+ })
+ )
+ );
+
+ client.diagnostic.emit('response', null, response);
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?hello=dolly
+ [stream]",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('when request body is not defined', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createResponseWithBody();
+
+ client.diagnostic.emit('response', null, response);
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?hello=dolly",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('properly encode queries', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ body: {},
+ statusCode: 200,
+ params: {
+ method: 'GET',
+ path: '/foo',
+ querystring: { city: 'Münich' },
+ },
+ });
+
+ client.diagnostic.emit('response', null, response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "200
+ GET /foo?city=M%C3%BCnich",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('logs queries even in case of errors', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 500,
+ body: {
+ error: {
+ type: 'internal server error',
+ },
+ },
+ params: {
+ method: 'GET',
+ path: '/foo',
+ querystring: { hello: 'dolly' },
+ body: {
+ seq_no_primary_term: true,
+ query: {
+ term: { user: 'kimchy' },
+ },
+ },
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "500
+ GET /foo?hello=dolly
+ {\\"seq_no_primary_term\\":true,\\"query\\":{\\"term\\":{\\"user\\":\\"kimchy\\"}}} [internal server error]: internal server error",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('logs debug when the client emits an @elastic/elasticsearch error', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({ body: {} });
+ client.diagnostic.emit('response', new errors.TimeoutError('message', response), response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "[TimeoutError]: message",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('logs debug when the client emits an ResponseError returned by elasticsearch', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 400,
+ headers: {},
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ },
+ body: {
+ error: {
+ type: 'illegal_argument_exception',
+ reason: 'request [/_path] contains unrecognized parameter: [name]',
+ },
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "400
+ GET /_path?hello=dolly [illegal_argument_exception]: request [/_path] contains unrecognized parameter: [name]",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('logs default error info when the error response body is empty', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ let response: DiagnosticResult = createApiResponse({
+ statusCode: 400,
+ headers: {},
+ params: {
+ method: 'GET',
+ path: '/_path',
+ },
+ body: {
+ error: {},
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "400
+ GET /_path [undefined]: {\\"error\\":{}}",
+ undefined,
+ ],
+ ]
+ `);
+
+ logger.debug.mockClear();
+
+ response = createApiResponse({
+ statusCode: 400,
+ headers: {},
+ params: {
+ method: 'GET',
+ path: '/_path',
+ },
+ body: undefined,
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "400
+ GET /_path [undefined]: Response Error",
+ undefined,
+ ],
+ ]
+ `);
+ });
+
+ it('adds meta information to logs', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ let response = createApiResponse({
+ statusCode: 400,
+ headers: {},
+ params: {
+ method: 'GET',
+ path: '/_path',
+ },
+ requestOptions: {
+ opaqueId: 'opaque-id',
+ },
+ body: {
+ error: {},
+ },
+ });
+ client.diagnostic.emit('response', null, response);
+
+ expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(`
+ Object {
+ "http": Object {
+ "request": Object {
+ "id": "opaque-id",
+ },
+ },
+ }
+ `);
+
+ logger.debug.mockClear();
+
+ response = createApiResponse({
+ statusCode: 400,
+ headers: {},
+ params: {
+ method: 'GET',
+ path: '/_path',
+ },
+ requestOptions: {
+ opaqueId: 'opaque-id',
+ },
+ body: {} as any,
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(`
+ Object {
+ "http": Object {
+ "request": Object {
+ "id": "opaque-id",
+ },
+ },
+ }
+ `);
+ });
+ });
+
+ describe('deprecation warnings from response headers', () => {
+ it('does not log when no deprecation warning header is returned', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 200,
+ warnings: null,
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ },
+ body: {
+ hits: [
+ {
+ _source: 'may the source be with you',
+ },
+ ],
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ // One debug log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
+ expect(loggingSystemMock.collect(logger).info).toEqual([]);
+ });
+
+ it('does not log when warning header comes from a warn-agent that is not elasticsearch', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 200,
+ warnings: [
+ '299 nginx/2.3.1 "GET /_path is deprecated"',
+ '299 nginx/2.3.1 "GET hello query param is deprecated"',
+ ],
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ },
+ body: {
+ hits: [
+ {
+ _source: 'may the source be with you',
+ },
+ ],
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ // One debug log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
+ expect(loggingSystemMock.collect(logger).info).toEqual([]);
+ });
+
+ it('logs error when the client receives an Elasticsearch error response for a deprecated request originating from a user', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 400,
+ warnings: ['299 Elasticsearch-8.1.0 "GET /_path is deprecated"'],
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ },
+ body: {
+ error: {
+ type: 'illegal_argument_exception',
+ reason: 'request [/_path] contains unrecognized parameter: [name]',
+ },
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ expect(loggingSystemMock.collect(logger).info).toEqual([]);
+ // Test debug[1] since theree is one log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
+ 'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
+ );
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:user');
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
+ /Query:\n.*400\n.*GET \/_path\?hello\=dolly \[illegal_argument_exception\]: request \[\/_path\] contains unrecognized parameter: \[name\]/
+ );
+ });
+
+ it('logs warning when the client receives an Elasticsearch error response for a deprecated request originating from kibana', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 400,
+ warnings: ['299 Elasticsearch-8.1.0 "GET /_path is deprecated"'],
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ // Set the request header to indicate to Elasticsearch that this is a request over which users have no control
+ headers: { 'x-elastic-product-origin': 'kibana' },
+ },
+ body: {
+ error: {
+ type: 'illegal_argument_exception',
+ reason: 'request [/_path] contains unrecognized parameter: [name]',
+ },
+ },
+ });
+ client.diagnostic.emit('response', new errors.ResponseError(response), response);
+
+ // One debug log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
+ 'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
+ );
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
+ /Query:\n.*400\n.*GET \/_path\?hello\=dolly \[illegal_argument_exception\]: request \[\/_path\] contains unrecognized parameter: \[name\]/
+ );
+ });
+
+ it('logs error when the client receives an Elasticsearch success response for a deprecated request originating from a user', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 200,
+ warnings: ['299 Elasticsearch-8.1.0 "GET /_path is deprecated"'],
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ },
+ body: {
+ hits: [
+ {
+ _source: 'may the source be with you',
+ },
+ ],
+ },
+ });
+ client.diagnostic.emit('response', null, response);
+
+ expect(loggingSystemMock.collect(logger).info).toEqual([]);
+ // Test debug[1] since theree is one log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
+ 'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
+ );
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:user');
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
+ expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
+ /Query:\n.*200\n.*GET \/_path\?hello\=dolly/
+ );
+ });
+
+ it('logs warning when the client receives an Elasticsearch success response for a deprecated request originating from kibana', () => {
+ instrumentEsQueryAndDeprecationLogger({ logger, client, type: 'test type' });
+
+ const response = createApiResponse({
+ statusCode: 200,
+ warnings: ['299 Elasticsearch-8.1.0 "GET /_path is deprecated"'],
+ params: {
+ method: 'GET',
+ path: '/_path',
+ querystring: { hello: 'dolly' },
+ // Set the request header to indicate to Elasticsearch that this is a request over which users have no control
+ headers: { 'x-elastic-product-origin': 'kibana' },
+ },
+ body: {
+ hits: [
+ {
+ _source: 'may the source be with you',
+ },
+ ],
+ },
+ });
+ client.diagnostic.emit('response', null, response);
+
+ // One debug log entry from 'elasticsearch.query' context
+ expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
+ 'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
+ );
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
+ expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
+ /Query:\n.*200\n.*GET \/_path\?hello\=dolly/
+ );
+ });
+ });
+});
diff --git a/src/core/server/elasticsearch/client/log_query_and_deprecation.ts b/src/core/server/elasticsearch/client/log_query_and_deprecation.ts
new file mode 100644
index 0000000000000..fc5a0fa6e1111
--- /dev/null
+++ b/src/core/server/elasticsearch/client/log_query_and_deprecation.ts
@@ -0,0 +1,143 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { Buffer } from 'buffer';
+import { stringify } from 'querystring';
+import { errors, DiagnosticResult, RequestBody, Client } from '@elastic/elasticsearch';
+import type { ElasticsearchErrorDetails } from './types';
+import { Logger } from '../../logging';
+
+const convertQueryString = (qs: string | Record | undefined): string => {
+ if (qs === undefined || typeof qs === 'string') {
+ return qs ?? '';
+ }
+ return stringify(qs);
+};
+
+function ensureString(body: RequestBody): string {
+ if (typeof body === 'string') return body;
+ if (Buffer.isBuffer(body)) return '[buffer]';
+ if ('readable' in body && body.readable && typeof body._read === 'function') return '[stream]';
+ return JSON.stringify(body);
+}
+
+/**
+ * Returns a debug message from an Elasticsearch error in the following format:
+ * [error type] error reason
+ */
+export function getErrorMessage(error: errors.ElasticsearchClientError): string {
+ if (error instanceof errors.ResponseError) {
+ const errorBody = error.meta.body as ElasticsearchErrorDetails;
+ return `[${errorBody?.error?.type}]: ${errorBody?.error?.reason ?? error.message}`;
+ }
+ return `[${error.name}]: ${error.message}`;
+}
+
+/**
+ * returns a string in format:
+ *
+ * status code
+ * method URL
+ * request body
+ *
+ * so it could be copy-pasted into the Dev console
+ */
+function getResponseMessage(event: DiagnosticResult): string {
+ const errorMeta = getRequestDebugMeta(event);
+ const body = errorMeta.body ? `\n${errorMeta.body}` : '';
+ return `${errorMeta.statusCode}\n${errorMeta.method} ${errorMeta.url}${body}`;
+}
+
+/**
+ * Returns stringified debug information from an Elasticsearch request event
+ * useful for logging in case of an unexpected failure.
+ */
+export function getRequestDebugMeta(event: DiagnosticResult): {
+ url: string;
+ body: string;
+ statusCode: number | null;
+ method: string;
+} {
+ const params = event.meta.request.params;
+ // definition is wrong, `params.querystring` can be either a string or an object
+ const querystring = convertQueryString(params.querystring);
+ return {
+ url: `${params.path}${querystring ? `?${querystring}` : ''}`,
+ body: params.body ? `${ensureString(params.body)}` : '',
+ method: params.method,
+ statusCode: event.statusCode!,
+ };
+}
+
+/** HTTP Warning headers have the following syntax:
+ * (where warn-code is a three digit number)
+ * This function tests if a warning comes from an Elasticsearch warn-agent
+ * */
+const isEsWarning = (warning: string) => /\d\d\d Elasticsearch-/.test(warning);
+
+export const instrumentEsQueryAndDeprecationLogger = ({
+ logger,
+ client,
+ type,
+}: {
+ logger: Logger;
+ client: Client;
+ type: string;
+}) => {
+ const queryLogger = logger.get('query', type);
+ const deprecationLogger = logger.get('deprecation');
+ client.diagnostic.on('response', (error, event) => {
+ if (event) {
+ const opaqueId = event.meta.request.options.opaqueId;
+ const meta = opaqueId
+ ? {
+ http: { request: { id: event.meta.request.options.opaqueId } },
+ }
+ : undefined; // do not clutter logs if opaqueId is not present
+ let queryMsg = '';
+ if (error) {
+ if (error instanceof errors.ResponseError) {
+ queryMsg = `${getResponseMessage(event)} ${getErrorMessage(error)}`;
+ } else {
+ queryMsg = getErrorMessage(error);
+ }
+ } else {
+ queryMsg = getResponseMessage(event);
+ }
+
+ queryLogger.debug(queryMsg, meta);
+
+ if (event.warnings && event.warnings.filter(isEsWarning).length > 0) {
+ // Plugins can explicitly mark requests as originating from a user by
+ // removing the `'x-elastic-product-origin': 'kibana'` header that's
+ // added by default. User requests will be shown to users in the
+ // upgrade assistant UI as an action item that has to be addressed
+ // before they upgrade.
+ // Kibana requests will be hidden from the upgrade assistant UI and are
+ // only logged to help developers maintain their plugins
+ const requestOrigin =
+ (event.meta.request.params.headers != null &&
+ (event.meta.request.params.headers[
+ 'x-elastic-product-origin'
+ ] as unknown as string)) === 'kibana'
+ ? 'kibana'
+ : 'user';
+
+ // Strip the first 5 stack trace lines as these are irrelavent to finding the call site
+ const stackTrace = new Error().stack?.split('\n').slice(5).join('\n');
+
+ const deprecationMsg = `Elasticsearch deprecation: ${event.warnings}\nOrigin:${requestOrigin}\nStack trace:\n${stackTrace}\nQuery:\n${queryMsg}`;
+ if (requestOrigin === 'kibana') {
+ deprecationLogger.info(deprecationMsg);
+ } else {
+ deprecationLogger.debug(deprecationMsg);
+ }
+ }
+ }
+ });
+};
diff --git a/src/core/server/elasticsearch/elasticsearch_service.test.ts b/src/core/server/elasticsearch/elasticsearch_service.test.ts
index 3b75d19b80a10..ce5672ad30519 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.test.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.test.ts
@@ -21,7 +21,7 @@ import { MockClusterClient, isScriptingEnabledMock } from './elasticsearch_servi
import type { NodesVersionCompatibility } from './version_check/ensure_es_version';
import { BehaviorSubject } from 'rxjs';
import { first } from 'rxjs/operators';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Env } from '../config';
import { configServiceMock, getEnvOptions } from '../config/mocks';
import { CoreContext } from '../core_context';
diff --git a/src/core/server/http/cookie_session_storage.test.ts b/src/core/server/http/cookie_session_storage.test.ts
index ad05d37c81e99..8e2cd58733faf 100644
--- a/src/core/server/http/cookie_session_storage.test.ts
+++ b/src/core/server/http/cookie_session_storage.test.ts
@@ -8,7 +8,7 @@
import { parse as parseCookie } from 'tough-cookie';
import supertest from 'supertest';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { ByteSizeValue } from '@kbn/config-schema';
import { BehaviorSubject } from 'rxjs';
diff --git a/src/core/server/http/http_service.test.ts b/src/core/server/http/http_service.test.ts
index 4955d19668580..3a387cdfd5e35 100644
--- a/src/core/server/http/http_service.test.ts
+++ b/src/core/server/http/http_service.test.ts
@@ -10,7 +10,7 @@ import { mockHttpServer } from './http_service.test.mocks';
import { noop } from 'lodash';
import { BehaviorSubject } from 'rxjs';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { getEnvOptions } from '../config/mocks';
import { HttpService } from '.';
import { HttpConfigType, config } from './http_config';
diff --git a/src/core/server/http/test_utils.ts b/src/core/server/http/test_utils.ts
index 4e1a88e967f8f..8a8c545b365b3 100644
--- a/src/core/server/http/test_utils.ts
+++ b/src/core/server/http/test_utils.ts
@@ -8,7 +8,7 @@
import { BehaviorSubject } from 'rxjs';
import moment from 'moment';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { ByteSizeValue } from '@kbn/config-schema';
import { Env } from '../config';
import { HttpService } from './http_service';
diff --git a/src/core/server/metrics/logging/get_ops_metrics_log.test.ts b/src/core/server/metrics/logging/get_ops_metrics_log.test.ts
index cba188c94c74e..3fd3c4a7a24d6 100644
--- a/src/core/server/metrics/logging/get_ops_metrics_log.test.ts
+++ b/src/core/server/metrics/logging/get_ops_metrics_log.test.ts
@@ -42,6 +42,7 @@ const testMetrics = {
memory: { heap: { used_in_bytes: 100 } },
uptime_in_millis: 1500,
event_loop_delay: 50,
+ event_loop_delay_histogram: { percentiles: { '50': 50, '75': 75, '95': 95, '99': 99 } },
},
os: {
load: {
@@ -56,7 +57,7 @@ describe('getEcsOpsMetricsLog', () => {
it('provides correctly formatted message', () => {
const result = getEcsOpsMetricsLog(createMockOpsMetrics(testMetrics));
expect(result.message).toMatchInlineSnapshot(
- `"memory: 100.0B uptime: 0:00:01 load: [10.00,20.00,30.00] delay: 50.000"`
+ `"memory: 100.0B uptime: 0:00:01 load: [10.00,20.00,30.00] mean delay: 50.000 delay histogram: { 50: 50.000; 95: 95.000; 99: 99.000 }"`
);
});
@@ -70,6 +71,7 @@ describe('getEcsOpsMetricsLog', () => {
const missingMetrics = {
...baseMetrics,
process: {},
+ processes: [],
os: {},
} as unknown as OpsMetrics;
const logMeta = getEcsOpsMetricsLog(missingMetrics);
@@ -77,39 +79,41 @@ describe('getEcsOpsMetricsLog', () => {
});
it('provides an ECS-compatible response', () => {
- const logMeta = getEcsOpsMetricsLog(createBaseOpsMetrics());
- expect(logMeta).toMatchInlineSnapshot(`
+ const logMeta = getEcsOpsMetricsLog(createMockOpsMetrics(testMetrics));
+ expect(logMeta.meta).toMatchInlineSnapshot(`
Object {
- "message": "memory: 1.0B load: [1.00,1.00,1.00] delay: 1.000",
- "meta": Object {
- "event": Object {
- "category": Array [
- "process",
- "host",
- ],
- "kind": "metric",
- "type": Array [
- "info",
- ],
- },
- "host": Object {
- "os": Object {
- "load": Object {
- "15m": 1,
- "1m": 1,
- "5m": 1,
- },
+ "event": Object {
+ "category": Array [
+ "process",
+ "host",
+ ],
+ "kind": "metric",
+ "type": Array [
+ "info",
+ ],
+ },
+ "host": Object {
+ "os": Object {
+ "load": Object {
+ "15m": 30,
+ "1m": 10,
+ "5m": 20,
},
},
- "process": Object {
- "eventLoopDelay": 1,
- "memory": Object {
- "heap": Object {
- "usedInBytes": 1,
- },
+ },
+ "process": Object {
+ "eventLoopDelay": 50,
+ "eventLoopDelayHistogram": Object {
+ "50": 50,
+ "95": 95,
+ "99": 99,
+ },
+ "memory": Object {
+ "heap": Object {
+ "usedInBytes": 100,
},
- "uptime": 0,
},
+ "uptime": 1,
},
}
`);
diff --git a/src/core/server/metrics/logging/get_ops_metrics_log.ts b/src/core/server/metrics/logging/get_ops_metrics_log.ts
index 7e13f35889ec7..6211407ae86f0 100644
--- a/src/core/server/metrics/logging/get_ops_metrics_log.ts
+++ b/src/core/server/metrics/logging/get_ops_metrics_log.ts
@@ -30,10 +30,29 @@ export function getEcsOpsMetricsLog(metrics: OpsMetrics) {
// HH:mm:ss message format for backward compatibility
const uptimeValMsg = uptimeVal ? `uptime: ${numeral(uptimeVal).format('00:00:00')} ` : '';
- // Event loop delay is in ms
+ // Event loop delay metrics are in ms
const eventLoopDelayVal = process?.event_loop_delay;
const eventLoopDelayValMsg = eventLoopDelayVal
- ? `delay: ${numeral(process?.event_loop_delay).format('0.000')}`
+ ? `mean delay: ${numeral(process?.event_loop_delay).format('0.000')}`
+ : '';
+
+ const eventLoopDelayPercentiles = process?.event_loop_delay_histogram?.percentiles;
+
+ // Extract 50th, 95th and 99th percentiles for log meta
+ const eventLoopDelayHistVals = eventLoopDelayPercentiles
+ ? {
+ 50: eventLoopDelayPercentiles[50],
+ 95: eventLoopDelayPercentiles[95],
+ 99: eventLoopDelayPercentiles[99],
+ }
+ : undefined;
+ // Format message from 50th, 95th and 99th percentiles
+ const eventLoopDelayHistMsg = eventLoopDelayPercentiles
+ ? ` delay histogram: { 50: ${numeral(eventLoopDelayPercentiles['50']).format(
+ '0.000'
+ )}; 95: ${numeral(eventLoopDelayPercentiles['95']).format('0.000')}; 99: ${numeral(
+ eventLoopDelayPercentiles['99']
+ ).format('0.000')} }`
: '';
const loadEntries = {
@@ -65,6 +84,7 @@ export function getEcsOpsMetricsLog(metrics: OpsMetrics) {
},
},
eventLoopDelay: eventLoopDelayVal,
+ eventLoopDelayHistogram: eventLoopDelayHistVals,
},
host: {
os: {
@@ -75,7 +95,13 @@ export function getEcsOpsMetricsLog(metrics: OpsMetrics) {
};
return {
- message: `${processMemoryUsedInBytesMsg}${uptimeValMsg}${loadValsMsg}${eventLoopDelayValMsg}`,
+ message: [
+ processMemoryUsedInBytesMsg,
+ uptimeValMsg,
+ loadValsMsg,
+ eventLoopDelayValMsg,
+ eventLoopDelayHistMsg,
+ ].join(''),
meta,
};
}
diff --git a/src/core/server/metrics/metrics_service.test.ts b/src/core/server/metrics/metrics_service.test.ts
index d7de41fd7ccf7..27043b8fa2c8a 100644
--- a/src/core/server/metrics/metrics_service.test.ts
+++ b/src/core/server/metrics/metrics_service.test.ts
@@ -203,6 +203,7 @@ describe('MetricsService', () => {
},
"process": Object {
"eventLoopDelay": undefined,
+ "eventLoopDelayHistogram": undefined,
"memory": Object {
"heap": Object {
"usedInBytes": undefined,
diff --git a/src/core/server/plugins/discovery/plugins_discovery.test.ts b/src/core/server/plugins/discovery/plugins_discovery.test.ts
index 958e051d0476d..a6ffdff4422be 100644
--- a/src/core/server/plugins/discovery/plugins_discovery.test.ts
+++ b/src/core/server/plugins/discovery/plugins_discovery.test.ts
@@ -7,7 +7,7 @@
*/
// must be before mocks imports to avoid conflicting with `REPO_ROOT` accessor.
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { mockPackage, scanPluginSearchPathsMock } from './plugins_discovery.test.mocks';
import mockFs from 'mock-fs';
import { loggingSystemMock } from '../../logging/logging_system.mock';
diff --git a/src/core/server/plugins/integration_tests/plugins_service.test.ts b/src/core/server/plugins/integration_tests/plugins_service.test.ts
index 4170d9422f277..ebbb3fa473b6d 100644
--- a/src/core/server/plugins/integration_tests/plugins_service.test.ts
+++ b/src/core/server/plugins/integration_tests/plugins_service.test.ts
@@ -7,7 +7,7 @@
*/
// must be before mocks imports to avoid conflicting with `REPO_ROOT` accessor.
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { mockPackage, mockDiscover } from './plugins_service.test.mocks';
import { join } from 'path';
diff --git a/src/core/server/plugins/plugin.test.ts b/src/core/server/plugins/plugin.test.ts
index 513e893992005..92cbda2a69cfe 100644
--- a/src/core/server/plugins/plugin.test.ts
+++ b/src/core/server/plugins/plugin.test.ts
@@ -8,7 +8,7 @@
import { join } from 'path';
import { BehaviorSubject } from 'rxjs';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { schema } from '@kbn/config-schema';
import { Env } from '../config';
diff --git a/src/core/server/plugins/plugin_context.test.ts b/src/core/server/plugins/plugin_context.test.ts
index 867d4d978314b..7bcf392ed510b 100644
--- a/src/core/server/plugins/plugin_context.test.ts
+++ b/src/core/server/plugins/plugin_context.test.ts
@@ -8,7 +8,7 @@
import { duration } from 'moment';
import { first } from 'rxjs/operators';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { fromRoot } from '@kbn/utils';
import {
createPluginInitializerContext,
diff --git a/src/core/server/plugins/plugins_config.test.ts b/src/core/server/plugins/plugins_config.test.ts
index d65b057fb65c0..b9225054e63ef 100644
--- a/src/core/server/plugins/plugins_config.test.ts
+++ b/src/core/server/plugins/plugins_config.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { getEnvOptions } from '../config/mocks';
import { PluginsConfig, PluginsConfigType } from './plugins_config';
import { Env } from '../config';
diff --git a/src/core/server/plugins/plugins_service.test.ts b/src/core/server/plugins/plugins_service.test.ts
index 0c077d732c67b..5a05817d2111f 100644
--- a/src/core/server/plugins/plugins_service.test.ts
+++ b/src/core/server/plugins/plugins_service.test.ts
@@ -11,7 +11,8 @@ import { mockDiscover, mockPackage } from './plugins_service.test.mocks';
import { resolve, join } from 'path';
import { BehaviorSubject, from } from 'rxjs';
import { schema } from '@kbn/config-schema';
-import { createAbsolutePathSerializer, REPO_ROOT } from '@kbn/dev-utils';
+import { createAbsolutePathSerializer } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { ConfigPath, ConfigService, Env } from '../config';
import { rawConfigServiceMock, getEnvOptions } from '../config/mocks';
diff --git a/src/core/server/plugins/plugins_system.test.ts b/src/core/server/plugins/plugins_system.test.ts
index 4cd8e4c551bea..3d8a47005b362 100644
--- a/src/core/server/plugins/plugins_system.test.ts
+++ b/src/core/server/plugins/plugins_system.test.ts
@@ -14,7 +14,7 @@ import {
import { BehaviorSubject } from 'rxjs';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Env } from '../config';
import { configServiceMock, getEnvOptions } from '../config/mocks';
import { CoreContext } from '../core_context';
diff --git a/src/core/server/preboot/preboot_service.test.ts b/src/core/server/preboot/preboot_service.test.ts
index dd4b1cb7d1df0..77242f0c5765f 100644
--- a/src/core/server/preboot/preboot_service.test.ts
+++ b/src/core/server/preboot/preboot_service.test.ts
@@ -7,7 +7,7 @@
*/
import { nextTick } from '@kbn/test/jest';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { LoggerFactory } from '@kbn/logging';
import { Env } from '@kbn/config';
import { getEnvOptions } from '../config/mocks';
diff --git a/src/core/server/root/index.test.ts b/src/core/server/root/index.test.ts
index 7eba051a128f0..6ea3e05b9c2c2 100644
--- a/src/core/server/root/index.test.ts
+++ b/src/core/server/root/index.test.ts
@@ -10,7 +10,7 @@ import { rawConfigService, configService, logger, mockServer } from './index.tes
import { BehaviorSubject } from 'rxjs';
import { filter, first } from 'rxjs/operators';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { getEnvOptions } from '../config/mocks';
import { Root } from '.';
import { Env } from '../config';
diff --git a/src/core/server/saved_objects/migrations/integration_tests/7.7.2_xpack_100k.test.ts b/src/core/server/saved_objects/migrations/integration_tests/7.7.2_xpack_100k.test.ts
index c22c6154c2605..139cd298d28ed 100644
--- a/src/core/server/saved_objects/migrations/integration_tests/7.7.2_xpack_100k.test.ts
+++ b/src/core/server/saved_objects/migrations/integration_tests/7.7.2_xpack_100k.test.ts
@@ -8,7 +8,7 @@
import path from 'path';
import { unlink } from 'fs/promises';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Env } from '@kbn/config';
import { getEnvOptions } from '../../../config/mocks';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
diff --git a/src/core/server/saved_objects/migrations/integration_tests/migration_from_older_v1.test.ts b/src/core/server/saved_objects/migrations/integration_tests/migration_from_older_v1.test.ts
index 0ed9262017263..c341463b78910 100644
--- a/src/core/server/saved_objects/migrations/integration_tests/migration_from_older_v1.test.ts
+++ b/src/core/server/saved_objects/migrations/integration_tests/migration_from_older_v1.test.ts
@@ -10,7 +10,7 @@ import Path from 'path';
import Fs from 'fs';
import Util from 'util';
import Semver from 'semver';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Env } from '@kbn/config';
import { getEnvOptions } from '../../../config/mocks';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
diff --git a/src/core/server/saved_objects/migrations/integration_tests/migration_from_same_v1.test.ts b/src/core/server/saved_objects/migrations/integration_tests/migration_from_same_v1.test.ts
index 15d985daccba6..34d1317755c14 100644
--- a/src/core/server/saved_objects/migrations/integration_tests/migration_from_same_v1.test.ts
+++ b/src/core/server/saved_objects/migrations/integration_tests/migration_from_same_v1.test.ts
@@ -10,7 +10,7 @@ import Path from 'path';
import Fs from 'fs';
import Util from 'util';
import Semver from 'semver';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { Env } from '@kbn/config';
import { getEnvOptions } from '../../../config/mocks';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
diff --git a/src/core/server/saved_objects/saved_objects_service.test.ts b/src/core/server/saved_objects/saved_objects_service.test.ts
index a4f6c019c9624..a8bda95af46f9 100644
--- a/src/core/server/saved_objects/saved_objects_service.test.ts
+++ b/src/core/server/saved_objects/saved_objects_service.test.ts
@@ -19,7 +19,7 @@ import {
import { BehaviorSubject } from 'rxjs';
import { RawPackageInfo } from '@kbn/config';
import { ByteSizeValue } from '@kbn/config-schema';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { SavedObjectsService } from './saved_objects_service';
import { mockCoreContext } from '../core_context.mock';
diff --git a/src/core/server/saved_objects/service/lib/repository.test.ts b/src/core/server/saved_objects/service/lib/repository.test.ts
index ab692b146e7f6..1668df7a82253 100644
--- a/src/core/server/saved_objects/service/lib/repository.test.ts
+++ b/src/core/server/saved_objects/service/lib/repository.test.ts
@@ -3558,6 +3558,20 @@ describe('SavedObjectsRepository', () => {
});
});
+ it('search for the right fields when typeToNamespacesMap is set', async () => {
+ const relevantOpts = {
+ ...commonOptions,
+ fields: ['title'],
+ type: '',
+ namespaces: [],
+ typeToNamespacesMap: new Map([[type, [namespace]]]),
+ };
+
+ await findSuccess(relevantOpts, namespace);
+ const esOptions = client.search.mock.calls[0][0];
+ expect(esOptions?._source ?? []).toContain('index-pattern.title');
+ });
+
it(`accepts hasReferenceOperator`, async () => {
const relevantOpts: SavedObjectsFindOptions = {
...commonOptions,
diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts
index 0d17525016043..53bc6f158bf93 100644
--- a/src/core/server/saved_objects/service/lib/repository.ts
+++ b/src/core/server/saved_objects/service/lib/repository.ts
@@ -930,7 +930,7 @@ export class SavedObjectsRepository {
index: pit ? undefined : this.getIndicesForTypes(allowedTypes),
// If `searchAfter` is provided, we drop `from` as it will not be used for pagination.
from: searchAfter ? undefined : perPage * (page - 1),
- _source: includedFields(type, fields),
+ _source: includedFields(allowedTypes, fields),
preference,
rest_total_hits_as_int: true,
size: perPage,
@@ -938,7 +938,7 @@ export class SavedObjectsRepository {
size: perPage,
seq_no_primary_term: true,
from: perPage * (page - 1),
- _source: includedFields(type, fields),
+ _source: includedFields(allowedTypes, fields),
...(aggsObject ? { aggs: aggsObject } : {}),
...getSearchDsl(this._mappings, this._registry, {
search,
diff --git a/src/core/server/server.test.ts b/src/core/server/server.test.ts
index 112693aae0279..48547883d5f67 100644
--- a/src/core/server/server.test.ts
+++ b/src/core/server/server.test.ts
@@ -26,7 +26,7 @@ import {
} from './server.test.mocks';
import { BehaviorSubject } from 'rxjs';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { rawConfigServiceMock, getEnvOptions } from './config/mocks';
import { Env } from './config';
import { Server } from './server';
diff --git a/src/core/server/ui_settings/integration_tests/index.test.ts b/src/core/server/ui_settings/integration_tests/index.test.ts
index ef635e90dac70..3f85beb2acec6 100644
--- a/src/core/server/ui_settings/integration_tests/index.test.ts
+++ b/src/core/server/ui_settings/integration_tests/index.test.ts
@@ -7,7 +7,7 @@
*/
import { Env } from '@kbn/config';
-import { REPO_ROOT } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { getEnvOptions } from '../../config/mocks';
import { startServers, stopServers } from './lib';
import { docExistsSuite } from './doc_exists';
diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts
index 58720be637e2f..c326c7a35df63 100644
--- a/src/core/test_helpers/kbn_server.ts
+++ b/src/core/test_helpers/kbn_server.ts
@@ -6,7 +6,8 @@
* Side Public License, v 1.
*/
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import {
createTestEsCluster,
CreateTestEsClusterOptions,
diff --git a/src/dev/build/lib/integration_tests/version_info.test.ts b/src/dev/build/lib/integration_tests/version_info.test.ts
index e7a3a04c04734..9385de6e00a4f 100644
--- a/src/dev/build/lib/integration_tests/version_info.test.ts
+++ b/src/dev/build/lib/integration_tests/version_info.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { kibanaPackageJson as pkg } from '@kbn/dev-utils';
+import { kibanaPackageJson as pkg } from '@kbn/utils';
import { getVersionInfo } from '../version_info';
diff --git a/src/dev/build/tasks/install_chromium.js b/src/dev/build/tasks/install_chromium.js
index ad60019ea81a4..2bcceb33fad00 100644
--- a/src/dev/build/tasks/install_chromium.js
+++ b/src/dev/build/tasks/install_chromium.js
@@ -6,10 +6,8 @@
* Side Public License, v 1.
*/
-import { first } from 'rxjs/operators';
-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { installBrowser } from '../../../../x-pack/plugins/reporting/server/browsers/install';
+import { install } from '../../../../x-pack/plugins/screenshotting/server/utils';
export const InstallChromium = {
description: 'Installing Chromium',
@@ -22,13 +20,23 @@ export const InstallChromium = {
// revert after https://github.com/elastic/kibana/issues/109949
if (target === 'darwin-arm64') continue;
- const { binaryPath$ } = installBrowser(
- log,
- build.resolvePathForPlatform(platform, 'x-pack/plugins/reporting/chromium'),
+ const logger = {
+ get: log.withType.bind(log),
+ debug: log.debug.bind(log),
+ info: log.info.bind(log),
+ warn: log.warning.bind(log),
+ trace: log.verbose.bind(log),
+ error: log.error.bind(log),
+ fatal: log.error.bind(log),
+ log: log.write.bind(log),
+ };
+
+ await install(
+ logger,
+ build.resolvePathForPlatform(platform, 'x-pack/plugins/screenshotting/chromium'),
platform.getName(),
platform.getArchitecture()
);
- await binaryPath$.pipe(first()).toPromise();
}
},
};
diff --git a/src/dev/build/tasks/os_packages/docker_generator/bundle_dockerfiles.ts b/src/dev/build/tasks/os_packages/docker_generator/bundle_dockerfiles.ts
index 02b469820f900..cc1ffb5f3e301 100644
--- a/src/dev/build/tasks/os_packages/docker_generator/bundle_dockerfiles.ts
+++ b/src/dev/build/tasks/os_packages/docker_generator/bundle_dockerfiles.ts
@@ -10,7 +10,8 @@ import { resolve } from 'path';
import { readFileSync } from 'fs';
import { copyFile } from 'fs/promises';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import Mustache from 'mustache';
import { compressTar, copyAll, mkdirp, write, Config } from '../../../lib';
diff --git a/src/dev/build/tasks/os_packages/docker_generator/run.ts b/src/dev/build/tasks/os_packages/docker_generator/run.ts
index 6a192baed3fa3..085b4393caa66 100644
--- a/src/dev/build/tasks/os_packages/docker_generator/run.ts
+++ b/src/dev/build/tasks/os_packages/docker_generator/run.ts
@@ -10,7 +10,8 @@ import { access, link, unlink, chmod } from 'fs';
import { resolve, basename } from 'path';
import { promisify } from 'util';
-import { ToolingLog, kibanaPackageJson } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { kibanaPackageJson } from '@kbn/utils';
import { write, copyAll, mkdirp, exec, Config, Build } from '../../../lib';
import * as dockerTemplates from './templates';
diff --git a/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/Dockerfile b/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/Dockerfile
index dbdace85eda01..e9a6ef3539692 100644
--- a/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/Dockerfile
+++ b/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/Dockerfile
@@ -2,9 +2,9 @@
# Build stage 0
# Extract Kibana and make various file manipulations.
################################################################################
-ARG BASE_REGISTRY=registry1.dsop.io
+ARG BASE_REGISTRY=registry1.dso.mil
ARG BASE_IMAGE=redhat/ubi/ubi8
-ARG BASE_TAG=8.4
+ARG BASE_TAG=8.5
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} as prep_files
diff --git a/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/hardening_manifest.yaml b/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/hardening_manifest.yaml
index 24614039e5eb7..1c7926c2fcbc2 100644
--- a/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/hardening_manifest.yaml
+++ b/src/dev/build/tasks/os_packages/docker_generator/templates/ironbank/hardening_manifest.yaml
@@ -14,7 +14,7 @@ tags:
# Build args passed to Dockerfile ARGs
args:
BASE_IMAGE: 'redhat/ubi/ubi8'
- BASE_TAG: '8.4'
+ BASE_TAG: '8.5'
# Docker image labels
labels:
@@ -59,4 +59,4 @@ maintainers:
- email: "yalabe.dukuly@anchore.com"
name: "Yalabe Dukuly"
username: "yalabe.dukuly"
- cht_member: true
\ No newline at end of file
+ cht_member: true
diff --git a/src/dev/chromium_version.ts b/src/dev/chromium_version.ts
index 410fcc72fbc0f..1f55330a92bb6 100644
--- a/src/dev/chromium_version.ts
+++ b/src/dev/chromium_version.ts
@@ -6,7 +6,8 @@
* Side Public License, v 1.
*/
-import { run, REPO_ROOT, ToolingLog } from '@kbn/dev-utils';
+import { run, ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import chalk from 'chalk';
import cheerio from 'cheerio';
import fs from 'fs';
diff --git a/src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js b/src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js
index 05af7c2a154a4..40d36ed46ea34 100644
--- a/src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js
+++ b/src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js
@@ -7,7 +7,8 @@
*/
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
-import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
const log = new ToolingLog({
level: 'info',
@@ -15,16 +16,17 @@ const log = new ToolingLog({
});
describe(`enumeratePatterns`, () => {
- it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.ts to kibana-reporting`, () => {
+ it(`should resolve x-pack/plugins/screenshotting/server/browsers/extract/unzip.ts to kibana-screenshotting`, () => {
const actual = enumeratePatterns(REPO_ROOT)(log)(
- new Map([['x-pack/plugins/reporting', ['kibana-reporting']]])
+ new Map([['x-pack/plugins/screenshotting', ['kibana-screenshotting']]])
);
- expect(
- actual[0].includes(
- 'x-pack/plugins/reporting/server/browsers/extract/unzip.ts kibana-reporting'
- )
- ).toBe(true);
+ expect(actual).toHaveProperty(
+ '0',
+ expect.arrayContaining([
+ 'x-pack/plugins/screenshotting/server/browsers/extract/unzip.ts kibana-screenshotting',
+ ])
+ );
});
it(`should resolve src/plugins/charts/common/static/color_maps/color_maps.ts to kibana-app`, () => {
const actual = enumeratePatterns(REPO_ROOT)(log)(
diff --git a/src/dev/code_coverage/ingest_coverage/team_assignment/index.js b/src/dev/code_coverage/ingest_coverage/team_assignment/index.js
index 0e341a3aac1dc..a38c4ee50b40a 100644
--- a/src/dev/code_coverage/ingest_coverage/team_assignment/index.js
+++ b/src/dev/code_coverage/ingest_coverage/team_assignment/index.js
@@ -6,7 +6,8 @@
* Side Public License, v 1.
*/
-import { run, createFlagError, REPO_ROOT } from '@kbn/dev-utils';
+import { run, createFlagError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { parse } from './parse_owners';
import { flush } from './flush';
import { enumeratePatterns } from './enumerate_patterns';
diff --git a/src/dev/ensure_all_tests_in_ci_group.ts b/src/dev/ensure_all_tests_in_ci_group.ts
index aeccefae05d2c..a2d9729d3352b 100644
--- a/src/dev/ensure_all_tests_in_ci_group.ts
+++ b/src/dev/ensure_all_tests_in_ci_group.ts
@@ -12,7 +12,8 @@ import Fs from 'fs/promises';
import execa from 'execa';
import { safeLoad } from 'js-yaml';
-import { run, REPO_ROOT } from '@kbn/dev-utils';
+import { run } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { schema } from '@kbn/config-schema';
const RELATIVE_JOBS_YAML_PATH = '.ci/ci_groups.yml';
diff --git a/src/dev/eslint/run_eslint_with_types.ts b/src/dev/eslint/run_eslint_with_types.ts
index 750011dea1031..0f2a10d07d681 100644
--- a/src/dev/eslint/run_eslint_with_types.ts
+++ b/src/dev/eslint/run_eslint_with_types.ts
@@ -14,7 +14,8 @@ import execa from 'execa';
import * as Rx from 'rxjs';
import { mergeMap, reduce } from 'rxjs/operators';
import { supportsColor } from 'chalk';
-import { REPO_ROOT, run, createFailError } from '@kbn/dev-utils';
+import { run, createFailError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { lastValueFrom } from '@kbn/std';
import { PROJECTS } from '../typescript/projects';
diff --git a/src/dev/plugin_discovery/find_plugins.ts b/src/dev/plugin_discovery/find_plugins.ts
index f1725f34d1f8e..53a53bc08e15b 100644
--- a/src/dev/plugin_discovery/find_plugins.ts
+++ b/src/dev/plugin_discovery/find_plugins.ts
@@ -8,11 +8,9 @@
import Path from 'path';
import { getPluginSearchPaths } from '@kbn/config';
-import {
- KibanaPlatformPlugin,
- REPO_ROOT,
- simpleKibanaPlatformPluginDiscovery,
-} from '@kbn/dev-utils';
+import { KibanaPlatformPlugin, simpleKibanaPlatformPluginDiscovery } from '@kbn/dev-utils';
+
+import { REPO_ROOT } from '@kbn/utils';
export interface SearchOptions {
oss: boolean;
diff --git a/src/dev/run_build_docs_cli.ts b/src/dev/run_build_docs_cli.ts
index aad524b4437d3..8ee75912c1a7e 100644
--- a/src/dev/run_build_docs_cli.ts
+++ b/src/dev/run_build_docs_cli.ts
@@ -9,7 +9,8 @@
import Path from 'path';
import dedent from 'dedent';
-import { run, REPO_ROOT, createFailError } from '@kbn/dev-utils';
+import { run, createFailError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
const DEFAULT_DOC_REPO_PATH = Path.resolve(REPO_ROOT, '..', 'docs');
diff --git a/src/dev/run_find_plugins_with_circular_deps.ts b/src/dev/run_find_plugins_with_circular_deps.ts
index f7974b464fcaf..f9ee7bd84c54f 100644
--- a/src/dev/run_find_plugins_with_circular_deps.ts
+++ b/src/dev/run_find_plugins_with_circular_deps.ts
@@ -10,7 +10,8 @@ import dedent from 'dedent';
import { parseDependencyTree, parseCircular, prettyCircular } from 'dpdm';
import { relative } from 'path';
import { getPluginSearchPaths } from '@kbn/config';
-import { REPO_ROOT, run } from '@kbn/dev-utils';
+import { run } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
interface Options {
debug?: boolean;
diff --git a/src/dev/run_precommit_hook.js b/src/dev/run_precommit_hook.js
index a7bd0a9f57f6e..dfa3a94426bb2 100644
--- a/src/dev/run_precommit_hook.js
+++ b/src/dev/run_precommit_hook.js
@@ -8,7 +8,8 @@
import SimpleGit from 'simple-git/promise';
-import { run, combineErrors, createFlagError, REPO_ROOT } from '@kbn/dev-utils';
+import { run, combineErrors, createFlagError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import * as Eslint from './eslint';
import * as Stylelint from './stylelint';
import { getFilesForCommit, checkFileCasing } from './precommit_hook';
diff --git a/src/dev/typescript/build_ts_refs.ts b/src/dev/typescript/build_ts_refs.ts
index aaa8c0d12fa4d..f3896cf676e27 100644
--- a/src/dev/typescript/build_ts_refs.ts
+++ b/src/dev/typescript/build_ts_refs.ts
@@ -8,7 +8,8 @@
import Path from 'path';
-import { ToolingLog, REPO_ROOT, ProcRunner } from '@kbn/dev-utils';
+import { ToolingLog, ProcRunner } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import { ROOT_REFS_CONFIG_PATH } from './root_refs_config';
import { Project } from './project';
diff --git a/src/dev/typescript/build_ts_refs_cli.ts b/src/dev/typescript/build_ts_refs_cli.ts
index c68424c2a98f7..09866315fc8dd 100644
--- a/src/dev/typescript/build_ts_refs_cli.ts
+++ b/src/dev/typescript/build_ts_refs_cli.ts
@@ -8,7 +8,8 @@
import Path from 'path';
-import { run, REPO_ROOT, createFlagError } from '@kbn/dev-utils';
+import { run, createFlagError } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import del from 'del';
import { RefOutputCache } from './ref_output_cache';
diff --git a/src/dev/typescript/ref_output_cache/ref_output_cache.ts b/src/dev/typescript/ref_output_cache/ref_output_cache.ts
index b7e641ceb33d5..32b08ec1ba0df 100644
--- a/src/dev/typescript/ref_output_cache/ref_output_cache.ts
+++ b/src/dev/typescript/ref_output_cache/ref_output_cache.ts
@@ -9,7 +9,8 @@
import Path from 'path';
import Fs from 'fs/promises';
-import { ToolingLog, kibanaPackageJson, extract } from '@kbn/dev-utils';
+import { ToolingLog, extract } from '@kbn/dev-utils';
+import { kibanaPackageJson } from '@kbn/utils';
import del from 'del';
import tempy from 'tempy';
diff --git a/src/dev/typescript/root_refs_config.ts b/src/dev/typescript/root_refs_config.ts
index f4aa88f1ea6b2..e20b1ab46cd82 100644
--- a/src/dev/typescript/root_refs_config.ts
+++ b/src/dev/typescript/root_refs_config.ts
@@ -10,7 +10,8 @@ import Path from 'path';
import Fs from 'fs/promises';
import dedent from 'dedent';
-import { REPO_ROOT, ToolingLog } from '@kbn/dev-utils';
+import { ToolingLog } from '@kbn/dev-utils';
+import { REPO_ROOT } from '@kbn/utils';
import normalize from 'normalize-path';
import { PROJECTS } from './projects';
diff --git a/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/index.scss b/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/index.scss
index 6e1afd91c476d..fb004dfce4ec0 100644
--- a/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/index.scss
+++ b/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/index.scss
@@ -9,14 +9,6 @@
padding: $euiSizeS;
}
-.heatmap-chart__empty {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-}
-
.heatmap-chart-icon__subdued {
fill: $euiTextSubduedColor;
}
diff --git a/src/plugins/charts/public/static/components/empty_placeholder.scss b/src/plugins/charts/public/static/components/empty_placeholder.scss
new file mode 100644
index 0000000000000..3f98da9eecb6a
--- /dev/null
+++ b/src/plugins/charts/public/static/components/empty_placeholder.scss
@@ -0,0 +1,7 @@
+.chart__empty-placeholder {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
\ No newline at end of file
diff --git a/src/plugins/charts/public/static/components/empty_placeholder.tsx b/src/plugins/charts/public/static/components/empty_placeholder.tsx
index db3f3fb6739d5..e376120c9cd9e 100644
--- a/src/plugins/charts/public/static/components/empty_placeholder.tsx
+++ b/src/plugins/charts/public/static/components/empty_placeholder.tsx
@@ -9,15 +9,20 @@
import React from 'react';
import { EuiIcon, EuiText, IconType, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
+import './empty_placeholder.scss';
-export const EmptyPlaceholder = (props: { icon: IconType }) => (
+export const EmptyPlaceholder = ({
+ icon,
+ message = ,
+}: {
+ icon: IconType;
+ message?: JSX.Element;
+}) => (
<>
-
-
+
+
-
-
-
+ {message}
>
);
diff --git a/src/plugins/console/public/application/contexts/services_context.mock.ts b/src/plugins/console/public/application/contexts/services_context.mock.ts
index c19413bdd0413..90a5d9ddce010 100644
--- a/src/plugins/console/public/application/contexts/services_context.mock.ts
+++ b/src/plugins/console/public/application/contexts/services_context.mock.ts
@@ -7,7 +7,7 @@
*/
import { notificationServiceMock } from '../../../../../core/public/mocks';
-import { httpServiceMock } from '../../../../../core/public/mocks';
+import { httpServiceMock, themeServiceMock } from '../../../../../core/public/mocks';
import type { ObjectStorageClient } from '../../../common/types';
import { HistoryMock } from '../../services/history.mock';
@@ -35,6 +35,7 @@ export const serviceContextMock = {
objectStorageClient: {} as unknown as ObjectStorageClient,
},
docLinkVersion: 'NA',
+ theme$: themeServiceMock.create().start().theme$,
};
},
};
diff --git a/src/plugins/console/public/application/contexts/services_context.tsx b/src/plugins/console/public/application/contexts/services_context.tsx
index 53c021d4d0982..5912de0375590 100644
--- a/src/plugins/console/public/application/contexts/services_context.tsx
+++ b/src/plugins/console/public/application/contexts/services_context.tsx
@@ -7,7 +7,9 @@
*/
import React, { createContext, useContext, useEffect } from 'react';
-import { NotificationsSetup } from 'kibana/public';
+import { Observable } from 'rxjs';
+import { NotificationsSetup, CoreTheme } from 'kibana/public';
+
import { History, Settings, Storage } from '../../services';
import { ObjectStorageClient } from '../../../common/types';
import { MetricsTracker } from '../../types';
@@ -26,6 +28,7 @@ interface ContextServices {
export interface ContextValue {
services: ContextServices;
docLinkVersion: string;
+ theme$: Observable;
}
interface ContextProps {
diff --git a/src/plugins/console/public/application/hooks/use_send_current_request_to_es/use_send_current_request_to_es.ts b/src/plugins/console/public/application/hooks/use_send_current_request_to_es/use_send_current_request_to_es.ts
index d025760c19d0a..81aa571b45a20 100644
--- a/src/plugins/console/public/application/hooks/use_send_current_request_to_es/use_send_current_request_to_es.ts
+++ b/src/plugins/console/public/application/hooks/use_send_current_request_to_es/use_send_current_request_to_es.ts
@@ -8,20 +8,21 @@
import { i18n } from '@kbn/i18n';
import { useCallback } from 'react';
+
+import { toMountPoint } from '../../../shared_imports';
import { isQuotaExceededError } from '../../../services/history';
+// @ts-ignore
+import { retrieveAutoCompleteInfo } from '../../../lib/mappings/mappings';
import { instance as registry } from '../../contexts/editor_context/editor_registry';
import { useRequestActionContext, useServicesContext } from '../../contexts';
+import { StorageQuotaError } from '../../components/storage_quota_error';
import { sendRequestToES } from './send_request_to_es';
import { track } from './track';
-import { toMountPoint } from '../../../../../kibana_react/public';
-
-// @ts-ignore
-import { retrieveAutoCompleteInfo } from '../../../lib/mappings/mappings';
-import { StorageQuotaError } from '../../components/storage_quota_error';
export const useSendCurrentRequestToES = () => {
const {
services: { history, settings, notifications, trackUiMetric },
+ theme$,
} = useServicesContext();
const dispatch = useRequestActionContext();
@@ -83,7 +84,8 @@ export const useSendCurrentRequestToES = () => {
settings.setHistoryDisabled(true);
notifications.toasts.remove(toast);
},
- })
+ }),
+ { theme$ }
),
});
} else {
@@ -127,5 +129,5 @@ export const useSendCurrentRequestToES = () => {
});
}
}
- }, [dispatch, settings, history, notifications, trackUiMetric]);
+ }, [dispatch, settings, history, notifications, trackUiMetric, theme$]);
};
diff --git a/src/plugins/console/public/application/index.tsx b/src/plugins/console/public/application/index.tsx
index 0b41095f8cc19..719975874cd44 100644
--- a/src/plugins/console/public/application/index.tsx
+++ b/src/plugins/console/public/application/index.tsx
@@ -8,13 +8,16 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { HttpSetup, NotificationsSetup, I18nStart } from 'src/core/public';
-import { ServicesContextProvider, EditorContextProvider, RequestContextProvider } from './contexts';
-import { Main } from './containers';
+import { Observable } from 'rxjs';
+import { HttpSetup, NotificationsSetup, I18nStart, CoreTheme } from 'src/core/public';
+
+import { UsageCollectionSetup } from '../../../usage_collection/public';
+import { KibanaThemeProvider } from '../shared_imports';
import { createStorage, createHistory, createSettings } from '../services';
-import * as localStorageObjectClient from '../lib/local_storage_object_client';
import { createUsageTracker } from '../services/tracker';
-import { UsageCollectionSetup } from '../../../usage_collection/public';
+import * as localStorageObjectClient from '../lib/local_storage_object_client';
+import { Main } from './containers';
+import { ServicesContextProvider, EditorContextProvider, RequestContextProvider } from './contexts';
import { createApi, createEsHostService } from './lib';
export interface BootDependencies {
@@ -24,6 +27,7 @@ export interface BootDependencies {
notifications: NotificationsSetup;
usageCollection?: UsageCollectionSetup;
element: HTMLElement;
+ theme$: Observable;
}
export function renderApp({
@@ -33,6 +37,7 @@ export function renderApp({
usageCollection,
element,
http,
+ theme$,
}: BootDependencies) {
const trackUiMetric = createUsageTracker(usageCollection);
trackUiMetric.load('opened_app');
@@ -49,26 +54,29 @@ export function renderApp({
render(
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
,
element
);
diff --git a/src/plugins/console/public/application/models/legacy_core_editor/mode/worker/worker.js b/src/plugins/console/public/application/models/legacy_core_editor/mode/worker/worker.js
index 866e19a1d0d3e..efd7dbd088581 100644
--- a/src/plugins/console/public/application/models/legacy_core_editor/mode/worker/worker.js
+++ b/src/plugins/console/public/application/models/legacy_core_editor/mode/worker/worker.js
@@ -2022,22 +2022,37 @@ ace.define(
},
// parses and returns the method
method = function () {
- const [first, ...rest] = text.split(' ');
- text = first.toUpperCase() + rest.join(' ');
- ch = ch.toUpperCase();
-
switch (ch) {
+ case 'g':
+ next('g');
+ next('e');
+ next('t');
+ return 'get';
case 'G':
next('G');
next('E');
next('T');
return 'GET';
+ case 'h':
+ next('h');
+ next('e');
+ next('a');
+ next('d');
+ return 'head';
case 'H':
next('H');
next('E');
next('A');
next('D');
return 'HEAD';
+ case 'd':
+ next('d');
+ next('e');
+ next('l');
+ next('e');
+ next('t');
+ next('e');
+ return 'delete';
case 'D':
next('D');
next('E');
@@ -2046,6 +2061,22 @@ ace.define(
next('T');
next('E');
return 'DELETE';
+ case 'p':
+ next('p');
+ switch (ch) {
+ case 'u':
+ next('u');
+ next('t');
+ return 'put';
+ case 'o':
+ next('o');
+ next('s');
+ next('t');
+ return 'post';
+ default:
+ error('Unexpected \'' + ch + '\'');
+ }
+ break;
case 'P':
next('P');
switch (ch) {
diff --git a/src/plugins/console/public/lib/mappings/mappings.js b/src/plugins/console/public/lib/mappings/mappings.js
index d4996f9fd8862..2a4ee6b2e346b 100644
--- a/src/plugins/console/public/lib/mappings/mappings.js
+++ b/src/plugins/console/public/lib/mappings/mappings.js
@@ -250,7 +250,10 @@ function retrieveSettings(settingsKey, settingsToRetrieve) {
// Fetch autocomplete info if setting is set to true, and if user has made changes.
if (settingsToRetrieve[settingsKey] === true) {
- return es.send('GET', settingKeyToPathMap[settingsKey], null, true);
+ // Use pretty=false in these request in order to compress the response by removing whitespace
+ const path = `${settingKeyToPathMap[settingsKey]}?pretty=false`;
+
+ return es.send('GET', path, null, true);
} else {
const settingsPromise = new $.Deferred();
if (settingsToRetrieve[settingsKey] === false) {
diff --git a/src/plugins/console/public/plugin.ts b/src/plugins/console/public/plugin.ts
index d61769c23dfe0..f46f60b485d55 100644
--- a/src/plugins/console/public/plugin.ts
+++ b/src/plugins/console/public/plugin.ts
@@ -52,7 +52,7 @@ export class ConsoleUIPlugin implements Plugin {
+ mount: async ({ element, theme$ }) => {
const [core] = await getStartServices();
const {
@@ -69,6 +69,7 @@ export class ConsoleUIPlugin implements Plugin {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx b/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx
index fc4c6b299284b..3c3872226ffb0 100644
--- a/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx
@@ -56,6 +56,7 @@ beforeEach(async () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/copy_to_dashboard_action.tsx b/src/plugins/dashboard/public/application/actions/copy_to_dashboard_action.tsx
index f16486dd65e3c..3c9c1cbbba83e 100644
--- a/src/plugins/dashboard/public/application/actions/copy_to_dashboard_action.tsx
+++ b/src/plugins/dashboard/public/application/actions/copy_to_dashboard_action.tsx
@@ -7,7 +7,7 @@
*/
import React from 'react';
-import { OverlayStart } from '../../../../../core/public';
+import { CoreStart, OverlayStart } from '../../../../../core/public';
import { dashboardCopyToDashboardAction } from '../../dashboard_strings';
import { EmbeddableStateTransfer, IEmbeddable } from '../../services/embeddable';
import { toMountPoint } from '../../services/kibana_react';
@@ -37,6 +37,7 @@ export class CopyToDashboardAction implements Action
+ />,
+ { theme$: this.theme.theme$ }
),
{
maxWidth: 400,
diff --git a/src/plugins/dashboard/public/application/actions/expand_panel_action.test.tsx b/src/plugins/dashboard/public/application/actions/expand_panel_action.test.tsx
index b20a96c79aed6..f99b539ecb26c 100644
--- a/src/plugins/dashboard/public/application/actions/expand_panel_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/expand_panel_action.test.tsx
@@ -48,6 +48,7 @@ beforeEach(async () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreMock.createStart().http,
+ theme: coreMock.createStart().theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/export_csv_action.test.tsx b/src/plugins/dashboard/public/application/actions/export_csv_action.test.tsx
index 797765eda232d..c08a8d4af68dd 100644
--- a/src/plugins/dashboard/public/application/actions/export_csv_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/export_csv_action.test.tsx
@@ -61,6 +61,7 @@ describe('Export CSV action', () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/library_notification_action.test.tsx b/src/plugins/dashboard/public/application/actions/library_notification_action.test.tsx
index ab442bf839e37..92042f581fad4 100644
--- a/src/plugins/dashboard/public/application/actions/library_notification_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/library_notification_action.test.tsx
@@ -62,6 +62,7 @@ beforeEach(async () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
@@ -90,7 +91,7 @@ beforeEach(async () => {
});
test('Notification is incompatible with Error Embeddables', async () => {
- const action = new LibraryNotificationAction(unlinkAction);
+ const action = new LibraryNotificationAction(coreStart.theme, unlinkAction);
const errorEmbeddable = new ErrorEmbeddable(
'Wow what an awful error',
{ id: ' 404' },
@@ -100,19 +101,19 @@ test('Notification is incompatible with Error Embeddables', async () => {
});
test('Notification is shown when embeddable on dashboard has reference type input', async () => {
- const action = new LibraryNotificationAction(unlinkAction);
+ const action = new LibraryNotificationAction(coreStart.theme, unlinkAction);
embeddable.updateInput(await embeddable.getInputAsRefType());
expect(await action.isCompatible({ embeddable })).toBe(true);
});
test('Notification is not shown when embeddable input is by value', async () => {
- const action = new LibraryNotificationAction(unlinkAction);
+ const action = new LibraryNotificationAction(coreStart.theme, unlinkAction);
embeddable.updateInput(await embeddable.getInputAsValueType());
expect(await action.isCompatible({ embeddable })).toBe(false);
});
test('Notification is not shown when view mode is set to view', async () => {
- const action = new LibraryNotificationAction(unlinkAction);
+ const action = new LibraryNotificationAction(coreStart.theme, unlinkAction);
embeddable.updateInput(await embeddable.getInputAsRefType());
embeddable.updateInput({ viewMode: ViewMode.VIEW });
expect(await action.isCompatible({ embeddable })).toBe(false);
diff --git a/src/plugins/dashboard/public/application/actions/library_notification_action.tsx b/src/plugins/dashboard/public/application/actions/library_notification_action.tsx
index 4211dcf1443ed..b867f83985a6e 100644
--- a/src/plugins/dashboard/public/application/actions/library_notification_action.tsx
+++ b/src/plugins/dashboard/public/application/actions/library_notification_action.tsx
@@ -9,7 +9,8 @@
import React from 'react';
import { Action, IncompatibleActionError } from '../../services/ui_actions';
-import { reactToUiComponent } from '../../services/kibana_react';
+import { CoreStart } from '../../../../../core/public';
+import { KibanaThemeProvider, reactToUiComponent } from '../../services/kibana_react';
import {
IEmbeddable,
ViewMode,
@@ -32,7 +33,7 @@ export class LibraryNotificationAction implements Action {
const { embeddable } = context;
return (
-
+
+
+
);
};
diff --git a/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx b/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx
index de1a475fdbd18..a2a55404072eb 100644
--- a/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx
@@ -58,6 +58,7 @@ describe('LibraryNotificationPopover', () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/open_replace_panel_flyout.tsx b/src/plugins/dashboard/public/application/actions/open_replace_panel_flyout.tsx
index cca72d10fac15..fa79b02d20dd5 100644
--- a/src/plugins/dashboard/public/application/actions/open_replace_panel_flyout.tsx
+++ b/src/plugins/dashboard/public/application/actions/open_replace_panel_flyout.tsx
@@ -47,7 +47,8 @@ export async function openReplacePanelFlyout(options: {
savedObjectsFinder={savedObjectFinder}
notifications={notifications}
getEmbeddableFactories={getEmbeddableFactories}
- />
+ />,
+ { theme$: core.theme.theme$ }
),
{
'data-test-subj': 'dashboardReplacePanel',
diff --git a/src/plugins/dashboard/public/application/actions/replace_panel_action.test.tsx b/src/plugins/dashboard/public/application/actions/replace_panel_action.test.tsx
index fe39f6112a7f3..9781736606607 100644
--- a/src/plugins/dashboard/public/application/actions/replace_panel_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/replace_panel_action.test.tsx
@@ -48,6 +48,7 @@ beforeEach(async () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.test.tsx b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.test.tsx
index 4f10f833f643c..f82b8d1bc7a87 100644
--- a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.test.tsx
+++ b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.test.tsx
@@ -57,6 +57,7 @@ beforeEach(async () => {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
+ theme: coreStart.theme,
presentationUtil: getStubPluginServices(),
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/dashboard_router.tsx b/src/plugins/dashboard/public/application/dashboard_router.tsx
index c74ac506e4809..ae16527b64440 100644
--- a/src/plugins/dashboard/public/application/dashboard_router.tsx
+++ b/src/plugins/dashboard/public/application/dashboard_router.tsx
@@ -20,7 +20,7 @@ import { DashboardListing } from './listing';
import { dashboardStateStore } from './state';
import { DashboardApp } from './dashboard_app';
import { DashboardNoMatch } from './listing/dashboard_no_match';
-import { KibanaContextProvider } from '../services/kibana_react';
+import { KibanaContextProvider, KibanaThemeProvider } from '../services/kibana_react';
import { addHelpMenuToAppChrome, DashboardSessionStorage } from './lib';
import { createDashboardListingFilterUrl } from '../dashboard_constants';
import { createDashboardEditUrl, DashboardConstants } from '../dashboard_constants';
@@ -226,26 +226,28 @@ export async function mountApp({
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx b/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx
index 744d63c1ba04a..d5eef0c05129d 100644
--- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx
+++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx
@@ -55,6 +55,7 @@ const options: DashboardContainerServices = {
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreMock.createStart().http,
+ theme: coreMock.createStart().theme,
presentationUtil,
};
diff --git a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx
index d7081bf020d85..3e259d4e26179 100644
--- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx
+++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx
@@ -36,6 +36,7 @@ import {
KibanaContextProvider,
KibanaReactContext,
KibanaReactContextValue,
+ KibanaThemeProvider,
} from '../../services/kibana_react';
import { PLACEHOLDER_EMBEDDABLE } from './placeholder';
import { DashboardAppCapabilities, DashboardContainerInput } from '../../types';
@@ -60,6 +61,7 @@ export interface DashboardContainerServices {
uiSettings: IUiSettingsClient;
embeddable: EmbeddableStart;
uiActions: UiActionsStart;
+ theme: CoreStart['theme'];
http: CoreStart['http'];
}
@@ -259,9 +261,11 @@ export class DashboardContainer extends Container
-
-
-
+
+
+
+
+
,
dom
diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx
index 7518a36433d35..59f346caf4b0d 100644
--- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx
+++ b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx
@@ -71,6 +71,7 @@ function prepare(props?: Partial) {
} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreMock.createStart().http,
+ theme: coreMock.createStart().theme,
presentationUtil,
screenshotMode: screenshotModePluginMock.createSetupContract(),
};
diff --git a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx
index 97ca4a1332f24..598d6fc5eabb5 100644
--- a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx
+++ b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx
@@ -10,15 +10,25 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { EuiLoadingChart } from '@elastic/eui';
import classNames from 'classnames';
+import { CoreStart } from 'src/core/public';
import { Embeddable, EmbeddableInput, IContainer } from '../../../services/embeddable';
+import { KibanaThemeProvider } from '../../../services/kibana_react';
export const PLACEHOLDER_EMBEDDABLE = 'placeholder';
+export interface PlaceholderEmbeddableServices {
+ theme: CoreStart['theme'];
+}
+
export class PlaceholderEmbeddable extends Embeddable {
public readonly type = PLACEHOLDER_EMBEDDABLE;
private node?: HTMLElement;
- constructor(initialInput: EmbeddableInput, parent?: IContainer) {
+ constructor(
+ initialInput: EmbeddableInput,
+ private readonly services: PlaceholderEmbeddableServices,
+ parent?: IContainer
+ ) {
super(initialInput, {}, parent);
this.input = initialInput;
}
@@ -30,9 +40,11 @@ export class PlaceholderEmbeddable extends Embeddable {
const classes = classNames('embPanel', 'embPanel-isLoading');
ReactDOM.render(
-
-
-
,
+
+
+
+
+ ,
node
);
}
diff --git a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts
index 50cf85998913b..b0dce72ad77e3 100644
--- a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts
+++ b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts
@@ -13,11 +13,17 @@ import {
EmbeddableInput,
IContainer,
} from '../../../services/embeddable';
-import { PlaceholderEmbeddable, PLACEHOLDER_EMBEDDABLE } from './placeholder_embeddable';
+import {
+ PlaceholderEmbeddable,
+ PlaceholderEmbeddableServices,
+ PLACEHOLDER_EMBEDDABLE,
+} from './placeholder_embeddable';
export class PlaceholderEmbeddableFactory implements EmbeddableFactoryDefinition {
public readonly type = PLACEHOLDER_EMBEDDABLE;
+ constructor(private readonly getStartServices: () => Promise) {}
+
public async isEditable() {
return false;
}
@@ -27,7 +33,8 @@ export class PlaceholderEmbeddableFactory implements EmbeddableFactoryDefinition
}
public async create(initialInput: EmbeddableInput, parent?: IContainer) {
- return new PlaceholderEmbeddable(initialInput, parent);
+ const services = await this.getStartServices();
+ return new PlaceholderEmbeddable(initialInput, services, parent);
}
public getDisplayName() {
diff --git a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx
index f0333cefd612f..d9de67ee9455d 100644
--- a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx
+++ b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx
@@ -49,6 +49,7 @@ function getProps(props?: Partial): {
application: applicationServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreMock.createStart().http,
+ theme: coreMock.createStart().theme,
embeddable: {
getTriggerCompatibleActions: (() => []) as any,
getEmbeddablePanel: jest.fn(),
diff --git a/src/plugins/dashboard/public/application/lib/filter_utils.ts b/src/plugins/dashboard/public/application/lib/filter_utils.ts
index a31b83ec2df8f..c6b9ae2d01cf3 100644
--- a/src/plugins/dashboard/public/application/lib/filter_utils.ts
+++ b/src/plugins/dashboard/public/application/lib/filter_utils.ts
@@ -72,7 +72,7 @@ export const cleanFiltersForComparison = (filters: Filter[]) => {
export const cleanFiltersForSerialize = (filters: Filter[]): Filter[] => {
return filters.map((filter) => {
- if (filter.meta.value) {
+ if (filter.meta?.value) {
delete filter.meta.value;
}
return filter;
diff --git a/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts b/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts
index 31579e92bd1ec..03a03842c0e66 100644
--- a/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts
+++ b/src/plugins/dashboard/public/application/lib/load_saved_dashboard_state.ts
@@ -8,10 +8,10 @@
import _ from 'lodash';
+import { getDashboard60Warning, dashboardLoadingErrorStrings } from '../../dashboard_strings';
import { savedObjectToDashboardState } from './convert_dashboard_state';
import { DashboardState, DashboardBuildContext } from '../../types';
import { DashboardConstants, DashboardSavedObject } from '../..';
-import { getDashboard60Warning } from '../../dashboard_strings';
import { migrateLegacyQuery } from './migrate_legacy_query';
import { cleanFiltersForSerialize } from './filter_utils';
import { ViewMode } from '../../services/embeddable';
@@ -52,34 +52,33 @@ export const loadSavedDashboardState = async ({
return;
}
await indexPatterns.ensureDefaultDataView();
- let savedDashboard: DashboardSavedObject | undefined;
try {
- savedDashboard = (await savedDashboards.get({
+ const savedDashboard = (await savedDashboards.get({
id: savedDashboardId,
useResolve: true,
})) as DashboardSavedObject;
+ const savedDashboardState = savedObjectToDashboardState({
+ savedDashboard,
+ usageCollection,
+ showWriteControls,
+ savedObjectsTagging,
+ version: initializerContext.env.packageInfo.version,
+ });
+
+ const isViewMode = !showWriteControls || Boolean(savedDashboard.id);
+ savedDashboardState.viewMode = isViewMode ? ViewMode.VIEW : ViewMode.EDIT;
+ savedDashboardState.filters = cleanFiltersForSerialize(savedDashboardState.filters);
+ savedDashboardState.query = migrateLegacyQuery(
+ savedDashboardState.query || queryString.getDefaultQuery()
+ );
+
+ return { savedDashboardState, savedDashboard };
} catch (error) {
// E.g. a corrupt or deleted dashboard
- notifications.toasts.addDanger(error.message);
+ notifications.toasts.addDanger(
+ dashboardLoadingErrorStrings.getDashboardLoadError(error.message)
+ );
history.push(DashboardConstants.LANDING_PAGE_PATH);
return;
}
- if (!savedDashboard) return;
-
- const savedDashboardState = savedObjectToDashboardState({
- savedDashboard,
- usageCollection,
- showWriteControls,
- savedObjectsTagging,
- version: initializerContext.env.packageInfo.version,
- });
-
- const isViewMode = !showWriteControls || Boolean(savedDashboard.id);
- savedDashboardState.viewMode = isViewMode ? ViewMode.VIEW : ViewMode.EDIT;
- savedDashboardState.filters = cleanFiltersForSerialize(savedDashboardState.filters);
- savedDashboardState.query = migrateLegacyQuery(
- savedDashboardState.query || queryString.getDefaultQuery()
- );
-
- return { savedDashboardState, savedDashboard };
};
diff --git a/src/plugins/dashboard/public/application/listing/confirm_overlays.tsx b/src/plugins/dashboard/public/application/listing/confirm_overlays.tsx
index e3f7b32ef8223..f2792790f2f5d 100644
--- a/src/plugins/dashboard/public/application/listing/confirm_overlays.tsx
+++ b/src/plugins/dashboard/public/application/listing/confirm_overlays.tsx
@@ -20,7 +20,7 @@ import {
} from '@elastic/eui';
import React from 'react';
-import { OverlayStart } from '../../../../../core/public';
+import { CoreStart, OverlayStart } from '../../../../../core/public';
import { toMountPoint } from '../../services/kibana_react';
import { createConfirmStrings, discardConfirmStrings } from '../../dashboard_strings';
@@ -43,6 +43,7 @@ export const confirmDiscardUnsavedChanges = (overlays: OverlayStart, discardCall
export const confirmCreateWithUnsaved = (
overlays: OverlayStart,
+ theme: CoreStart['theme'],
startBlankCallback: () => void,
contineCallback: () => void
) => {
@@ -105,7 +106,8 @@ export const confirmCreateWithUnsaved = (
-
+ ,
+ { theme$: theme.theme$ }
),
{
'data-test-subj': 'dashboardCreateConfirmModal',
diff --git a/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx b/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
index 605e5ec88565f..deb8671edb97d 100644
--- a/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
+++ b/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
@@ -119,6 +119,7 @@ export const DashboardListing = ({
} else {
confirmCreateWithUnsaved(
core.overlays,
+ core.theme,
() => {
dashboardSessionStorage.clearState();
redirectTo({ destination: 'dashboard' });
@@ -126,7 +127,7 @@ export const DashboardListing = ({
() => redirectTo({ destination: 'dashboard' })
);
}
- }, [dashboardSessionStorage, redirectTo, core.overlays]);
+ }, [dashboardSessionStorage, redirectTo, core.overlays, core.theme]);
const emptyPrompt = useMemo(() => {
if (!showWriteControls) {
diff --git a/src/plugins/dashboard/public/application/listing/dashboard_no_match.tsx b/src/plugins/dashboard/public/application/listing/dashboard_no_match.tsx
index 228a6994dcbb7..df7e9bc21e46d 100644
--- a/src/plugins/dashboard/public/application/listing/dashboard_no_match.tsx
+++ b/src/plugins/dashboard/public/application/listing/dashboard_no_match.tsx
@@ -45,7 +45,8 @@ export const DashboardNoMatch = ({ history }: { history: RouteComponentProps['hi
}}
/>
-
+ ,
+ { theme$: services.core.theme.theme$ }
)
);
diff --git a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
index 8e24e9ea595dc..bc5bb3aa4a566 100644
--- a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
+++ b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
@@ -110,7 +110,9 @@ export function DashboardTopNav({
} = useKibana().services;
const { version: kibanaVersion } = initializerContext.env.packageInfo;
const timefilter = data.query.timefilter.timefilter;
- const toasts = core.notifications.toasts;
+ const { notifications, theme } = core;
+ const { toasts } = notifications;
+ const { theme$ } = theme;
const dispatchDashboardStateChange = useDashboardDispatch();
const dashboardState = useDashboardSelector((state) => state.dashboardStateReducer);
@@ -367,7 +369,7 @@ export function DashboardTopNav({
});
return saveResult.id ? { id: saveResult.id } : { error: saveResult.error };
};
- showCloneModal(onClone, currentState.title);
+ showCloneModal({ onClone, title: currentState.title, theme$ });
}, [
dashboardSessionStorage,
savedObjectsTagging,
@@ -375,6 +377,7 @@ export function DashboardTopNav({
kibanaVersion,
redirectTo,
timefilter,
+ theme$,
toasts,
]);
@@ -395,9 +398,10 @@ export function DashboardTopNav({
onHidePanelTitlesChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setHidePanelTitles(isChecked));
},
+ theme$,
});
},
- [dashboardAppState, dispatchDashboardStateChange]
+ [dashboardAppState, dispatchDashboardStateChange, theme$]
);
const showShare = useCallback(
diff --git a/src/plugins/dashboard/public/application/top_nav/show_clone_modal.tsx b/src/plugins/dashboard/public/application/top_nav/show_clone_modal.tsx
index 66803d0d7741e..5c7ec042bf1d9 100644
--- a/src/plugins/dashboard/public/application/top_nav/show_clone_modal.tsx
+++ b/src/plugins/dashboard/public/application/top_nav/show_clone_modal.tsx
@@ -10,16 +10,21 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n-react';
+import { CoreStart } from 'src/core/public';
import { DashboardCloneModal } from './clone_modal';
+import { KibanaThemeProvider } from '../../services/kibana_react';
-export function showCloneModal(
+export interface ShowCloneModalProps {
onClone: (
newTitle: string,
isTitleDuplicateConfirmed: boolean,
onTitleDuplicate: () => void
- ) => Promise<{ id?: string } | { error: Error }>,
- title: string
-) {
+ ) => Promise<{ id?: string } | { error: Error }>;
+ title: string;
+ theme$: CoreStart['theme']['theme$'];
+}
+
+export function showCloneModal({ onClone, title, theme$ }: ShowCloneModalProps) {
const container = document.createElement('div');
const closeModal = () => {
ReactDOM.unmountComponentAtNode(container);
@@ -44,14 +49,16 @@ export function showCloneModal(
document.body.appendChild(container);
const element = (
-
+
+
+
);
ReactDOM.render(element, container);
diff --git a/src/plugins/dashboard/public/application/top_nav/show_options_popover.tsx b/src/plugins/dashboard/public/application/top_nav/show_options_popover.tsx
index c9e10f83ff7ef..c53103075dcfb 100644
--- a/src/plugins/dashboard/public/application/top_nav/show_options_popover.tsx
+++ b/src/plugins/dashboard/public/application/top_nav/show_options_popover.tsx
@@ -10,8 +10,9 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { I18nProvider } from '@kbn/i18n-react';
import { EuiWrappingPopover } from '@elastic/eui';
-
+import { CoreStart } from 'src/core/public';
import { OptionsMenu } from './options';
+import { KibanaThemeProvider } from '../../services/kibana_react';
let isOpen = false;
@@ -22,6 +23,17 @@ const onClose = () => {
isOpen = false;
};
+export interface ShowOptionsPopoverProps {
+ anchorElement: HTMLElement;
+ useMargins: boolean;
+ onUseMarginsChange: (useMargins: boolean) => void;
+ syncColors: boolean;
+ onSyncColorsChange: (syncColors: boolean) => void;
+ hidePanelTitles: boolean;
+ onHidePanelTitlesChange: (hideTitles: boolean) => void;
+ theme$: CoreStart['theme']['theme$'];
+}
+
export function showOptionsPopover({
anchorElement,
useMargins,
@@ -30,15 +42,8 @@ export function showOptionsPopover({
onHidePanelTitlesChange,
syncColors,
onSyncColorsChange,
-}: {
- anchorElement: HTMLElement;
- useMargins: boolean;
- onUseMarginsChange: (useMargins: boolean) => void;
- syncColors: boolean;
- onSyncColorsChange: (syncColors: boolean) => void;
- hidePanelTitles: boolean;
- onHidePanelTitlesChange: (hideTitles: boolean) => void;
-}) {
+ theme$,
+}: ShowOptionsPopoverProps) {
if (isOpen) {
onClose();
return;
@@ -49,16 +54,23 @@ export function showOptionsPopover({
document.body.appendChild(container);
const element = (
-
-
-
+
+
+
+
+
);
ReactDOM.render(element, container);
diff --git a/src/plugins/dashboard/public/dashboard_strings.ts b/src/plugins/dashboard/public/dashboard_strings.ts
index ca0f51976f3fb..52961c43cc1a2 100644
--- a/src/plugins/dashboard/public/dashboard_strings.ts
+++ b/src/plugins/dashboard/public/dashboard_strings.ts
@@ -359,6 +359,14 @@ export const panelStorageErrorStrings = {
}),
};
+export const dashboardLoadingErrorStrings = {
+ getDashboardLoadError: (message: string) =>
+ i18n.translate('dashboard.loadingError.errorMessage', {
+ defaultMessage: 'Error encountered while loading saved dashboard: {message}',
+ values: { message },
+ }),
+};
+
/*
Empty Screen
*/
diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx
index 9912aef943144..7f784d43c0cb7 100644
--- a/src/plugins/dashboard/public/plugin.tsx
+++ b/src/plugins/dashboard/public/plugin.tsx
@@ -193,6 +193,11 @@ export class DashboardPlugin
);
}
+ const getPlaceholderEmbeddableStartServices = async () => {
+ const [coreStart] = await core.getStartServices();
+ return { theme: coreStart.theme };
+ };
+
const getStartServices = async () => {
const [coreStart, deps] = await core.getStartServices();
@@ -203,13 +208,14 @@ export class DashboardPlugin
SavedObjectFinder: getSavedObjectFinder(coreStart.savedObjects, coreStart.uiSettings),
showWriteControls: Boolean(coreStart.application.capabilities.dashboard.showWriteControls),
notifications: coreStart.notifications,
+ screenshotMode: deps.screenshotMode,
application: coreStart.application,
uiSettings: coreStart.uiSettings,
overlays: coreStart.overlays,
embeddable: deps.embeddable,
uiActions: deps.uiActions,
inspector: deps.inspector,
- screenshotMode: deps.screenshotMode,
+ theme: coreStart.theme,
http: coreStart.http,
ExitFullScreenButton,
presentationUtil: deps.presentationUtil,
@@ -279,10 +285,12 @@ export class DashboardPlugin
dashboardContainerFactory.type,
dashboardContainerFactory
);
- });
- const placeholderFactory = new PlaceholderEmbeddableFactory();
- embeddable.registerEmbeddableFactory(placeholderFactory.type, placeholderFactory);
+ const placeholderFactory = new PlaceholderEmbeddableFactory(
+ getPlaceholderEmbeddableStartServices
+ );
+ embeddable.registerEmbeddableFactory(placeholderFactory.type, placeholderFactory);
+ });
this.stopUrlTracking = () => {
stopUrlTracker();
@@ -364,7 +372,7 @@ export class DashboardPlugin
}
public start(core: CoreStart, plugins: DashboardStartDependencies): DashboardStart {
- const { notifications, overlays, application } = core;
+ const { notifications, overlays, application, theme } = core;
const { uiActions, data, share, presentationUtil, embeddable } = plugins;
const dashboardCapabilities: Readonly = application.capabilities
@@ -406,11 +414,15 @@ export class DashboardPlugin
uiActions.registerAction(unlinkFromLibraryAction);
uiActions.attachAction(CONTEXT_MENU_TRIGGER, unlinkFromLibraryAction.id);
- const libraryNotificationAction = new LibraryNotificationAction(unlinkFromLibraryAction);
+ const libraryNotificationAction = new LibraryNotificationAction(
+ theme,
+ unlinkFromLibraryAction
+ );
uiActions.registerAction(libraryNotificationAction);
uiActions.attachAction(PANEL_NOTIFICATION_TRIGGER, libraryNotificationAction.id);
const copyToDashboardAction = new CopyToDashboardAction(
+ theme,
overlays,
embeddable.getStateTransfer(),
{
diff --git a/src/plugins/dashboard/public/services/kibana_react.ts b/src/plugins/dashboard/public/services/kibana_react.ts
index 4d5a3a5b57657..8cab64065824d 100644
--- a/src/plugins/dashboard/public/services/kibana_react.ts
+++ b/src/plugins/dashboard/public/services/kibana_react.ts
@@ -20,4 +20,5 @@ export {
reactToUiComponent,
ExitFullScreenButton,
KibanaContextProvider,
+ KibanaThemeProvider,
} from '../../../kibana_react/public';
diff --git a/src/plugins/data/common/search/aggs/agg_types.ts b/src/plugins/data/common/search/aggs/agg_types.ts
index dd930887f9d19..a84fddb19c5fa 100644
--- a/src/plugins/data/common/search/aggs/agg_types.ts
+++ b/src/plugins/data/common/search/aggs/agg_types.ts
@@ -62,6 +62,8 @@ export const getAggTypes = () => ({
{ name: BUCKET_TYPES.SIGNIFICANT_TERMS, fn: buckets.getSignificantTermsBucketAgg },
{ name: BUCKET_TYPES.GEOHASH_GRID, fn: buckets.getGeoHashBucketAgg },
{ name: BUCKET_TYPES.GEOTILE_GRID, fn: buckets.getGeoTitleBucketAgg },
+ { name: BUCKET_TYPES.SAMPLER, fn: buckets.getSamplerBucketAgg },
+ { name: BUCKET_TYPES.DIVERSIFIED_SAMPLER, fn: buckets.getDiversifiedSamplerBucketAgg },
],
});
@@ -79,6 +81,8 @@ export const getAggTypesFunctions = () => [
buckets.aggDateHistogram,
buckets.aggTerms,
buckets.aggMultiTerms,
+ buckets.aggSampler,
+ buckets.aggDiversifiedSampler,
metrics.aggAvg,
metrics.aggBucketAvg,
metrics.aggBucketMax,
diff --git a/src/plugins/data/common/search/aggs/aggs_service.test.ts b/src/plugins/data/common/search/aggs/aggs_service.test.ts
index be3fbae26174a..571083c18156f 100644
--- a/src/plugins/data/common/search/aggs/aggs_service.test.ts
+++ b/src/plugins/data/common/search/aggs/aggs_service.test.ts
@@ -73,6 +73,8 @@ describe('Aggs service', () => {
"significant_terms",
"geohash_grid",
"geotile_grid",
+ "sampler",
+ "diversified_sampler",
"foo",
]
`);
@@ -122,6 +124,8 @@ describe('Aggs service', () => {
"significant_terms",
"geohash_grid",
"geotile_grid",
+ "sampler",
+ "diversified_sampler",
]
`);
expect(bStart.types.getAll().metrics.map((t) => t(aggTypesDependencies).name))
diff --git a/src/plugins/data/common/search/aggs/buckets/bucket_agg_types.ts b/src/plugins/data/common/search/aggs/buckets/bucket_agg_types.ts
index 0c01bff90bfee..671266ef15997 100644
--- a/src/plugins/data/common/search/aggs/buckets/bucket_agg_types.ts
+++ b/src/plugins/data/common/search/aggs/buckets/bucket_agg_types.ts
@@ -19,4 +19,6 @@ export enum BUCKET_TYPES {
GEOHASH_GRID = 'geohash_grid',
GEOTILE_GRID = 'geotile_grid',
DATE_HISTOGRAM = 'date_histogram',
+ SAMPLER = 'sampler',
+ DIVERSIFIED_SAMPLER = 'diversified_sampler',
}
diff --git a/src/plugins/data/common/search/aggs/buckets/diversified_sampler.ts b/src/plugins/data/common/search/aggs/buckets/diversified_sampler.ts
new file mode 100644
index 0000000000000..31ebaa094c368
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/diversified_sampler.ts
@@ -0,0 +1,62 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { BucketAggType } from './bucket_agg_type';
+import { BaseAggParams } from '../types';
+import { aggDiversifiedSamplerFnName } from './diversified_sampler_fn';
+
+export const DIVERSIFIED_SAMPLER_AGG_NAME = 'diversified_sampler';
+
+const title = i18n.translate('data.search.aggs.buckets.diversifiedSamplerTitle', {
+ defaultMessage: 'Diversified sampler',
+ description: 'Diversified sampler aggregation title',
+});
+
+export interface AggParamsDiversifiedSampler extends BaseAggParams {
+ /**
+ * Is used to provide values used for de-duplication
+ */
+ field: string;
+
+ /**
+ * Limits how many top-scoring documents are collected in the sample processed on each shard.
+ */
+ shard_size?: number;
+
+ /**
+ * Limits how many documents are permitted per choice of de-duplicating value
+ */
+ max_docs_per_value?: number;
+}
+
+/**
+ * Like the sampler aggregation this is a filtering aggregation used to limit any sub aggregations' processing to a sample of the top-scoring documents.
+ * The diversified_sampler aggregation adds the ability to limit the number of matches that share a common value.
+ */
+export const getDiversifiedSamplerBucketAgg = () =>
+ new BucketAggType({
+ name: DIVERSIFIED_SAMPLER_AGG_NAME,
+ title,
+ customLabels: false,
+ expressionName: aggDiversifiedSamplerFnName,
+ params: [
+ {
+ name: 'shard_size',
+ type: 'number',
+ },
+ {
+ name: 'max_docs_per_value',
+ type: 'number',
+ },
+ {
+ name: 'field',
+ type: 'field',
+ },
+ ],
+ });
diff --git a/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.test.ts b/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.test.ts
new file mode 100644
index 0000000000000..e874542289bb2
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.test.ts
@@ -0,0 +1,58 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { functionWrapper } from '../test_helpers';
+import { aggDiversifiedSampler } from './diversified_sampler_fn';
+
+describe('aggDiversifiedSampler', () => {
+ const fn = functionWrapper(aggDiversifiedSampler());
+
+ test('fills in defaults when only required args are provided', () => {
+ const actual = fn({ id: 'sampler', schema: 'bucket', field: 'author' });
+ expect(actual).toMatchInlineSnapshot(`
+ Object {
+ "type": "agg_type",
+ "value": Object {
+ "enabled": true,
+ "id": "sampler",
+ "params": Object {
+ "field": "author",
+ "max_docs_per_value": undefined,
+ "shard_size": undefined,
+ },
+ "schema": "bucket",
+ "type": "diversified_sampler",
+ },
+ }
+ `);
+ });
+
+ test('includes optional params when they are provided', () => {
+ const actual = fn({
+ id: 'sampler',
+ schema: 'bucket',
+ shard_size: 300,
+ field: 'author',
+ max_docs_per_value: 3,
+ });
+
+ expect(actual.value).toMatchInlineSnapshot(`
+ Object {
+ "enabled": true,
+ "id": "sampler",
+ "params": Object {
+ "field": "author",
+ "max_docs_per_value": 3,
+ "shard_size": 300,
+ },
+ "schema": "bucket",
+ "type": "diversified_sampler",
+ }
+ `);
+ });
+});
diff --git a/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.ts b/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.ts
new file mode 100644
index 0000000000000..0e1b235dd576d
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/diversified_sampler_fn.ts
@@ -0,0 +1,90 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
+import { AggExpressionFunctionArgs, AggExpressionType, BUCKET_TYPES } from '../';
+import { DIVERSIFIED_SAMPLER_AGG_NAME } from './diversified_sampler';
+
+export const aggDiversifiedSamplerFnName = 'aggDiversifiedSampler';
+
+type Input = any;
+type Arguments = AggExpressionFunctionArgs;
+
+type Output = AggExpressionType;
+type FunctionDefinition = ExpressionFunctionDefinition<
+ typeof aggDiversifiedSamplerFnName,
+ Input,
+ Arguments,
+ Output
+>;
+
+export const aggDiversifiedSampler = (): FunctionDefinition => ({
+ name: aggDiversifiedSamplerFnName,
+ help: i18n.translate('data.search.aggs.function.buckets.diversifiedSampler.help', {
+ defaultMessage: 'Generates a serialized agg config for a Diversified sampler agg',
+ }),
+ type: 'agg_type',
+ args: {
+ id: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.id.help', {
+ defaultMessage: 'ID for this aggregation',
+ }),
+ },
+ enabled: {
+ types: ['boolean'],
+ default: true,
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.enabled.help', {
+ defaultMessage: 'Specifies whether this aggregation should be enabled',
+ }),
+ },
+ schema: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.schema.help', {
+ defaultMessage: 'Schema to use for this aggregation',
+ }),
+ },
+ shard_size: {
+ types: ['number'],
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.shardSize.help', {
+ defaultMessage:
+ 'The shard_size parameter limits how many top-scoring documents are collected in the sample processed on each shard.',
+ }),
+ },
+ max_docs_per_value: {
+ types: ['number'],
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.maxDocsPerValue.help', {
+ defaultMessage:
+ 'Limits how many documents are permitted per choice of de-duplicating value.',
+ }),
+ },
+ field: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.diversifiedSampler.field.help', {
+ defaultMessage: 'Used to provide values used for de-duplication.',
+ }),
+ },
+ },
+ fn: (input, args) => {
+ const { id, enabled, schema, ...rest } = args;
+
+ return {
+ type: 'agg_type',
+ value: {
+ id,
+ enabled,
+ schema,
+ type: DIVERSIFIED_SAMPLER_AGG_NAME,
+ params: {
+ ...rest,
+ },
+ },
+ };
+ },
+});
diff --git a/src/plugins/data/common/search/aggs/buckets/index.ts b/src/plugins/data/common/search/aggs/buckets/index.ts
index 421fa0fcfdaf4..bf96a9ef860c0 100644
--- a/src/plugins/data/common/search/aggs/buckets/index.ts
+++ b/src/plugins/data/common/search/aggs/buckets/index.ts
@@ -38,3 +38,7 @@ export * from './terms_fn';
export * from './terms';
export * from './multi_terms_fn';
export * from './multi_terms';
+export * from './sampler_fn';
+export * from './sampler';
+export * from './diversified_sampler_fn';
+export * from './diversified_sampler';
diff --git a/src/plugins/data/common/search/aggs/buckets/multi_terms.ts b/src/plugins/data/common/search/aggs/buckets/multi_terms.ts
index c320c7e242798..02bf6bd12d319 100644
--- a/src/plugins/data/common/search/aggs/buckets/multi_terms.ts
+++ b/src/plugins/data/common/search/aggs/buckets/multi_terms.ts
@@ -34,6 +34,7 @@ export interface AggParamsMultiTerms extends BaseAggParams {
size?: number;
otherBucket?: boolean;
otherBucketLabel?: string;
+ separatorLabel?: string;
}
export const getMultiTermsBucketAgg = () => {
@@ -83,6 +84,7 @@ export const getMultiTermsBucketAgg = () => {
params: {
otherBucketLabel: params.otherBucketLabel,
paramsPerField: formats,
+ separator: agg.params.separatorLabel,
},
};
},
@@ -142,6 +144,11 @@ export const getMultiTermsBucketAgg = () => {
shouldShow: (agg) => agg.getParam('otherBucket'),
write: noop,
},
+ {
+ name: 'separatorLabel',
+ type: 'string',
+ write: noop,
+ },
],
});
};
diff --git a/src/plugins/data/common/search/aggs/buckets/multi_terms_fn.ts b/src/plugins/data/common/search/aggs/buckets/multi_terms_fn.ts
index 58e49479cd2c1..12b9c6d156548 100644
--- a/src/plugins/data/common/search/aggs/buckets/multi_terms_fn.ts
+++ b/src/plugins/data/common/search/aggs/buckets/multi_terms_fn.ts
@@ -111,6 +111,12 @@ export const aggMultiTerms = (): FunctionDefinition => ({
defaultMessage: 'Represents a custom label for this aggregation',
}),
},
+ separatorLabel: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.multiTerms.separatorLabel.help', {
+ defaultMessage: 'The separator label used to join each term combination',
+ }),
+ },
},
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;
diff --git a/src/plugins/data/common/search/aggs/buckets/sampler.ts b/src/plugins/data/common/search/aggs/buckets/sampler.ts
new file mode 100644
index 0000000000000..7eb4f74115095
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/sampler.ts
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { BucketAggType } from './bucket_agg_type';
+import { BaseAggParams } from '../types';
+import { aggSamplerFnName } from './sampler_fn';
+
+export const SAMPLER_AGG_NAME = 'sampler';
+
+const title = i18n.translate('data.search.aggs.buckets.samplerTitle', {
+ defaultMessage: 'Sampler',
+ description: 'Sampler aggregation title',
+});
+
+export interface AggParamsSampler extends BaseAggParams {
+ /**
+ * Limits how many top-scoring documents are collected in the sample processed on each shard.
+ */
+ shard_size?: number;
+}
+
+/**
+ * A filtering aggregation used to limit any sub aggregations' processing to a sample of the top-scoring documents.
+ */
+export const getSamplerBucketAgg = () =>
+ new BucketAggType({
+ name: SAMPLER_AGG_NAME,
+ title,
+ customLabels: false,
+ expressionName: aggSamplerFnName,
+ params: [
+ {
+ name: 'shard_size',
+ type: 'number',
+ },
+ ],
+ });
diff --git a/src/plugins/data/common/search/aggs/buckets/sampler_fn.test.ts b/src/plugins/data/common/search/aggs/buckets/sampler_fn.test.ts
new file mode 100644
index 0000000000000..76ef901671e72
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/sampler_fn.test.ts
@@ -0,0 +1,52 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { functionWrapper } from '../test_helpers';
+import { aggSampler } from './sampler_fn';
+
+describe('aggSampler', () => {
+ const fn = functionWrapper(aggSampler());
+
+ test('fills in defaults when only required args are provided', () => {
+ const actual = fn({ id: 'sampler', schema: 'bucket' });
+ expect(actual).toMatchInlineSnapshot(`
+ Object {
+ "type": "agg_type",
+ "value": Object {
+ "enabled": true,
+ "id": "sampler",
+ "params": Object {
+ "shard_size": undefined,
+ },
+ "schema": "bucket",
+ "type": "sampler",
+ },
+ }
+ `);
+ });
+
+ test('includes optional params when they are provided', () => {
+ const actual = fn({
+ id: 'sampler',
+ schema: 'bucket',
+ shard_size: 300,
+ });
+
+ expect(actual.value).toMatchInlineSnapshot(`
+ Object {
+ "enabled": true,
+ "id": "sampler",
+ "params": Object {
+ "shard_size": 300,
+ },
+ "schema": "bucket",
+ "type": "sampler",
+ }
+ `);
+ });
+});
diff --git a/src/plugins/data/common/search/aggs/buckets/sampler_fn.ts b/src/plugins/data/common/search/aggs/buckets/sampler_fn.ts
new file mode 100644
index 0000000000000..2cb30eb70a230
--- /dev/null
+++ b/src/plugins/data/common/search/aggs/buckets/sampler_fn.ts
@@ -0,0 +1,77 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
+import { AggExpressionFunctionArgs, AggExpressionType, BUCKET_TYPES } from '../';
+import { SAMPLER_AGG_NAME } from './sampler';
+
+export const aggSamplerFnName = 'aggSampler';
+
+type Input = any;
+type Arguments = AggExpressionFunctionArgs;
+
+type Output = AggExpressionType;
+type FunctionDefinition = ExpressionFunctionDefinition<
+ typeof aggSamplerFnName,
+ Input,
+ Arguments,
+ Output
+>;
+
+export const aggSampler = (): FunctionDefinition => ({
+ name: aggSamplerFnName,
+ help: i18n.translate('data.search.aggs.function.buckets.sampler.help', {
+ defaultMessage: 'Generates a serialized agg config for a Sampler agg',
+ }),
+ type: 'agg_type',
+ args: {
+ id: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.sampler.id.help', {
+ defaultMessage: 'ID for this aggregation',
+ }),
+ },
+ enabled: {
+ types: ['boolean'],
+ default: true,
+ help: i18n.translate('data.search.aggs.buckets.sampler.enabled.help', {
+ defaultMessage: 'Specifies whether this aggregation should be enabled',
+ }),
+ },
+ schema: {
+ types: ['string'],
+ help: i18n.translate('data.search.aggs.buckets.sampler.schema.help', {
+ defaultMessage: 'Schema to use for this aggregation',
+ }),
+ },
+ shard_size: {
+ types: ['number'],
+ help: i18n.translate('data.search.aggs.buckets.sampler.shardSize.help', {
+ defaultMessage:
+ 'The shard_size parameter limits how many top-scoring documents are collected in the sample processed on each shard.',
+ }),
+ },
+ },
+ fn: (input, args) => {
+ const { id, enabled, schema, ...rest } = args;
+
+ return {
+ type: 'agg_type',
+ value: {
+ id,
+ enabled,
+ schema,
+ type: SAMPLER_AGG_NAME,
+ params: {
+ ...rest,
+ },
+ },
+ };
+ },
+});
diff --git a/src/plugins/data/common/search/aggs/types.ts b/src/plugins/data/common/search/aggs/types.ts
index b9a977e0a8a09..9c4866c19714d 100644
--- a/src/plugins/data/common/search/aggs/types.ts
+++ b/src/plugins/data/common/search/aggs/types.ts
@@ -90,6 +90,8 @@ import {
aggFilteredMetric,
aggSinglePercentile,
} from './';
+import { AggParamsSampler } from './buckets/sampler';
+import { AggParamsDiversifiedSampler } from './buckets/diversified_sampler';
export type { IAggConfig, AggConfigSerialized } from './agg_config';
export type { CreateAggConfigParams, IAggConfigs } from './agg_configs';
@@ -166,6 +168,8 @@ export interface AggParamsMapping {
[BUCKET_TYPES.DATE_HISTOGRAM]: AggParamsDateHistogram;
[BUCKET_TYPES.TERMS]: AggParamsTerms;
[BUCKET_TYPES.MULTI_TERMS]: AggParamsMultiTerms;
+ [BUCKET_TYPES.SAMPLER]: AggParamsSampler;
+ [BUCKET_TYPES.DIVERSIFIED_SAMPLER]: AggParamsDiversifiedSampler;
[METRIC_TYPES.AVG]: AggParamsAvg;
[METRIC_TYPES.CARDINALITY]: AggParamsCardinality;
[METRIC_TYPES.COUNT]: BaseAggParams;
diff --git a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
index 76112980c55fb..8510acf1572c7 100644
--- a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
+++ b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.test.ts
@@ -13,6 +13,7 @@ import {
IFieldFormat,
SerializedFieldFormat,
} from '../../../../../field_formats/common';
+import { MultiFieldKey } from '../buckets/multi_field_key';
import { getAggsFormats } from './get_aggs_formats';
const getAggFormat = (
@@ -119,4 +120,35 @@ describe('getAggsFormats', () => {
expect(format.convert('__missing__')).toBe(mapping.params.missingBucketLabel);
expect(getFormat).toHaveBeenCalledTimes(3);
});
+
+ test('uses a default separator for multi terms', () => {
+ const terms = ['source', 'geo.src', 'geo.dest'];
+ const mapping = {
+ id: 'multi_terms',
+ params: {
+ paramsPerField: Array(terms.length).fill({ id: 'terms' }),
+ },
+ };
+
+ const format = getAggFormat(mapping, getFormat);
+
+ expect(format.convert(new MultiFieldKey({ key: terms }))).toBe('source › geo.src › geo.dest');
+ expect(getFormat).toHaveBeenCalledTimes(terms.length);
+ });
+
+ test('uses a custom separator for multi terms when passed', () => {
+ const terms = ['source', 'geo.src', 'geo.dest'];
+ const mapping = {
+ id: 'multi_terms',
+ params: {
+ paramsPerField: Array(terms.length).fill({ id: 'terms' }),
+ separator: ' - ',
+ },
+ };
+
+ const format = getAggFormat(mapping, getFormat);
+
+ expect(format.convert(new MultiFieldKey({ key: terms }))).toBe('source - geo.src - geo.dest');
+ expect(getFormat).toHaveBeenCalledTimes(terms.length);
+ });
});
diff --git a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
index aade8bc70e4ee..f14f981fdec65 100644
--- a/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
+++ b/src/plugins/data/common/search/aggs/utils/get_aggs_formats.ts
@@ -143,9 +143,11 @@ export function getAggsFormats(getFieldFormat: GetFieldFormat): FieldFormatInsta
return params.otherBucketLabel;
}
+ const joinTemplate = params.separator ?? ' › ';
+
return (val as MultiFieldKey).keys
.map((valPart, i) => formats[i].convert(valPart, type))
- .join(' › ');
+ .join(joinTemplate);
};
getConverterFor = (type: FieldFormatsContentType) => (val: string) => this.convert(val, type);
},
diff --git a/src/plugins/data/public/search/aggs/aggs_service.test.ts b/src/plugins/data/public/search/aggs/aggs_service.test.ts
index 20e07360a68e5..c7df4354cc76b 100644
--- a/src/plugins/data/public/search/aggs/aggs_service.test.ts
+++ b/src/plugins/data/public/search/aggs/aggs_service.test.ts
@@ -53,7 +53,7 @@ describe('AggsService - public', () => {
test('registers default agg types', () => {
service.setup(setupDeps);
const start = service.start(startDeps);
- expect(start.types.getAll().buckets.length).toBe(12);
+ expect(start.types.getAll().buckets.length).toBe(14);
expect(start.types.getAll().metrics.length).toBe(23);
});
@@ -69,7 +69,7 @@ describe('AggsService - public', () => {
);
const start = service.start(startDeps);
- expect(start.types.getAll().buckets.length).toBe(13);
+ expect(start.types.getAll().buckets.length).toBe(15);
expect(start.types.getAll().buckets.some(({ name }) => name === 'foo')).toBe(true);
expect(start.types.getAll().metrics.length).toBe(24);
expect(start.types.getAll().metrics.some(({ name }) => name === 'bar')).toBe(true);
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index fef82c710bca1..ccf9615bc3965 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -90,7 +90,7 @@ export class DataServerPlugin
{ bfetch, expressions, usageCollection, fieldFormats }: DataPluginSetupDependencies
) {
this.scriptsService.setup(core);
- this.queryService.setup(core);
+ const querySetup = this.queryService.setup(core);
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });
@@ -107,6 +107,7 @@ export class DataServerPlugin
searchSetup.__enhance(enhancements.search);
},
search: searchSetup,
+ query: querySetup,
fieldFormats,
};
}
diff --git a/src/plugins/data_view_field_editor/public/components/field_editor/form_fields/script_field.tsx b/src/plugins/data_view_field_editor/public/components/field_editor/form_fields/script_field.tsx
index 602db0cd55274..c5eaeb02c05cf 100644
--- a/src/plugins/data_view_field_editor/public/components/field_editor/form_fields/script_field.tsx
+++ b/src/plugins/data_view_field_editor/public/components/field_editor/form_fields/script_field.tsx
@@ -218,6 +218,7 @@ const ScriptFieldComponent = ({ existingConcreteFields, links }: Props) => {
<>
{
indexPatterns = new IndexPatternsFetcher(esClient);
});
it('Removes pattern without matching indices', async () => {
+ // first field caps request returns empty
const result = await indexPatterns.validatePatternListActive(patternList);
expect(result).toEqual(['b', 'c']);
});
+ it('Keeps matching and negating patterns', async () => {
+ // first field caps request returns empty
+ const result = await indexPatterns.validatePatternListActive(['-a', 'b', 'c']);
+ expect(result).toEqual(['-a', 'c']);
+ });
it('Returns all patterns when all match indices', async () => {
esClient = {
fieldCaps: jest.fn().mockResolvedValue(response),
diff --git a/src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts b/src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
index c054d547e956f..bceefac22e0f0 100644
--- a/src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
+++ b/src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
@@ -133,6 +133,10 @@ export class IndexPatternsFetcher {
const result = await Promise.all(
patternList
.map(async (index) => {
+ // perserve negated patterns
+ if (index.startsWith('-')) {
+ return true;
+ }
const searchResponse = await this.elasticsearchClient.fieldCaps({
index,
fields: '_id',
diff --git a/src/plugins/dev_tools/kibana.json b/src/plugins/dev_tools/kibana.json
index 75a1e82f1d910..9b2ae8a3f995f 100644
--- a/src/plugins/dev_tools/kibana.json
+++ b/src/plugins/dev_tools/kibana.json
@@ -7,5 +7,6 @@
"name": "Stack Management",
"githubTeam": "kibana-stack-management"
},
- "requiredPlugins": ["urlForwarding"]
+ "requiredPlugins": ["urlForwarding"],
+ "requiredBundles": ["kibanaReact"]
}
diff --git a/src/plugins/dev_tools/public/application.tsx b/src/plugins/dev_tools/public/application.tsx
index a4fdaf28e0eb4..dc72cfda790d4 100644
--- a/src/plugins/dev_tools/public/application.tsx
+++ b/src/plugins/dev_tools/public/application.tsx
@@ -16,6 +16,7 @@ import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
import { ApplicationStart, ChromeStart, ScopedHistory, CoreTheme } from 'src/core/public';
+import { KibanaThemeProvider } from '../../kibana_react/public';
import type { DocTitleService, BreadcrumbService } from './services';
import { DevToolApp } from './dev_tool';
@@ -177,32 +178,34 @@ export function renderApp(
ReactDOM.render(
-
-
- {devTools
- // Only create routes for devtools that are not disabled
- .filter((devTool) => !devTool.isDisabled())
- .map((devTool) => (
- (
-
- )}
- />
- ))}
-
-
-
-
-
+
+
+
+ {devTools
+ // Only create routes for devtools that are not disabled
+ .filter((devTool) => !devTool.isDisabled())
+ .map((devTool) => (
+ (
+
+ )}
+ />
+ ))}
+
+
+
+
+
+
,
element
);
diff --git a/src/plugins/discover/public/__mocks__/services.ts b/src/plugins/discover/public/__mocks__/services.ts
index 6a90ed42417e6..ec7657827d95b 100644
--- a/src/plugins/discover/public/__mocks__/services.ts
+++ b/src/plugins/discover/public/__mocks__/services.ts
@@ -97,4 +97,5 @@ export const discoverServiceMock = {
storage: {
get: jest.fn(),
},
+ addBasePath: jest.fn(),
} as unknown as DiscoverServices;
diff --git a/src/plugins/discover/public/application/context/context_app_route.tsx b/src/plugins/discover/public/application/context/context_app_route.tsx
index dfc318021b93e..80feea833ec94 100644
--- a/src/plugins/discover/public/application/context/context_app_route.tsx
+++ b/src/plugins/discover/public/application/context/context_app_route.tsx
@@ -15,6 +15,7 @@ import { ContextApp } from './context_app';
import { getRootBreadcrumbs } from '../../utils/breadcrumbs';
import { LoadingIndicator } from '../../components/common/loading_indicator';
import { useIndexPattern } from '../../utils/use_index_pattern';
+import { useMainRouteBreadcrumb } from '../../utils/use_navigation_props';
export interface ContextAppProps {
/**
@@ -33,17 +34,18 @@ export function ContextAppRoute(props: ContextAppProps) {
const { chrome } = services;
const { indexPatternId, id } = useParams();
+ const breadcrumb = useMainRouteBreadcrumb();
useEffect(() => {
chrome.setBreadcrumbs([
- ...getRootBreadcrumbs(),
+ ...getRootBreadcrumbs(breadcrumb),
{
text: i18n.translate('discover.context.breadcrumb', {
defaultMessage: 'Surrounding documents',
}),
},
]);
- }, [chrome]);
+ }, [chrome, breadcrumb]);
const { indexPattern, error } = useIndexPattern(services.indexPatterns, indexPatternId);
diff --git a/src/plugins/discover/public/application/doc/single_doc_route.tsx b/src/plugins/discover/public/application/doc/single_doc_route.tsx
index e5ddb784b9080..0a5cc3a8a82b6 100644
--- a/src/plugins/discover/public/application/doc/single_doc_route.tsx
+++ b/src/plugins/discover/public/application/doc/single_doc_route.tsx
@@ -14,6 +14,7 @@ import { getRootBreadcrumbs } from '../../utils/breadcrumbs';
import { Doc } from './components/doc';
import { LoadingIndicator } from '../../components/common/loading_indicator';
import { useIndexPattern } from '../../utils/use_index_pattern';
+import { useMainRouteBreadcrumb } from '../../utils/use_navigation_props';
export interface SingleDocRouteProps {
/**
@@ -36,18 +37,19 @@ export function SingleDocRoute(props: SingleDocRouteProps) {
const { chrome, timefilter } = services;
const { indexPatternId, index } = useParams();
+ const breadcrumb = useMainRouteBreadcrumb();
const query = useQuery();
const docId = query.get('id') || '';
useEffect(() => {
chrome.setBreadcrumbs([
- ...getRootBreadcrumbs(),
+ ...getRootBreadcrumbs(breadcrumb),
{
text: `${index}#${docId}`,
},
]);
- }, [chrome, index, docId]);
+ }, [chrome, index, docId, breadcrumb]);
useEffect(() => {
timefilter.disableAutoRefreshSelector();
diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
index 30e0cf24f7d52..27f4268224904 100644
--- a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
@@ -27,8 +27,7 @@ import {
import { DocViewer } from '../../services/doc_views/components/doc_viewer/doc_viewer';
import { DocViewFilterFn } from '../../services/doc_views/doc_views_types';
import { DiscoverServices } from '../../build_services';
-import { getContextUrl } from '../../utils/get_context_url';
-import { getSingleDocUrl } from '../../utils/get_single_doc_url';
+import { useNavigationProps } from '../../utils/use_navigation_props';
import { ElasticSearchHit } from '../../types';
interface Props {
@@ -103,6 +102,15 @@ export function DiscoverGridFlyout({
[activePage, setPage]
);
+ const { singleDocProps, surrDocsProps } = useNavigationProps({
+ indexPatternId: indexPattern.id!,
+ rowIndex: hit._index,
+ rowId: hit._id,
+ filterManager: services.filterManager,
+ addBasePath: services.addBasePath,
+ columns,
+ });
+
return (
{i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', {
defaultMessage: 'Single document',
@@ -157,13 +165,7 @@ export function DiscoverGridFlyout({
size="xs"
iconType="documents"
flush="left"
- href={getContextUrl(
- String(hit._id),
- indexPattern.id,
- columns,
- services.filterManager,
- services.addBasePath
- )}
+ {...surrDocsProps}
data-test-subj="docTableRowAction"
>
{i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', {
diff --git a/src/plugins/discover/public/components/doc_table/components/table_row.tsx b/src/plugins/discover/public/components/doc_table/components/table_row.tsx
index 2eee9a177e4f8..2d9e8fa6e9584 100644
--- a/src/plugins/discover/public/components/doc_table/components/table_row.tsx
+++ b/src/plugins/discover/public/components/doc_table/components/table_row.tsx
@@ -15,12 +15,11 @@ import { flattenHit } from '../../../../../data/common';
import { DocViewer } from '../../../services/doc_views/components/doc_viewer/doc_viewer';
import { FilterManager, IndexPattern } from '../../../../../data/public';
import { TableCell } from './table_row/table_cell';
-import { DocViewFilterFn } from '../../../services/doc_views/doc_views_types';
-import { getContextUrl } from '../../../utils/get_context_url';
-import { getSingleDocUrl } from '../../../utils/get_single_doc_url';
-import { TableRowDetails } from './table_row_details';
import { formatRow, formatTopLevelObject } from '../lib/row_formatter';
+import { useNavigationProps } from '../../../utils/use_navigation_props';
+import { DocViewFilterFn } from '../../../services/doc_views/doc_views_types';
import { ElasticSearchHit } from '../../../types';
+import { TableRowDetails } from './table_row_details';
export type DocTableRow = ElasticSearchHit & {
isAnchor?: boolean;
@@ -100,13 +99,14 @@ export const TableRow = ({
[filter, flattenedRow, indexPattern.fields]
);
- const getContextAppHref = () => {
- return getContextUrl(row._id, indexPattern.id!, columns, filterManager, addBasePath);
- };
-
- const getSingleDocHref = () => {
- return addBasePath(getSingleDocUrl(indexPattern.id!, row._index, row._id));
- };
+ const { singleDocProps, surrDocsProps } = useNavigationProps({
+ indexPatternId: indexPattern.id!,
+ rowIndex: row._index,
+ rowId: row._id,
+ filterManager,
+ addBasePath,
+ columns,
+ });
const rowCells = [
@@ -208,8 +208,8 @@ export const TableRow = ({
open={open}
colLength={(columns.length || 1) + 2}
isTimeBased={indexPattern.isTimeBased()}
- getContextAppHref={getContextAppHref}
- getSingleDocHref={getSingleDocHref}
+ singleDocProps={singleDocProps}
+ surrDocsProps={surrDocsProps}
>
string;
- getSingleDocHref: () => string;
+ singleDocProps: DiscoverNavigationProps;
+ surrDocsProps: DiscoverNavigationProps;
children: JSX.Element;
}
@@ -22,8 +23,8 @@ export const TableRowDetails = ({
open,
colLength,
isTimeBased,
- getContextAppHref,
- getSingleDocHref,
+ singleDocProps,
+ surrDocsProps,
children,
}: TableRowDetailsProps) => {
if (!open) {
@@ -54,7 +55,7 @@ export const TableRowDetails = ({
{isTimeBased && (
-
+
-
+
[],
- getAppFilters: () => [],
-} as unknown as FilterManager;
-const addBasePath = (path: string) => `/base${path}`;
-
-describe('Get context url', () => {
- test('returning a valid context url', async () => {
- const url = await getContextUrl(
- 'docId',
- 'ipId',
- ['test1', 'test2'],
- filterManager,
- addBasePath
- );
- expect(url).toMatchInlineSnapshot(
- `"/base/app/discover#/context/ipId/docId?_g=(filters:!())&_a=(columns:!(test1,test2),filters:!())"`
- );
- });
-
- test('returning a valid context url when docId contains whitespace', async () => {
- const url = await getContextUrl(
- 'doc Id',
- 'ipId',
- ['test1', 'test2'],
- filterManager,
- addBasePath
- );
- expect(url).toMatchInlineSnapshot(
- `"/base/app/discover#/context/ipId/doc%20Id?_g=(filters:!())&_a=(columns:!(test1,test2),filters:!())"`
- );
- });
-});
diff --git a/src/plugins/discover/public/utils/get_context_url.tsx b/src/plugins/discover/public/utils/get_context_url.tsx
deleted file mode 100644
index 68c0e935f17e9..0000000000000
--- a/src/plugins/discover/public/utils/get_context_url.tsx
+++ /dev/null
@@ -1,46 +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
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { stringify } from 'query-string';
-import rison from 'rison-node';
-import { url } from '../../../kibana_utils/common';
-import { esFilters, FilterManager } from '../../../data/public';
-import { DiscoverServices } from '../build_services';
-
-/**
- * Helper function to generate an URL to a document in Discover's context view
- */
-export function getContextUrl(
- documentId: string,
- indexPatternId: string,
- columns: string[],
- filterManager: FilterManager,
- addBasePath: DiscoverServices['addBasePath']
-) {
- const globalFilters = filterManager.getGlobalFilters();
- const appFilters = filterManager.getAppFilters();
-
- const hash = stringify(
- url.encodeQuery({
- _g: rison.encode({
- filters: globalFilters || [],
- }),
- _a: rison.encode({
- columns,
- filters: (appFilters || []).map(esFilters.disableFilter),
- }),
- }),
- { encode: false, sort: false }
- );
-
- return addBasePath(
- `/app/discover#/context/${encodeURIComponent(indexPatternId)}/${encodeURIComponent(
- documentId
- )}?${hash}`
- );
-}
diff --git a/src/plugins/discover/public/utils/use_navigation_props.test.tsx b/src/plugins/discover/public/utils/use_navigation_props.test.tsx
new file mode 100644
index 0000000000000..29d4976f265c3
--- /dev/null
+++ b/src/plugins/discover/public/utils/use_navigation_props.test.tsx
@@ -0,0 +1,101 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React, { ReactElement } from 'react';
+import { renderHook } from '@testing-library/react-hooks';
+import { createFilterManagerMock } from '../../../data/public/query/filter_manager/filter_manager.mock';
+import {
+ getContextHash,
+ HistoryState,
+ useNavigationProps,
+ UseNavigationProps,
+} from './use_navigation_props';
+import { Router } from 'react-router-dom';
+import { createMemoryHistory } from 'history';
+import { setServices } from '../kibana_services';
+import { DiscoverServices } from '../build_services';
+
+const filterManager = createFilterManagerMock();
+const defaultProps = {
+ indexPatternId: 'ff959d40-b880-11e8-a6d9-e546fe2bba5f',
+ rowIndex: 'kibana_sample_data_ecommerce',
+ rowId: 'QmsYdX0BQ6gV8MTfoPYE',
+ columns: ['customer_first_name', 'products.manufacturer'],
+ filterManager,
+ addBasePath: jest.fn(),
+} as UseNavigationProps;
+const basePathPrefix = 'localhost:5601/xqj';
+
+const getSearch = () => {
+ return `?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))
+ &_a=(columns:!(${defaultProps.columns.join()}),filters:!(),index:${defaultProps.indexPatternId}
+ ,interval:auto,query:(language:kuery,query:''),sort:!(!(order_date,desc)))`;
+};
+
+const getSingeDocRoute = () => {
+ return `/doc/${defaultProps.indexPatternId}/${defaultProps.rowIndex}`;
+};
+
+const getContextRoute = () => {
+ return `/context/${defaultProps.indexPatternId}/${defaultProps.rowId}`;
+};
+
+const render = () => {
+ const history = createMemoryHistory({
+ initialEntries: ['/' + getSearch()],
+ });
+ setServices({ history: () => history } as unknown as DiscoverServices);
+ const wrapper = ({ children }: { children: ReactElement }) => (
+ {children}
+ );
+ return {
+ result: renderHook(() => useNavigationProps(defaultProps), { wrapper }).result,
+ history,
+ };
+};
+
+describe('useNavigationProps', () => {
+ test('should provide valid breadcrumb for single doc page from main view', () => {
+ const { result, history } = render();
+
+ result.current.singleDocProps.onClick?.();
+ expect(history.location.pathname).toEqual(getSingeDocRoute());
+ expect(history.location.search).toEqual(`?id=${defaultProps.rowId}`);
+ expect(history.location.state?.breadcrumb).toEqual(`#/${getSearch()}`);
+ });
+
+ test('should provide valid breadcrumb for context page from main view', () => {
+ const { result, history } = render();
+
+ result.current.surrDocsProps.onClick?.();
+ expect(history.location.pathname).toEqual(getContextRoute());
+ expect(history.location.search).toEqual(
+ `?${getContextHash(defaultProps.columns, filterManager)}`
+ );
+ expect(history.location.state?.breadcrumb).toEqual(`#/${getSearch()}`);
+ });
+
+ test('should create valid links to the context and single doc pages from embeddable', () => {
+ const { result } = renderHook(() =>
+ useNavigationProps({
+ ...defaultProps,
+ addBasePath: (val: string) => `${basePathPrefix}${val}`,
+ })
+ );
+
+ expect(result.current.singleDocProps.href!).toEqual(
+ `${basePathPrefix}/app/discover#${getSingeDocRoute()}?id=${defaultProps.rowId}`
+ );
+ expect(result.current.surrDocsProps.href!).toEqual(
+ `${basePathPrefix}/app/discover#${getContextRoute()}?${getContextHash(
+ defaultProps.columns,
+ filterManager
+ )}`
+ );
+ });
+});
diff --git a/src/plugins/discover/public/utils/use_navigation_props.tsx b/src/plugins/discover/public/utils/use_navigation_props.tsx
new file mode 100644
index 0000000000000..6f1dedf75e730
--- /dev/null
+++ b/src/plugins/discover/public/utils/use_navigation_props.tsx
@@ -0,0 +1,132 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { useMemo, useRef } from 'react';
+import { useHistory, matchPath } from 'react-router-dom';
+import { stringify } from 'query-string';
+import rison from 'rison-node';
+import { esFilters, FilterManager } from '../../../data/public';
+import { url } from '../../../kibana_utils/common';
+import { getServices } from '../kibana_services';
+
+export type DiscoverNavigationProps = { onClick: () => void } | { href: string };
+
+export interface UseNavigationProps {
+ indexPatternId: string;
+ rowIndex: string;
+ rowId: string;
+ columns: string[];
+ filterManager: FilterManager;
+ addBasePath: (url: string) => string;
+}
+
+export type HistoryState = { breadcrumb?: string } | undefined;
+
+export const getContextHash = (columns: string[], filterManager: FilterManager) => {
+ const globalFilters = filterManager.getGlobalFilters();
+ const appFilters = filterManager.getAppFilters();
+
+ const hash = stringify(
+ url.encodeQuery({
+ _g: rison.encode({
+ filters: globalFilters || [],
+ }),
+ _a: rison.encode({
+ columns,
+ filters: (appFilters || []).map(esFilters.disableFilter),
+ }),
+ }),
+ { encode: false, sort: false }
+ );
+
+ return hash;
+};
+
+/**
+ * When it's context route, breadcrumb link should point to the main discover page anyway.
+ * Otherwise, we are on main page and should create breadcrumb link from it.
+ * Current history object should be used in callback, since url state might be changed
+ * after expanded document opened.
+ */
+const getCurrentBreadcrumbs = (isContextRoute: boolean, prevBreadcrumb?: string) => {
+ const { history: getHistory } = getServices();
+ const currentHistory = getHistory();
+ return isContextRoute
+ ? prevBreadcrumb
+ : '#' + currentHistory?.location.pathname + currentHistory?.location.search;
+};
+
+export const useMainRouteBreadcrumb = () => {
+ // useRef needed to retrieve initial breadcrumb link from the push state without updates
+ return useRef(useHistory().location.state?.breadcrumb).current;
+};
+
+export const useNavigationProps = ({
+ indexPatternId,
+ rowIndex,
+ rowId,
+ columns,
+ filterManager,
+ addBasePath,
+}: UseNavigationProps) => {
+ const history = useHistory();
+ const prevBreadcrumb = useRef(history?.location.state?.breadcrumb).current;
+ const contextSearchHash = useMemo(
+ () => getContextHash(columns, filterManager),
+ [columns, filterManager]
+ );
+
+ /**
+ * When history can be accessed via hooks,
+ * it is discover main or context route.
+ */
+ if (!!history) {
+ const isContextRoute = matchPath(history.location.pathname, {
+ path: '/context/:indexPatternId/:id',
+ exact: true,
+ });
+
+ const onOpenSingleDoc = () => {
+ history.push({
+ pathname: `/doc/${indexPatternId}/${rowIndex}`,
+ search: `?id=${encodeURIComponent(rowId)}`,
+ state: { breadcrumb: getCurrentBreadcrumbs(!!isContextRoute, prevBreadcrumb) },
+ });
+ };
+
+ const onOpenSurrDocs = () =>
+ history.push({
+ pathname: `/context/${encodeURIComponent(indexPatternId)}/${encodeURIComponent(
+ String(rowId)
+ )}`,
+ search: `?${contextSearchHash}`,
+ state: { breadcrumb: getCurrentBreadcrumbs(!!isContextRoute, prevBreadcrumb) },
+ });
+
+ return {
+ singleDocProps: { onClick: onOpenSingleDoc },
+ surrDocsProps: { onClick: onOpenSurrDocs },
+ };
+ }
+
+ // for embeddable absolute href should be kept
+ return {
+ singleDocProps: {
+ href: addBasePath(
+ `/app/discover#/doc/${indexPatternId}/${rowIndex}?id=${encodeURIComponent(rowId)}`
+ ),
+ },
+ surrDocsProps: {
+ href: addBasePath(
+ `/app/discover#/context/${encodeURIComponent(indexPatternId)}/${encodeURIComponent(
+ rowId
+ )}?${contextSearchHash}`
+ ),
+ },
+ };
+};
diff --git a/src/plugins/home/server/plugin.ts b/src/plugins/home/server/plugin.ts
index 6f082dd561e93..04d2d80898b50 100644
--- a/src/plugins/home/server/plugin.ts
+++ b/src/plugins/home/server/plugin.ts
@@ -27,12 +27,13 @@ export interface HomeServerPluginSetupDependencies {
}
export class HomeServerPlugin implements Plugin {
- private readonly tutorialsRegistry = new TutorialsRegistry();
+ private readonly tutorialsRegistry;
private readonly sampleDataRegistry: SampleDataRegistry;
private customIntegrations?: CustomIntegrationsPluginSetup;
constructor(private readonly initContext: PluginInitializerContext) {
this.sampleDataRegistry = new SampleDataRegistry(this.initContext);
+ this.tutorialsRegistry = new TutorialsRegistry(this.initContext);
}
public setup(core: CoreSetup, plugins: HomeServerPluginSetupDependencies): HomeServerPluginSetup {
diff --git a/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts b/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts
index 4c80c8858a475..aeebecf6cab32 100644
--- a/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts
+++ b/src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts
@@ -29,6 +29,7 @@ export enum TutorialsCategory {
export type Platform = 'WINDOWS' | 'OSX' | 'DEB' | 'RPM';
export interface TutorialContext {
+ kibanaBranch: string;
[key: string]: unknown;
}
export type TutorialProvider = (context: TutorialContext) => TutorialSchema;
diff --git a/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts b/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts
index ee73c8e13f62b..dec1d23e05787 100644
--- a/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts
+++ b/src/plugins/home/server/services/tutorials/tutorials_registry.test.ts
@@ -69,6 +69,7 @@ const validTutorialProvider = VALID_TUTORIAL;
describe('TutorialsRegistry', () => {
let mockCoreSetup: MockedKeys;
+ let mockInitContext: ReturnType;
let testProvider: TutorialProvider;
let testScopedTutorialContextFactory: ScopedTutorialContextFactory;
let mockCustomIntegrationsPluginSetup: jest.Mocked;
@@ -80,6 +81,7 @@ describe('TutorialsRegistry', () => {
describe('GET /api/kibana/home/tutorials', () => {
beforeEach(() => {
mockCoreSetup = coreMock.createSetup();
+ mockInitContext = coreMock.createPluginInitializerContext();
});
test('has a router that retrieves registered tutorials', () => {
@@ -90,13 +92,19 @@ describe('TutorialsRegistry', () => {
describe('setup', () => {
test('exposes proper contract', () => {
- const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
+ const setup = new TutorialsRegistry(mockInitContext).setup(
+ mockCoreSetup,
+ mockCustomIntegrationsPluginSetup
+ );
expect(setup).toHaveProperty('registerTutorial');
expect(setup).toHaveProperty('addScopedTutorialContextFactory');
});
test('registerTutorial throws when registering a tutorial with an invalid schema', () => {
- const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
+ const setup = new TutorialsRegistry(mockInitContext).setup(
+ mockCoreSetup,
+ mockCustomIntegrationsPluginSetup
+ );
testProvider = ({}) => invalidTutorialProvider;
expect(() => setup.registerTutorial(testProvider)).toThrowErrorMatchingInlineSnapshot(
`"Unable to register tutorial spec because its invalid. Error: [name]: is not allowed to be empty"`
@@ -104,7 +112,10 @@ describe('TutorialsRegistry', () => {
});
test('registerTutorial registers a tutorial with a valid schema', () => {
- const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
+ const setup = new TutorialsRegistry(mockInitContext).setup(
+ mockCoreSetup,
+ mockCustomIntegrationsPluginSetup
+ );
testProvider = ({}) => validTutorialProvider;
expect(() => setup.registerTutorial(testProvider)).not.toThrowError();
expect(mockCustomIntegrationsPluginSetup.registerCustomIntegration.mock.calls).toEqual([
@@ -129,7 +140,10 @@ describe('TutorialsRegistry', () => {
});
test('addScopedTutorialContextFactory throws when given a scopedTutorialContextFactory that is not a function', () => {
- const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
+ const setup = new TutorialsRegistry(mockInitContext).setup(
+ mockCoreSetup,
+ mockCustomIntegrationsPluginSetup
+ );
const testItem = {} as TutorialProvider;
expect(() =>
setup.addScopedTutorialContextFactory(testItem)
@@ -139,7 +153,10 @@ describe('TutorialsRegistry', () => {
});
test('addScopedTutorialContextFactory adds a scopedTutorialContextFactory when given a function', () => {
- const setup = new TutorialsRegistry().setup(mockCoreSetup, mockCustomIntegrationsPluginSetup);
+ const setup = new TutorialsRegistry(mockInitContext).setup(
+ mockCoreSetup,
+ mockCustomIntegrationsPluginSetup
+ );
testScopedTutorialContextFactory = ({}) => 'string';
expect(() =>
setup.addScopedTutorialContextFactory(testScopedTutorialContextFactory)
@@ -149,7 +166,7 @@ describe('TutorialsRegistry', () => {
describe('start', () => {
test('exposes proper contract', () => {
- const start = new TutorialsRegistry().start(
+ const start = new TutorialsRegistry(mockInitContext).start(
coreMock.createStart(),
mockCustomIntegrationsPluginSetup
);
diff --git a/src/plugins/home/server/services/tutorials/tutorials_registry.ts b/src/plugins/home/server/services/tutorials/tutorials_registry.ts
index 723c92e6dfaf4..7d93a57b2073d 100644
--- a/src/plugins/home/server/services/tutorials/tutorials_registry.ts
+++ b/src/plugins/home/server/services/tutorials/tutorials_registry.ts
@@ -6,11 +6,12 @@
* Side Public License, v 1.
*/
-import { CoreSetup, CoreStart } from 'src/core/server';
+import { CoreSetup, CoreStart, PluginInitializerContext } from 'src/core/server';
import {
TutorialProvider,
TutorialContextFactory,
ScopedTutorialContextFactory,
+ TutorialContext,
} from './lib/tutorials_registry_types';
import { TutorialSchema, tutorialSchema } from './lib/tutorial_schema';
import { builtInTutorials } from '../../tutorials/register';
@@ -71,12 +72,14 @@ export class TutorialsRegistry {
private tutorialProviders: TutorialProvider[] = []; // pre-register all the tutorials we know we want in here
private readonly scopedTutorialContextFactories: TutorialContextFactory[] = [];
+ constructor(private readonly initContext: PluginInitializerContext) {}
+
public setup(core: CoreSetup, customIntegrations?: CustomIntegrationsPluginSetup) {
const router = core.http.createRouter();
router.get(
{ path: '/api/kibana/home/tutorials', validate: false },
async (context, req, res) => {
- const initialContext = {};
+ const initialContext = this.baseTutorialContext;
const scopedContext = this.scopedTutorialContextFactories.reduce(
(accumulatedContext, contextFactory) => {
return { ...accumulatedContext, ...contextFactory(req) };
@@ -92,7 +95,7 @@ export class TutorialsRegistry {
);
return {
registerTutorial: (specProvider: TutorialProvider) => {
- const emptyContext = {};
+ const emptyContext = this.baseTutorialContext;
let tutorial: TutorialSchema;
try {
tutorial = tutorialSchema.validate(specProvider(emptyContext));
@@ -132,12 +135,16 @@ export class TutorialsRegistry {
if (customIntegrations) {
builtInTutorials.forEach((provider) => {
- const tutorial = provider({});
+ const tutorial = provider(this.baseTutorialContext);
registerBeatsTutorialsWithCustomIntegrations(core, customIntegrations, tutorial);
});
}
return {};
}
+
+ private get baseTutorialContext(): TutorialContext {
+ return { kibanaBranch: this.initContext.env.packageInfo.branch };
+ }
}
/** @public */
diff --git a/src/plugins/home/server/tutorials/activemq_logs/index.ts b/src/plugins/home/server/tutorials/activemq_logs/index.ts
index a277b37838562..cc84f9a536b22 100644
--- a/src/plugins/home/server/tutorials/activemq_logs/index.ts
+++ b/src/plugins/home/server/tutorials/activemq_logs/index.ts
@@ -56,8 +56,8 @@ export function activemqLogsSpecProvider(context: TutorialContext): TutorialSche
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/activemq_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/activemq_metrics/index.ts b/src/plugins/home/server/tutorials/activemq_metrics/index.ts
index 9a001c149cda0..9c98c9c2ffc7a 100644
--- a/src/plugins/home/server/tutorials/activemq_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/activemq_metrics/index.ts
@@ -54,8 +54,8 @@ export function activemqMetricsSpecProvider(context: TutorialContext): TutorialS
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['web'],
};
diff --git a/src/plugins/home/server/tutorials/aerospike_metrics/index.ts b/src/plugins/home/server/tutorials/aerospike_metrics/index.ts
index 3e574f2c75496..1cc350af579cb 100644
--- a/src/plugins/home/server/tutorials/aerospike_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/aerospike_metrics/index.ts
@@ -54,8 +54,8 @@ export function aerospikeMetricsSpecProvider(context: TutorialContext): Tutorial
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/apache_logs/index.ts b/src/plugins/home/server/tutorials/apache_logs/index.ts
index 6e588fd86588d..aea8e3c188d94 100644
--- a/src/plugins/home/server/tutorials/apache_logs/index.ts
+++ b/src/plugins/home/server/tutorials/apache_logs/index.ts
@@ -57,8 +57,8 @@ export function apacheLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/apache_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/apache_metrics/index.ts b/src/plugins/home/server/tutorials/apache_metrics/index.ts
index 17b495d1460c5..0af719610c24d 100644
--- a/src/plugins/home/server/tutorials/apache_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/apache_metrics/index.ts
@@ -56,8 +56,8 @@ export function apacheMetricsSpecProvider(context: TutorialContext): TutorialSch
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/apache_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/auditbeat/index.ts b/src/plugins/home/server/tutorials/auditbeat/index.ts
index 96e5d4bcda393..666fcf15635c3 100644
--- a/src/plugins/home/server/tutorials/auditbeat/index.ts
+++ b/src/plugins/home/server/tutorials/auditbeat/index.ts
@@ -56,8 +56,8 @@ processes, users, logins, sockets information, file accesses, and more. \
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/auditbeat/screenshot.png',
onPrem: onPremInstructions(platforms, context),
- elasticCloud: cloudInstructions(platforms),
- onPremElasticCloud: onPremCloudInstructions(platforms),
+ elasticCloud: cloudInstructions(platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(platforms, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/auditd_logs/index.ts b/src/plugins/home/server/tutorials/auditd_logs/index.ts
index 6993196d93417..24857045ccc28 100644
--- a/src/plugins/home/server/tutorials/auditd_logs/index.ts
+++ b/src/plugins/home/server/tutorials/auditd_logs/index.ts
@@ -57,8 +57,8 @@ export function auditdLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/auditd_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['os_system'],
};
}
diff --git a/src/plugins/home/server/tutorials/aws_logs/index.ts b/src/plugins/home/server/tutorials/aws_logs/index.ts
index 62fbcc4eebc18..60187490318ae 100644
--- a/src/plugins/home/server/tutorials/aws_logs/index.ts
+++ b/src/plugins/home/server/tutorials/aws_logs/index.ts
@@ -57,8 +57,8 @@ export function awsLogsSpecProvider(context: TutorialContext): TutorialSchema {
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/aws_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['aws', 'cloud', 'datastore', 'security', 'network'],
};
}
diff --git a/src/plugins/home/server/tutorials/aws_metrics/index.ts b/src/plugins/home/server/tutorials/aws_metrics/index.ts
index 6bf1bf64bff9f..6541b4f5f29c8 100644
--- a/src/plugins/home/server/tutorials/aws_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/aws_metrics/index.ts
@@ -58,8 +58,8 @@ export function awsMetricsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/aws_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['aws', 'cloud', 'datastore', 'security', 'network'],
};
}
diff --git a/src/plugins/home/server/tutorials/azure_logs/index.ts b/src/plugins/home/server/tutorials/azure_logs/index.ts
index 3c9438d9a6298..163496813567a 100644
--- a/src/plugins/home/server/tutorials/azure_logs/index.ts
+++ b/src/plugins/home/server/tutorials/azure_logs/index.ts
@@ -58,8 +58,8 @@ export function azureLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/azure_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['azure', 'cloud', 'network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/azure_metrics/index.ts b/src/plugins/home/server/tutorials/azure_metrics/index.ts
index 310f954104634..edf4062812b42 100644
--- a/src/plugins/home/server/tutorials/azure_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/azure_metrics/index.ts
@@ -57,8 +57,8 @@ export function azureMetricsSpecProvider(context: TutorialContext): TutorialSche
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/azure_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['azure', 'cloud', 'network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/barracuda_logs/index.ts b/src/plugins/home/server/tutorials/barracuda_logs/index.ts
index cdfd75b9728b9..7cf333ec6f7e5 100644
--- a/src/plugins/home/server/tutorials/barracuda_logs/index.ts
+++ b/src/plugins/home/server/tutorials/barracuda_logs/index.ts
@@ -55,8 +55,8 @@ export function barracudaLogsSpecProvider(context: TutorialContext): TutorialSch
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/bluecoat_logs/index.ts b/src/plugins/home/server/tutorials/bluecoat_logs/index.ts
index a7db5b04ee40d..f35cd0ac4e450 100644
--- a/src/plugins/home/server/tutorials/bluecoat_logs/index.ts
+++ b/src/plugins/home/server/tutorials/bluecoat_logs/index.ts
@@ -54,8 +54,8 @@ export function bluecoatLogsSpecProvider(context: TutorialContext): TutorialSche
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/cef_logs/index.ts b/src/plugins/home/server/tutorials/cef_logs/index.ts
index 1366198d610d7..bf1f402a09a65 100644
--- a/src/plugins/home/server/tutorials/cef_logs/index.ts
+++ b/src/plugins/home/server/tutorials/cef_logs/index.ts
@@ -61,8 +61,8 @@ export function cefLogsSpecProvider(context: TutorialContext): TutorialSchema {
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/ceph_metrics/index.ts b/src/plugins/home/server/tutorials/ceph_metrics/index.ts
index 6a53789d26f7c..e7d2c67ec2a99 100644
--- a/src/plugins/home/server/tutorials/ceph_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/ceph_metrics/index.ts
@@ -54,8 +54,8 @@ export function cephMetricsSpecProvider(context: TutorialContext): TutorialSchem
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/checkpoint_logs/index.ts b/src/plugins/home/server/tutorials/checkpoint_logs/index.ts
index b5ea6be42403b..83ce8d27ec861 100644
--- a/src/plugins/home/server/tutorials/checkpoint_logs/index.ts
+++ b/src/plugins/home/server/tutorials/checkpoint_logs/index.ts
@@ -54,8 +54,8 @@ export function checkpointLogsSpecProvider(context: TutorialContext): TutorialSc
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/cisco_logs/index.ts b/src/plugins/home/server/tutorials/cisco_logs/index.ts
index 922cfbf1e23ee..3c855996873af 100644
--- a/src/plugins/home/server/tutorials/cisco_logs/index.ts
+++ b/src/plugins/home/server/tutorials/cisco_logs/index.ts
@@ -57,8 +57,8 @@ export function ciscoLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/cisco_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/cloudwatch_logs/index.ts b/src/plugins/home/server/tutorials/cloudwatch_logs/index.ts
index 5564d11be4d19..a4172fae4ff4d 100644
--- a/src/plugins/home/server/tutorials/cloudwatch_logs/index.ts
+++ b/src/plugins/home/server/tutorials/cloudwatch_logs/index.ts
@@ -51,8 +51,8 @@ export function cloudwatchLogsSpecProvider(context: TutorialContext): TutorialSc
},
completionTimeMinutes: 10,
onPrem: onPremInstructions([], context),
- elasticCloud: cloudInstructions(),
- onPremElasticCloud: onPremCloudInstructions(),
+ elasticCloud: cloudInstructions(context),
+ onPremElasticCloud: onPremCloudInstructions(context),
integrationBrowserCategories: ['aws', 'cloud', 'datastore', 'security', 'network'],
};
}
diff --git a/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts b/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts
index 535c8aaa90768..d53fd7f1f73aa 100644
--- a/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/cockroachdb_metrics/index.ts
@@ -59,8 +59,8 @@ export function cockroachdbMetricsSpecProvider(context: TutorialContext): Tutori
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/cockroachdb_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/consul_metrics/index.ts b/src/plugins/home/server/tutorials/consul_metrics/index.ts
index ca7179d55fd89..26fff9e58f511 100644
--- a/src/plugins/home/server/tutorials/consul_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/consul_metrics/index.ts
@@ -56,8 +56,8 @@ export function consulMetricsSpecProvider(context: TutorialContext): TutorialSch
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/consul_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/coredns_logs/index.ts b/src/plugins/home/server/tutorials/coredns_logs/index.ts
index 1261c67135001..876e6e09d61d6 100644
--- a/src/plugins/home/server/tutorials/coredns_logs/index.ts
+++ b/src/plugins/home/server/tutorials/coredns_logs/index.ts
@@ -57,8 +57,8 @@ export function corednsLogsSpecProvider(context: TutorialContext): TutorialSchem
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/coredns_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/coredns_metrics/index.ts b/src/plugins/home/server/tutorials/coredns_metrics/index.ts
index 3abc14314a6ba..b854f4d448361 100644
--- a/src/plugins/home/server/tutorials/coredns_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/coredns_metrics/index.ts
@@ -54,8 +54,8 @@ export function corednsMetricsSpecProvider(context: TutorialContext): TutorialSc
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/coredns_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/couchbase_metrics/index.ts b/src/plugins/home/server/tutorials/couchbase_metrics/index.ts
index 5c29aa2d9a524..2a71a6d0457f1 100644
--- a/src/plugins/home/server/tutorials/couchbase_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/couchbase_metrics/index.ts
@@ -54,8 +54,8 @@ export function couchbaseMetricsSpecProvider(context: TutorialContext): Tutorial
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/couchdb_metrics/index.ts b/src/plugins/home/server/tutorials/couchdb_metrics/index.ts
index 00bea11d13d99..a379b3b04f4c7 100644
--- a/src/plugins/home/server/tutorials/couchdb_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/couchdb_metrics/index.ts
@@ -59,8 +59,8 @@ export function couchdbMetricsSpecProvider(context: TutorialContext): TutorialSc
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/couchdb_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security', 'network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts b/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts
index a48ed4288210b..2c5a32b63f75f 100644
--- a/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts
+++ b/src/plugins/home/server/tutorials/crowdstrike_logs/index.ts
@@ -58,8 +58,8 @@ export function crowdstrikeLogsSpecProvider(context: TutorialContext): TutorialS
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/cylance_logs/index.ts b/src/plugins/home/server/tutorials/cylance_logs/index.ts
index 64b79a41cd2e0..d8b72963678fa 100644
--- a/src/plugins/home/server/tutorials/cylance_logs/index.ts
+++ b/src/plugins/home/server/tutorials/cylance_logs/index.ts
@@ -54,8 +54,8 @@ export function cylanceLogsSpecProvider(context: TutorialContext): TutorialSchem
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/docker_metrics/index.ts b/src/plugins/home/server/tutorials/docker_metrics/index.ts
index ab80e6d644dbc..e36d590650454 100644
--- a/src/plugins/home/server/tutorials/docker_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/docker_metrics/index.ts
@@ -56,8 +56,8 @@ export function dockerMetricsSpecProvider(context: TutorialContext): TutorialSch
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/docker_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['containers', 'os_system'],
};
}
diff --git a/src/plugins/home/server/tutorials/dropwizard_metrics/index.ts b/src/plugins/home/server/tutorials/dropwizard_metrics/index.ts
index 9864d376966bb..f01119e6ba1d2 100644
--- a/src/plugins/home/server/tutorials/dropwizard_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/dropwizard_metrics/index.ts
@@ -54,8 +54,8 @@ export function dropwizardMetricsSpecProvider(context: TutorialContext): Tutoria
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['elastic_stack', 'datastore'],
};
}
diff --git a/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts b/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts
index 6415781d02c06..a1df2d8a4085e 100644
--- a/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts
+++ b/src/plugins/home/server/tutorials/elasticsearch_logs/index.ts
@@ -56,8 +56,8 @@ export function elasticsearchLogsSpecProvider(context: TutorialContext): Tutoria
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/elasticsearch_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['containers', 'os_system'],
};
}
diff --git a/src/plugins/home/server/tutorials/elasticsearch_metrics/index.ts b/src/plugins/home/server/tutorials/elasticsearch_metrics/index.ts
index 3961d7f78c86c..009e441c725d9 100644
--- a/src/plugins/home/server/tutorials/elasticsearch_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/elasticsearch_metrics/index.ts
@@ -54,8 +54,8 @@ export function elasticsearchMetricsSpecProvider(context: TutorialContext): Tuto
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['elastic_stack', 'datastore'],
};
}
diff --git a/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts b/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts
index 55c85a5bdd2a4..d39b182b81eaf 100644
--- a/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts
+++ b/src/plugins/home/server/tutorials/envoyproxy_logs/index.ts
@@ -60,8 +60,8 @@ export function envoyproxyLogsSpecProvider(context: TutorialContext): TutorialSc
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/envoyproxy_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['elastic_stack', 'datastore'],
};
}
diff --git a/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts b/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts
index e2f3b84739685..84ea8099e3d93 100644
--- a/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/envoyproxy_metrics/index.ts
@@ -47,8 +47,8 @@ export function envoyproxyMetricsSpecProvider(context: TutorialContext): Tutoria
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['elastic_stack', 'datastore'],
};
}
diff --git a/src/plugins/home/server/tutorials/etcd_metrics/index.ts b/src/plugins/home/server/tutorials/etcd_metrics/index.ts
index 9ed153c21c257..c4c68e80d40eb 100644
--- a/src/plugins/home/server/tutorials/etcd_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/etcd_metrics/index.ts
@@ -54,8 +54,8 @@ export function etcdMetricsSpecProvider(context: TutorialContext): TutorialSchem
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['elastic_stack', 'datastore'],
};
}
diff --git a/src/plugins/home/server/tutorials/f5_logs/index.ts b/src/plugins/home/server/tutorials/f5_logs/index.ts
index a407d1d3d5142..381fdd487eb24 100644
--- a/src/plugins/home/server/tutorials/f5_logs/index.ts
+++ b/src/plugins/home/server/tutorials/f5_logs/index.ts
@@ -55,8 +55,8 @@ export function f5LogsSpecProvider(context: TutorialContext): TutorialSchema {
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/f5_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/fortinet_logs/index.ts b/src/plugins/home/server/tutorials/fortinet_logs/index.ts
index 2f6af3ba47280..6a73c5f8e3f66 100644
--- a/src/plugins/home/server/tutorials/fortinet_logs/index.ts
+++ b/src/plugins/home/server/tutorials/fortinet_logs/index.ts
@@ -54,8 +54,8 @@ export function fortinetLogsSpecProvider(context: TutorialContext): TutorialSche
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/gcp_logs/index.ts b/src/plugins/home/server/tutorials/gcp_logs/index.ts
index 23d8e3364eb69..d02c08cd2be9a 100644
--- a/src/plugins/home/server/tutorials/gcp_logs/index.ts
+++ b/src/plugins/home/server/tutorials/gcp_logs/index.ts
@@ -59,8 +59,8 @@ export function gcpLogsSpecProvider(context: TutorialContext): TutorialSchema {
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/gcp_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['google_cloud', 'cloud', 'network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/gcp_metrics/index.ts b/src/plugins/home/server/tutorials/gcp_metrics/index.ts
index 7f397c1e1be7b..ea5351d010a42 100644
--- a/src/plugins/home/server/tutorials/gcp_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/gcp_metrics/index.ts
@@ -57,8 +57,8 @@ export function gcpMetricsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/gcp_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['google_cloud', 'cloud', 'network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/golang_metrics/index.ts b/src/plugins/home/server/tutorials/golang_metrics/index.ts
index 50d09e42e8791..e179e69734ad5 100644
--- a/src/plugins/home/server/tutorials/golang_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/golang_metrics/index.ts
@@ -57,8 +57,8 @@ export function golangMetricsSpecProvider(context: TutorialContext): TutorialSch
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['google_cloud', 'cloud', 'network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/gsuite_logs/index.ts b/src/plugins/home/server/tutorials/gsuite_logs/index.ts
index 718558321cf78..ba193bdb08c08 100644
--- a/src/plugins/home/server/tutorials/gsuite_logs/index.ts
+++ b/src/plugins/home/server/tutorials/gsuite_logs/index.ts
@@ -54,8 +54,8 @@ export function gsuiteLogsSpecProvider(context: TutorialContext): TutorialSchema
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/haproxy_logs/index.ts b/src/plugins/home/server/tutorials/haproxy_logs/index.ts
index c3765317ecbe0..05fc23fa16bcd 100644
--- a/src/plugins/home/server/tutorials/haproxy_logs/index.ts
+++ b/src/plugins/home/server/tutorials/haproxy_logs/index.ts
@@ -57,8 +57,8 @@ export function haproxyLogsSpecProvider(context: TutorialContext): TutorialSchem
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/haproxy_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/haproxy_metrics/index.ts b/src/plugins/home/server/tutorials/haproxy_metrics/index.ts
index 49f1d32dc4c82..fa7c451889ba3 100644
--- a/src/plugins/home/server/tutorials/haproxy_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/haproxy_metrics/index.ts
@@ -54,8 +54,8 @@ export function haproxyMetricsSpecProvider(context: TutorialContext): TutorialSc
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['network', 'web'],
};
}
diff --git a/src/plugins/home/server/tutorials/ibmmq_logs/index.ts b/src/plugins/home/server/tutorials/ibmmq_logs/index.ts
index 21b60a9ab5a5c..90b35d0e78842 100644
--- a/src/plugins/home/server/tutorials/ibmmq_logs/index.ts
+++ b/src/plugins/home/server/tutorials/ibmmq_logs/index.ts
@@ -56,8 +56,8 @@ export function ibmmqLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/ibmmq_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts b/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts
index 706003f0eab48..6329df6836b06 100644
--- a/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/ibmmq_metrics/index.ts
@@ -55,8 +55,8 @@ export function ibmmqMetricsSpecProvider(context: TutorialContext): TutorialSche
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/ibmmq_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/icinga_logs/index.ts b/src/plugins/home/server/tutorials/icinga_logs/index.ts
index dc730022262c2..c65e92d0fe856 100644
--- a/src/plugins/home/server/tutorials/icinga_logs/index.ts
+++ b/src/plugins/home/server/tutorials/icinga_logs/index.ts
@@ -57,8 +57,8 @@ export function icingaLogsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/icinga_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['security'],
};
}
diff --git a/src/plugins/home/server/tutorials/iis_logs/index.ts b/src/plugins/home/server/tutorials/iis_logs/index.ts
index 0dbc5bbdc75b8..423f2f917c84e 100644
--- a/src/plugins/home/server/tutorials/iis_logs/index.ts
+++ b/src/plugins/home/server/tutorials/iis_logs/index.ts
@@ -58,8 +58,8 @@ export function iisLogsSpecProvider(context: TutorialContext): TutorialSchema {
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/iis_logs/screenshot.png',
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/iis_metrics/index.ts b/src/plugins/home/server/tutorials/iis_metrics/index.ts
index d57e4688ba753..3c3159c2838d1 100644
--- a/src/plugins/home/server/tutorials/iis_metrics/index.ts
+++ b/src/plugins/home/server/tutorials/iis_metrics/index.ts
@@ -57,8 +57,8 @@ export function iisMetricsSpecProvider(context: TutorialContext): TutorialSchema
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/iis_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
- elasticCloud: cloudInstructions(moduleName),
- onPremElasticCloud: onPremCloudInstructions(moduleName),
+ elasticCloud: cloudInstructions(moduleName, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, context),
integrationBrowserCategories: ['web'],
};
}
diff --git a/src/plugins/home/server/tutorials/imperva_logs/index.ts b/src/plugins/home/server/tutorials/imperva_logs/index.ts
index 1cbe707f813ee..35e0a668ec7f0 100644
--- a/src/plugins/home/server/tutorials/imperva_logs/index.ts
+++ b/src/plugins/home/server/tutorials/imperva_logs/index.ts
@@ -54,8 +54,8 @@ export function impervaLogsSpecProvider(context: TutorialContext): TutorialSchem
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network', 'security'],
};
}
diff --git a/src/plugins/home/server/tutorials/infoblox_logs/index.ts b/src/plugins/home/server/tutorials/infoblox_logs/index.ts
index 8dce2bf00b2e2..21d1fcf9a156c 100644
--- a/src/plugins/home/server/tutorials/infoblox_logs/index.ts
+++ b/src/plugins/home/server/tutorials/infoblox_logs/index.ts
@@ -54,8 +54,8 @@ export function infobloxLogsSpecProvider(context: TutorialContext): TutorialSche
},
completionTimeMinutes: 10,
onPrem: onPremInstructions(moduleName, platforms, context),
- elasticCloud: cloudInstructions(moduleName, platforms),
- onPremElasticCloud: onPremCloudInstructions(moduleName, platforms),
+ elasticCloud: cloudInstructions(moduleName, platforms, context),
+ onPremElasticCloud: onPremCloudInstructions(moduleName, platforms, context),
integrationBrowserCategories: ['network'],
};
}
diff --git a/src/plugins/home/server/tutorials/instructions/auditbeat_instructions.ts b/src/plugins/home/server/tutorials/instructions/auditbeat_instructions.ts
index d0a0f97e26037..3968aff312380 100644
--- a/src/plugins/home/server/tutorials/instructions/auditbeat_instructions.ts
+++ b/src/plugins/home/server/tutorials/instructions/auditbeat_instructions.ts
@@ -13,271 +13,317 @@ import { getSpaceIdForBeatsTutorial } from './get_space_id_for_beats_tutorial';
import { Platform, TutorialContext } from '../../services/tutorials/lib/tutorials_registry_types';
import { cloudPasswordAndResetLink } from './cloud_instructions';
-export const createAuditbeatInstructions = (context?: TutorialContext) => ({
- INSTALL: {
- OSX: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.osxTitle', {
- defaultMessage: 'Download and install Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.osxTextPre', {
- defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'tar xzvf auditbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'cd auditbeat-{config.kibana.version}-darwin-x86_64/',
- ],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.debTitle', {
- defaultMessage: 'Download and install Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.debTextPre', {
- defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-amd64.deb',
- 'sudo dpkg -i auditbeat-{config.kibana.version}-amd64.deb',
- ],
- textPost: i18n.translate('home.tutorials.common.auditbeatInstructions.install.debTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
- values: {
- linkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
- },
- }),
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.rpmTitle', {
- defaultMessage: 'Download and install Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.rpmTextPre', {
- defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-x86_64.rpm',
- 'sudo rpm -vi auditbeat-{config.kibana.version}-x86_64.rpm',
- ],
- textPost: i18n.translate('home.tutorials.common.auditbeatInstructions.install.rpmTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
- values: {
- linkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
- },
- }),
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.windowsTitle', {
- defaultMessage: 'Download and install Auditbeat',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.auditbeatInstructions.install.windowsTextPre',
- {
- defaultMessage:
- 'First time using Auditbeat? See the [Quick Start]({guideLinkUrl}).\n\
+export const createAuditbeatInstructions = (context: TutorialContext) => {
+ const SSL_DOC_URL = `https://www.elastic.co/guide/en/beats/auditbeat/${context.kibanaBranch}/configuration-ssl.html#ca-sha256`;
+
+ return {
+ INSTALL: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.osxTitle', {
+ defaultMessage: 'Download and install Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.osxTextPre', {
+ defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'tar xzvf auditbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'cd auditbeat-{config.kibana.version}-darwin-x86_64/',
+ ],
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.debTitle', {
+ defaultMessage: 'Download and install Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.debTextPre', {
+ defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-amd64.deb',
+ 'sudo dpkg -i auditbeat-{config.kibana.version}-amd64.deb',
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.install.debTextPost',
+ {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
+ values: {
+ linkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
+ },
+ }
+ ),
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.rpmTitle', {
+ defaultMessage: 'Download and install Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.install.rpmTextPre', {
+ defaultMessage: 'First time using Auditbeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/auditbeat/auditbeat-{config.kibana.version}-x86_64.rpm',
+ 'sudo rpm -vi auditbeat-{config.kibana.version}-x86_64.rpm',
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.install.rpmTextPost',
+ {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
+ values: {
+ linkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
+ },
+ }
+ ),
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.install.windowsTitle', {
+ defaultMessage: 'Download and install Auditbeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.install.windowsTextPre',
+ {
+ defaultMessage:
+ 'First time using Auditbeat? See the [Quick Start]({guideLinkUrl}).\n\
1. Download the Auditbeat Windows zip file from the [Download]({auditbeatLinkUrl}) page.\n\
2. Extract the contents of the zip file into {folderPath}.\n\
3. Rename the `{directoryName}` directory to `Auditbeat`.\n\
4. Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select \
**Run As Administrator**). If you are running Windows XP, you might need to download and install PowerShell.\n\
5. From the PowerShell prompt, run the following commands to install Auditbeat as a Windows service.',
+ values: {
+ folderPath: '`C:\\Program Files`',
+ guideLinkUrl:
+ '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
+ auditbeatLinkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
+ directoryName: 'auditbeat-{config.kibana.version}-windows',
+ },
+ }
+ ),
+ commands: ['cd "C:\\Program Files\\Auditbeat"', '.\\install-service-auditbeat.ps1'],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.install.windowsTextPost',
+ {
+ defaultMessage:
+ 'Modify the settings under {propertyName} in the {auditbeatPath} file to point to your Elasticsearch installation.',
+ values: {
+ propertyName: '`output.elasticsearch`',
+ auditbeatPath: '`C:\\Program Files\\Auditbeat\\auditbeat.yml`',
+ },
+ }
+ ),
+ },
+ },
+ START: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.osxTitle', {
+ defaultMessage: 'Start Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.osxTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['./auditbeat setup', './auditbeat -e'],
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.debTitle', {
+ defaultMessage: 'Start Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.debTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['sudo auditbeat setup', 'sudo service auditbeat start'],
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.rpmTitle', {
+ defaultMessage: 'Start Auditbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.rpmTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['sudo auditbeat setup', 'sudo service auditbeat start'],
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.windowsTitle', {
+ defaultMessage: 'Start Auditbeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.start.windowsTextPre',
+ {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }
+ ),
+ commands: ['.\\auditbeat.exe setup', 'Start-Service auditbeat'],
+ },
+ },
+ CONFIG: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.osxTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.osxTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
values: {
- folderPath: '`C:\\Program Files`',
- guideLinkUrl: '{config.docs.beats.auditbeat}/auditbeat-installation-configuration.html',
- auditbeatLinkUrl: 'https://www.elastic.co/downloads/beats/auditbeat',
- directoryName: 'auditbeat-{config.kibana.version}-windows',
+ path: '`auditbeat.yml`',
},
- }
- ),
- commands: ['cd "C:\\Program Files\\Auditbeat"', '.\\install-service-auditbeat.ps1'],
- textPost: i18n.translate(
- 'home.tutorials.common.auditbeatInstructions.install.windowsTextPost',
- {
- defaultMessage:
- 'Modify the settings under {propertyName} in the {auditbeatPath} file to point to your Elasticsearch installation.',
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.config.osxTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.debTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.debTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
values: {
- propertyName: '`output.elasticsearch`',
- auditbeatPath: '`C:\\Program Files\\Auditbeat\\auditbeat.yml`',
+ path: '`/etc/auditbeat/auditbeat.yml`',
},
- }
- ),
- },
- },
- START: {
- OSX: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.osxTitle', {
- defaultMessage: 'Start Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.osxTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['./auditbeat setup', './auditbeat -e'],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.debTitle', {
- defaultMessage: 'Start Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.debTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['sudo auditbeat setup', 'sudo service auditbeat start'],
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.rpmTitle', {
- defaultMessage: 'Start Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.rpmTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['sudo auditbeat setup', 'sudo service auditbeat start'],
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.start.windowsTitle', {
- defaultMessage: 'Start Auditbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.start.windowsTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['.\\auditbeat.exe setup', 'Start-Service auditbeat'],
- },
- },
- CONFIG: {
- OSX: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.osxTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.osxTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`auditbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.auditbeatInstructions.config.osxTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.debTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.debTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/auditbeat/auditbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.auditbeatInstructions.config.debTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.rpmTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.rpmTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/auditbeat/auditbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.auditbeatInstructions.config.rpmTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.windowsTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.windowsTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`C:\\Program Files\\Auditbeat\\auditbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate(
- 'home.tutorials.common.auditbeatInstructions.config.windowsTextPost',
- {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.config.debTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.rpmTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.auditbeatInstructions.config.rpmTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
+ path: '`/etc/auditbeat/auditbeat.yml`',
},
- }
- ),
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.config.rpmTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.auditbeatInstructions.config.windowsTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.config.windowsTextPre',
+ {
+ defaultMessage: 'Modify {path} to set the connection information:',
+ values: {
+ path: '`C:\\Program Files\\Auditbeat\\auditbeat.yml`',
+ },
+ }
+ ),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.auditbeatInstructions.config.windowsTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
},
- },
-});
+ };
+};
export const createAuditbeatCloudInstructions = () => ({
CONFIG: {
@@ -383,7 +429,7 @@ export function auditbeatStatusCheck() {
};
}
-export function onPremInstructions(platforms: readonly Platform[], context?: TutorialContext) {
+export function onPremInstructions(platforms: readonly Platform[], context: TutorialContext) {
const AUDITBEAT_INSTRUCTIONS = createAuditbeatInstructions(context);
const variants = [];
@@ -414,8 +460,8 @@ export function onPremInstructions(platforms: readonly Platform[], context?: Tut
};
}
-export function onPremCloudInstructions(platforms: readonly Platform[]) {
- const AUDITBEAT_INSTRUCTIONS = createAuditbeatInstructions();
+export function onPremCloudInstructions(platforms: readonly Platform[], context: TutorialContext) {
+ const AUDITBEAT_INSTRUCTIONS = createAuditbeatInstructions(context);
const TRYCLOUD_OPTION1 = createTrycloudOption1();
const TRYCLOUD_OPTION2 = createTrycloudOption2();
@@ -450,8 +496,8 @@ export function onPremCloudInstructions(platforms: readonly Platform[]) {
};
}
-export function cloudInstructions(platforms: readonly Platform[]) {
- const AUDITBEAT_INSTRUCTIONS = createAuditbeatInstructions();
+export function cloudInstructions(platforms: readonly Platform[], context: TutorialContext) {
+ const AUDITBEAT_INSTRUCTIONS = createAuditbeatInstructions(context);
const AUDITBEAT_CLOUD_INSTRUCTIONS = createAuditbeatCloudInstructions();
const variants = [];
diff --git a/src/plugins/home/server/tutorials/instructions/filebeat_instructions.ts b/src/plugins/home/server/tutorials/instructions/filebeat_instructions.ts
index c6aa44932ee45..89445510f2b3d 100644
--- a/src/plugins/home/server/tutorials/instructions/filebeat_instructions.ts
+++ b/src/plugins/home/server/tutorials/instructions/filebeat_instructions.ts
@@ -13,268 +13,307 @@ import { getSpaceIdForBeatsTutorial } from './get_space_id_for_beats_tutorial';
import { Platform, TutorialContext } from '../../services/tutorials/lib/tutorials_registry_types';
import { cloudPasswordAndResetLink } from './cloud_instructions';
-export const createFilebeatInstructions = (context?: TutorialContext) => ({
- INSTALL: {
- OSX: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.install.osxTitle', {
- defaultMessage: 'Download and install Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.osxTextPre', {
- defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'tar xzvf filebeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'cd filebeat-{config.kibana.version}-darwin-x86_64/',
- ],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTitle', {
- defaultMessage: 'Download and install Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTextPre', {
- defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-amd64.deb',
- 'sudo dpkg -i filebeat-{config.kibana.version}-amd64.deb',
- ],
- textPost: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
- values: {
- linkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
- },
- }),
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTitle', {
- defaultMessage: 'Download and install Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTextPre', {
- defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
- values: {
- linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-x86_64.rpm',
- 'sudo rpm -vi filebeat-{config.kibana.version}-x86_64.rpm',
- ],
- textPost: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
- values: {
- linkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
- },
- }),
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.install.windowsTitle', {
- defaultMessage: 'Download and install Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.windowsTextPre', {
- defaultMessage:
- 'First time using Filebeat? See the [Quick Start]({guideLinkUrl}).\n\
+export const createFilebeatInstructions = (context: TutorialContext) => {
+ const SSL_DOC_URL = `https://www.elastic.co/guide/en/beats/filebeat/${context.kibanaBranch}/configuration-ssl.html#ca-sha256`;
+
+ return {
+ INSTALL: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.install.osxTitle', {
+ defaultMessage: 'Download and install Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.osxTextPre', {
+ defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'tar xzvf filebeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'cd filebeat-{config.kibana.version}-darwin-x86_64/',
+ ],
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTitle', {
+ defaultMessage: 'Download and install Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTextPre', {
+ defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-amd64.deb',
+ 'sudo dpkg -i filebeat-{config.kibana.version}-amd64.deb',
+ ],
+ textPost: i18n.translate('home.tutorials.common.filebeatInstructions.install.debTextPost', {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
+ values: {
+ linkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
+ },
+ }),
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTitle', {
+ defaultMessage: 'Download and install Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTextPre', {
+ defaultMessage: 'First time using Filebeat? See the [Quick Start]({linkUrl}).',
+ values: {
+ linkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-{config.kibana.version}-x86_64.rpm',
+ 'sudo rpm -vi filebeat-{config.kibana.version}-x86_64.rpm',
+ ],
+ textPost: i18n.translate('home.tutorials.common.filebeatInstructions.install.rpmTextPost', {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({linkUrl}).',
+ values: {
+ linkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
+ },
+ }),
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.install.windowsTitle', {
+ defaultMessage: 'Download and install Filebeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.install.windowsTextPre',
+ {
+ defaultMessage:
+ 'First time using Filebeat? See the [Quick Start]({guideLinkUrl}).\n\
1. Download the Filebeat Windows zip file from the [Download]({filebeatLinkUrl}) page.\n\
2. Extract the contents of the zip file into {folderPath}.\n\
3. Rename the `{directoryName}` directory to `Filebeat`.\n\
4. Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select \
**Run As Administrator**). If you are running Windows XP, you might need to download and install PowerShell.\n\
5. From the PowerShell prompt, run the following commands to install Filebeat as a Windows service.',
- values: {
- folderPath: '`C:\\Program Files`',
- guideLinkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
- filebeatLinkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
- directoryName: 'filebeat-{config.kibana.version}-windows',
- },
- }),
- commands: ['cd "C:\\Program Files\\Filebeat"', '.\\install-service-filebeat.ps1'],
- textPost: i18n.translate(
- 'home.tutorials.common.filebeatInstructions.install.windowsTextPost',
- {
+ values: {
+ folderPath: '`C:\\Program Files`',
+ guideLinkUrl: '{config.docs.beats.filebeat}/filebeat-installation-configuration.html',
+ filebeatLinkUrl: 'https://www.elastic.co/downloads/beats/filebeat',
+ directoryName: 'filebeat-{config.kibana.version}-windows',
+ },
+ }
+ ),
+ commands: ['cd "C:\\Program Files\\Filebeat"', '.\\install-service-filebeat.ps1'],
+ textPost: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.install.windowsTextPost',
+ {
+ defaultMessage:
+ 'Modify the settings under {propertyName} in the {filebeatPath} file to point to your Elasticsearch installation.',
+ values: {
+ propertyName: '`output.elasticsearch`',
+ filebeatPath: '`C:\\Program Files\\Filebeat\\filebeat.yml`',
+ },
+ }
+ ),
+ },
+ },
+ START: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.start.osxTitle', {
+ defaultMessage: 'Start Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.osxTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['./filebeat setup', './filebeat -e'],
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.start.debTitle', {
+ defaultMessage: 'Start Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.debTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['sudo filebeat setup', 'sudo service filebeat start'],
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.start.rpmTitle', {
+ defaultMessage: 'Start Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.rpmTextPre', {
defaultMessage:
- 'Modify the settings under {propertyName} in the {filebeatPath} file to point to your Elasticsearch installation.',
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['sudo filebeat setup', 'sudo service filebeat start'],
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.start.windowsTitle', {
+ defaultMessage: 'Start Filebeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.windowsTextPre', {
+ defaultMessage:
+ 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
+ }),
+ commands: ['.\\filebeat.exe setup', 'Start-Service filebeat'],
+ },
+ },
+ CONFIG: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.config.osxTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.osxTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
values: {
- propertyName: '`output.elasticsearch`',
- filebeatPath: '`C:\\Program Files\\Filebeat\\filebeat.yml`',
+ path: '`filebeat.yml`',
},
- }
- ),
- },
- },
- START: {
- OSX: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.start.osxTitle', {
- defaultMessage: 'Start Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.osxTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['./filebeat setup', './filebeat -e'],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.start.debTitle', {
- defaultMessage: 'Start Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.debTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['sudo filebeat setup', 'sudo service filebeat start'],
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.start.rpmTitle', {
- defaultMessage: 'Start Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.rpmTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['sudo filebeat setup', 'sudo service filebeat start'],
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.start.windowsTitle', {
- defaultMessage: 'Start Filebeat',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.start.windowsTextPre', {
- defaultMessage:
- 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
- }),
- commands: ['.\\filebeat.exe setup', 'Start-Service filebeat'],
- },
- },
- CONFIG: {
- OSX: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.config.osxTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.osxTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`filebeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.filebeatInstructions.config.osxTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.config.debTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.debTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/filebeat/filebeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.filebeatInstructions.config.debTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.config.rpmTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.rpmTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/filebeat/filebeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.filebeatInstructions.config.rpmTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.filebeatInstructions.config.windowsTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.windowsTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`C:\\Program Files\\Filebeat\\filebeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate(
- 'home.tutorials.common.filebeatInstructions.config.windowsTextPost',
- {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.config.osxTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.config.debTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.debTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
+ path: '`/etc/filebeat/filebeat.yml`',
},
- }
- ),
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.config.debTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.config.rpmTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate('home.tutorials.common.filebeatInstructions.config.rpmTextPre', {
+ defaultMessage: 'Modify {path} to set the connection information:',
+ values: {
+ path: '`/etc/filebeat/filebeat.yml`',
+ },
+ }),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.config.rpmTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.filebeatInstructions.config.windowsTitle', {
+ defaultMessage: 'Edit the configuration',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.config.windowsTextPre',
+ {
+ defaultMessage: 'Modify {path} to set the connection information:',
+ values: {
+ path: '`C:\\Program Files\\Filebeat\\filebeat.yml`',
+ },
+ }
+ ),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.filebeatInstructions.config.windowsTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
},
- },
-});
+ };
+};
export const createFilebeatCloudInstructions = () => ({
CONFIG: {
@@ -430,7 +469,7 @@ export function filebeatStatusCheck(moduleName: string) {
export function onPremInstructions(
moduleName: string,
platforms: readonly Platform[] = [],
- context?: TutorialContext
+ context: TutorialContext
) {
const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions(context);
@@ -463,8 +502,12 @@ export function onPremInstructions(
};
}
-export function onPremCloudInstructions(moduleName: string, platforms: readonly Platform[] = []) {
- const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions();
+export function onPremCloudInstructions(
+ moduleName: string,
+ platforms: readonly Platform[] = [],
+ context: TutorialContext
+) {
+ const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions(context);
const TRYCLOUD_OPTION1 = createTrycloudOption1();
const TRYCLOUD_OPTION2 = createTrycloudOption2();
@@ -500,8 +543,12 @@ export function onPremCloudInstructions(moduleName: string, platforms: readonly
};
}
-export function cloudInstructions(moduleName: string, platforms: readonly Platform[] = []) {
- const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions();
+export function cloudInstructions(
+ moduleName: string,
+ platforms: readonly Platform[] = [],
+ context: TutorialContext
+) {
+ const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions(context);
const FILEBEAT_CLOUD_INSTRUCTIONS = createFilebeatCloudInstructions();
const variants = [];
diff --git a/src/plugins/home/server/tutorials/instructions/functionbeat_instructions.ts b/src/plugins/home/server/tutorials/instructions/functionbeat_instructions.ts
index 24a6fe3719f8f..60d6fa5cb813b 100644
--- a/src/plugins/home/server/tutorials/instructions/functionbeat_instructions.ts
+++ b/src/plugins/home/server/tutorials/instructions/functionbeat_instructions.ts
@@ -13,171 +13,203 @@ import { getSpaceIdForBeatsTutorial } from './get_space_id_for_beats_tutorial';
import { Platform, TutorialContext } from '../../services/tutorials/lib/tutorials_registry_types';
import { cloudPasswordAndResetLink } from './cloud_instructions';
-export const createFunctionbeatInstructions = (context?: TutorialContext) => ({
- INSTALL: {
- OSX: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.install.osxTitle', {
- defaultMessage: 'Download and install Functionbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.functionbeatInstructions.install.osxTextPre', {
- defaultMessage: 'First time using Functionbeat? See the [Quick Start]({link}).',
- values: {
- link: '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
- },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'tar xzvf functionbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'cd functionbeat-{config.kibana.version}-darwin-x86_64/',
- ],
- },
- LINUX: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.install.linuxTitle', {
- defaultMessage: 'Download and install Functionbeat',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.install.linuxTextPre',
- {
- defaultMessage: 'First time using Functionbeat? See the [Quick Start]({link}).',
- values: {
- link: '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
- },
- }
- ),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-{config.kibana.version}-linux-x86_64.tar.gz',
- 'tar xzvf functionbeat-{config.kibana.version}-linux-x86_64.tar.gz',
- 'cd functionbeat-{config.kibana.version}-linux-x86_64/',
- ],
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.install.windowsTitle', {
- defaultMessage: 'Download and install Functionbeat',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.install.windowsTextPre',
- {
- defaultMessage:
- 'First time using Functionbeat? See the [Quick Start]({functionbeatLink}).\n\
+export const createFunctionbeatInstructions = (context: TutorialContext) => {
+ const SSL_DOC_URL = `https://www.elastic.co/guide/en/beats/functionbeat/${context.kibanaBranch}/configuration-ssl.html#ca-sha256`;
+
+ return {
+ INSTALL: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.functionbeatInstructions.install.osxTitle', {
+ defaultMessage: 'Download and install Functionbeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.install.osxTextPre',
+ {
+ defaultMessage: 'First time using Functionbeat? See the [Quick Start]({link}).',
+ values: {
+ link: '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
+ },
+ }
+ ),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'tar xzvf functionbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'cd functionbeat-{config.kibana.version}-darwin-x86_64/',
+ ],
+ },
+ LINUX: {
+ title: i18n.translate('home.tutorials.common.functionbeatInstructions.install.linuxTitle', {
+ defaultMessage: 'Download and install Functionbeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.install.linuxTextPre',
+ {
+ defaultMessage: 'First time using Functionbeat? See the [Quick Start]({link}).',
+ values: {
+ link: '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
+ },
+ }
+ ),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-{config.kibana.version}-linux-x86_64.tar.gz',
+ 'tar xzvf functionbeat-{config.kibana.version}-linux-x86_64.tar.gz',
+ 'cd functionbeat-{config.kibana.version}-linux-x86_64/',
+ ],
+ },
+ WINDOWS: {
+ title: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.install.windowsTitle',
+ {
+ defaultMessage: 'Download and install Functionbeat',
+ }
+ ),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.install.windowsTextPre',
+ {
+ defaultMessage:
+ 'First time using Functionbeat? See the [Quick Start]({functionbeatLink}).\n\
1. Download the Functionbeat Windows zip file from the [Download]({elasticLink}) page.\n\
2. Extract the contents of the zip file into {folderPath}.\n\
3. Rename the {directoryName} directory to `Functionbeat`.\n\
4. Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select \
**Run As Administrator**). If you are running Windows XP, you might need to download and install PowerShell.\n\
5. From the PowerShell prompt, go to the Functionbeat directory:',
- values: {
- directoryName: '`functionbeat-{config.kibana.version}-windows`',
- folderPath: '`C:\\Program Files`',
- functionbeatLink:
- '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
- elasticLink: 'https://www.elastic.co/downloads/beats/functionbeat',
- },
- }
- ),
- commands: ['cd "C:\\Program Files\\Functionbeat"'],
+ values: {
+ directoryName: '`functionbeat-{config.kibana.version}-windows`',
+ folderPath: '`C:\\Program Files`',
+ functionbeatLink:
+ '{config.docs.beats.functionbeat}/functionbeat-installation-configuration.html',
+ elasticLink: 'https://www.elastic.co/downloads/beats/functionbeat',
+ },
+ }
+ ),
+ commands: ['cd "C:\\Program Files\\Functionbeat"'],
+ },
},
- },
- DEPLOY: {
- OSX_LINUX: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.deploy.osxTitle', {
- defaultMessage: 'Deploy Functionbeat to AWS Lambda',
- }),
- textPre: i18n.translate('home.tutorials.common.functionbeatInstructions.deploy.osxTextPre', {
- defaultMessage:
- 'This installs Functionbeat as a Lambda function.\
+ DEPLOY: {
+ OSX_LINUX: {
+ title: i18n.translate('home.tutorials.common.functionbeatInstructions.deploy.osxTitle', {
+ defaultMessage: 'Deploy Functionbeat to AWS Lambda',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.deploy.osxTextPre',
+ {
+ defaultMessage:
+ 'This installs Functionbeat as a Lambda function.\
The `setup` command checks the Elasticsearch configuration and loads the \
Kibana index pattern. It is normally safe to omit this command.',
- }),
- commands: ['./functionbeat setup', './functionbeat deploy fn-cloudwatch-logs'],
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.deploy.windowsTitle', {
- defaultMessage: 'Deploy Functionbeat to AWS Lambda',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.deploy.windowsTextPre',
- {
- defaultMessage:
- 'This installs Functionbeat as a Lambda function.\
+ }
+ ),
+ commands: ['./functionbeat setup', './functionbeat deploy fn-cloudwatch-logs'],
+ },
+ WINDOWS: {
+ title: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.deploy.windowsTitle',
+ {
+ defaultMessage: 'Deploy Functionbeat to AWS Lambda',
+ }
+ ),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.deploy.windowsTextPre',
+ {
+ defaultMessage:
+ 'This installs Functionbeat as a Lambda function.\
The `setup` command checks the Elasticsearch configuration and loads the \
Kibana index pattern. It is normally safe to omit this command.',
- }
- ),
- commands: ['.\\functionbeat.exe setup', '.\\functionbeat.exe deploy fn-cloudwatch-logs'],
- },
- },
- CONFIG: {
- OSX_LINUX: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.config.osxTitle', {
- defaultMessage: 'Configure the Elastic cluster',
- }),
- textPre: i18n.translate('home.tutorials.common.functionbeatInstructions.config.osxTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`functionbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.config.osxTextPost',
- {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }
- ),
+ }
+ ),
+ commands: ['.\\functionbeat.exe setup', '.\\functionbeat.exe deploy fn-cloudwatch-logs'],
+ },
},
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.functionbeatInstructions.config.windowsTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.config.windowsTextPre',
- {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`C:\\Program Files\\Functionbeat\\functionbeat.yml`',
- },
- }
- ),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate(
- 'home.tutorials.common.functionbeatInstructions.config.windowsTextPost',
- {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }
- ),
+ CONFIG: {
+ OSX_LINUX: {
+ title: i18n.translate('home.tutorials.common.functionbeatInstructions.config.osxTitle', {
+ defaultMessage: 'Configure the Elastic cluster',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.config.osxTextPre',
+ {
+ defaultMessage: 'Modify {path} to set the connection information:',
+ values: {
+ path: '`functionbeat.yml`',
+ },
+ }
+ ),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.config.osxTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
+ WINDOWS: {
+ title: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.config.windowsTitle',
+ {
+ defaultMessage: 'Edit the configuration',
+ }
+ ),
+ textPre: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.config.windowsTextPre',
+ {
+ defaultMessage: 'Modify {path} to set the connection information:',
+ values: {
+ path: '`C:\\Program Files\\Functionbeat\\functionbeat.yml`',
+ },
+ }
+ ),
+ commands: [
+ 'output.elasticsearch:',
+ ' hosts: [""]',
+ ' username: "elastic"',
+ ' password: ""',
+ " # If using Elasticsearch's default certificate",
+ ' ssl.ca_trusted_fingerprint: ""',
+ 'setup.kibana:',
+ ' host: ""',
+ getSpaceIdForBeatsTutorial(context),
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.functionbeatInstructions.config.windowsTextPostMarkdown',
+ {
+ defaultMessage:
+ 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of \
+ Elasticsearch, and {kibanaUrlTemplate} is the URL of Kibana. To [configure SSL]({configureSslUrl}) with the \
+ default certificate generated by Elasticsearch, add its fingerprint in {esCertFingerprintTemplate}.',
+ values: {
+ passwordTemplate: '``',
+ esUrlTemplate: '``',
+ kibanaUrlTemplate: '``',
+ configureSslUrl: SSL_DOC_URL,
+ esCertFingerprintTemplate: '``',
+ },
+ }
+ ),
+ },
},
- },
-});
+ };
+};
export const createFunctionbeatCloudInstructions = () => ({
CONFIG: {
@@ -336,7 +368,7 @@ export function functionbeatStatusCheck() {
};
}
-export function onPremInstructions(platforms: Platform[], context?: TutorialContext) {
+export function onPremInstructions(platforms: Platform[], context: TutorialContext) {
const FUNCTIONBEAT_INSTRUCTIONS = createFunctionbeatInstructions(context);
return {
@@ -386,10 +418,10 @@ export function onPremInstructions(platforms: Platform[], context?: TutorialCont
};
}
-export function onPremCloudInstructions() {
+export function onPremCloudInstructions(context: TutorialContext) {
const TRYCLOUD_OPTION1 = createTrycloudOption1();
const TRYCLOUD_OPTION2 = createTrycloudOption2();
- const FUNCTIONBEAT_INSTRUCTIONS = createFunctionbeatInstructions();
+ const FUNCTIONBEAT_INSTRUCTIONS = createFunctionbeatInstructions(context);
return {
instructionSets: [
@@ -444,8 +476,8 @@ export function onPremCloudInstructions() {
};
}
-export function cloudInstructions() {
- const FUNCTIONBEAT_INSTRUCTIONS = createFunctionbeatInstructions();
+export function cloudInstructions(context: TutorialContext) {
+ const FUNCTIONBEAT_INSTRUCTIONS = createFunctionbeatInstructions(context);
const FUNCTIONBEAT_CLOUD_INSTRUCTIONS = createFunctionbeatCloudInstructions();
return {
diff --git a/src/plugins/home/server/tutorials/instructions/heartbeat_instructions.ts b/src/plugins/home/server/tutorials/instructions/heartbeat_instructions.ts
index ce3e76a5f827e..5cbd1641bf09a 100644
--- a/src/plugins/home/server/tutorials/instructions/heartbeat_instructions.ts
+++ b/src/plugins/home/server/tutorials/instructions/heartbeat_instructions.ts
@@ -13,247 +13,298 @@ import { getSpaceIdForBeatsTutorial } from './get_space_id_for_beats_tutorial';
import { Platform, TutorialContext } from '../../services/tutorials/lib/tutorials_registry_types';
import { cloudPasswordAndResetLink } from './cloud_instructions';
-export const createHeartbeatInstructions = (context?: TutorialContext) => ({
- INSTALL: {
- OSX: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.osxTitle', {
- defaultMessage: 'Download and install Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.osxTextPre', {
- defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
- values: { link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html' },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'tar xzvf heartbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
- 'cd heartbeat-{config.kibana.version}-darwin-x86_64/',
- ],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTitle', {
- defaultMessage: 'Download and install Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTextPre', {
- defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
- values: { link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html' },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-amd64.deb',
- 'sudo dpkg -i heartbeat-{config.kibana.version}-amd64.deb',
- ],
- textPost: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({link}).',
- values: { link: 'https://www.elastic.co/downloads/beats/heartbeat' },
- }),
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.rpmTitle', {
- defaultMessage: 'Download and install Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.rpmTextPre', {
- defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
- values: { link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html' },
- }),
- commands: [
- 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-x86_64.rpm',
- 'sudo rpm -vi heartbeat-{config.kibana.version}-x86_64.rpm',
- ],
- textPost: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTextPost', {
- defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({link}).',
- values: { link: 'https://www.elastic.co/downloads/beats/heartbeat' },
- }),
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.windowsTitle', {
- defaultMessage: 'Download and install Heartbeat',
- }),
- textPre: i18n.translate(
- 'home.tutorials.common.heartbeatInstructions.install.windowsTextPre',
- {
- defaultMessage:
- 'First time using Heartbeat? See the [Quick Start]({heartbeatLink}).\n\
+export const createHeartbeatInstructions = (context: TutorialContext) => {
+ const SSL_DOC_URL = `https://www.elastic.co/guide/en/beats/heartbeat/${context.kibanaBranch}/configuration-ssl.html#ca-sha256`;
+
+ return {
+ INSTALL: {
+ OSX: {
+ title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.osxTitle', {
+ defaultMessage: 'Download and install Heartbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.osxTextPre', {
+ defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
+ values: {
+ link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'tar xzvf heartbeat-{config.kibana.version}-darwin-x86_64.tar.gz',
+ 'cd heartbeat-{config.kibana.version}-darwin-x86_64/',
+ ],
+ },
+ DEB: {
+ title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTitle', {
+ defaultMessage: 'Download and install Heartbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.debTextPre', {
+ defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
+ values: {
+ link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-amd64.deb',
+ 'sudo dpkg -i heartbeat-{config.kibana.version}-amd64.deb',
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.heartbeatInstructions.install.debTextPost',
+ {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({link}).',
+ values: { link: 'https://www.elastic.co/downloads/beats/heartbeat' },
+ }
+ ),
+ },
+ RPM: {
+ title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.rpmTitle', {
+ defaultMessage: 'Download and install Heartbeat',
+ }),
+ textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.install.rpmTextPre', {
+ defaultMessage: 'First time using Heartbeat? See the [Quick Start]({link}).',
+ values: {
+ link: '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html',
+ },
+ }),
+ commands: [
+ 'curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-{config.kibana.version}-x86_64.rpm',
+ 'sudo rpm -vi heartbeat-{config.kibana.version}-x86_64.rpm',
+ ],
+ textPost: i18n.translate(
+ 'home.tutorials.common.heartbeatInstructions.install.debTextPost',
+ {
+ defaultMessage: 'Looking for the 32-bit packages? See the [Download page]({link}).',
+ values: { link: 'https://www.elastic.co/downloads/beats/heartbeat' },
+ }
+ ),
+ },
+ WINDOWS: {
+ title: i18n.translate('home.tutorials.common.heartbeatInstructions.install.windowsTitle', {
+ defaultMessage: 'Download and install Heartbeat',
+ }),
+ textPre: i18n.translate(
+ 'home.tutorials.common.heartbeatInstructions.install.windowsTextPre',
+ {
+ defaultMessage:
+ 'First time using Heartbeat? See the [Quick Start]({heartbeatLink}).\n\
1. Download the Heartbeat Windows zip file from the [Download]({elasticLink}) page.\n\
2. Extract the contents of the zip file into {folderPath}.\n\
3. Rename the {directoryName} directory to `Heartbeat`.\n\
4. Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select \
**Run As Administrator**). If you are running Windows XP, you might need to download and install PowerShell.\n\
5. From the PowerShell prompt, run the following commands to install Heartbeat as a Windows service.',
- values: {
- directoryName: '`heartbeat-{config.kibana.version}-windows`',
- folderPath: '`C:\\Program Files`',
- heartbeatLink:
- '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html',
- elasticLink: 'https://www.elastic.co/downloads/beats/heartbeat',
- },
- }
- ),
- commands: ['cd "C:\\Program Files\\Heartbeat"', '.\\install-service-heartbeat.ps1'],
- },
- },
- START: {
- OSX: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.start.osxTitle', {
- defaultMessage: 'Start Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.start.osxTextPre', {
- defaultMessage: 'The `setup` command loads the Kibana index pattern.',
- }),
- commands: ['./heartbeat setup', './heartbeat -e'],
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.start.debTitle', {
- defaultMessage: 'Start Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.start.debTextPre', {
- defaultMessage: 'The `setup` command loads the Kibana index pattern.',
- }),
- commands: ['sudo heartbeat setup', 'sudo service heartbeat-elastic start'],
- },
- RPM: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.start.rpmTitle', {
- defaultMessage: 'Start Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.start.rpmTextPre', {
- defaultMessage: 'The `setup` command loads the Kibana index pattern.',
- }),
- commands: ['sudo heartbeat setup', 'sudo service heartbeat-elastic start'],
- },
- WINDOWS: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.start.windowsTitle', {
- defaultMessage: 'Start Heartbeat',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.start.windowsTextPre', {
- defaultMessage: 'The `setup` command loads the Kibana index pattern.',
- }),
- commands: ['.\\heartbeat.exe setup', 'Start-Service heartbeat'],
- },
- },
- CONFIG: {
- OSX: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.config.osxTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.config.osxTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`heartbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.heartbeatInstructions.config.osxTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
- },
- DEB: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.config.debTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.config.debTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/heartbeat/heartbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: ""',
- getSpaceIdForBeatsTutorial(context),
- ],
- textPost: i18n.translate('home.tutorials.common.heartbeatInstructions.config.debTextPost', {
- defaultMessage:
- 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \
-and {kibanaUrlTemplate} is the URL of Kibana.',
- values: {
- passwordTemplate: '``',
- esUrlTemplate: '``',
- kibanaUrlTemplate: '``',
- },
- }),
+ values: {
+ directoryName: '`heartbeat-{config.kibana.version}-windows`',
+ folderPath: '`C:\\Program Files`',
+ heartbeatLink:
+ '{config.docs.beats.heartbeat}/heartbeat-installation-configuration.html',
+ elasticLink: 'https://www.elastic.co/downloads/beats/heartbeat',
+ },
+ }
+ ),
+ commands: ['cd "C:\\Program Files\\Heartbeat"', '.\\install-service-heartbeat.ps1'],
+ },
},
- RPM: {
- title: i18n.translate('home.tutorials.common.heartbeatInstructions.config.rpmTitle', {
- defaultMessage: 'Edit the configuration',
- }),
- textPre: i18n.translate('home.tutorials.common.heartbeatInstructions.config.rpmTextPre', {
- defaultMessage: 'Modify {path} to set the connection information:',
- values: {
- path: '`/etc/heartbeat/heartbeat.yml`',
- },
- }),
- commands: [
- 'output.elasticsearch:',
- ' hosts: [""]',
- ' username: "elastic"',
- ' password: ""',
- 'setup.kibana:',
- ' host: " |