;
+
+export interface DatasetSelectionStrategy {
+ toDataviewSpec(): DataViewSpec;
+ toURLSelectionId(): string;
+}
diff --git a/x-pack/plugins/discover_log_explorer/tsconfig.json b/x-pack/plugins/discover_log_explorer/tsconfig.json
index 8844db22796e5..babab6c97b029 100644
--- a/x-pack/plugins/discover_log_explorer/tsconfig.json
+++ b/x-pack/plugins/discover_log_explorer/tsconfig.json
@@ -13,6 +13,7 @@
"@kbn/kibana-utils-plugin",
"@kbn/io-ts-utils",
"@kbn/data-views-plugin",
+ "@kbn/rison",
],
"exclude": ["target/**/*"]
}
diff --git a/x-pack/plugins/enterprise_search/common/constants.ts b/x-pack/plugins/enterprise_search/common/constants.ts
index 38d9f256d0d4f..88290c2ed4831 100644
--- a/x-pack/plugins/enterprise_search/common/constants.ts
+++ b/x-pack/plugins/enterprise_search/common/constants.ts
@@ -150,7 +150,7 @@ export const APPLICATIONS_PLUGIN = {
export const VECTOR_SEARCH_PLUGIN = {
DESCRIPTION: i18n.translate('xpack.enterpriseSearch.vectorSearch.description', {
defaultMessage:
- 'Elasticsearch can be used as a vector database and search along with other semantic search methods.',
+ 'Elasticsearch can be used as a vector database, which enables vector search and semantic search use cases.',
}),
ID: 'enterpriseSearchVectorSearch',
LOGO: 'logoEnterpriseSearch',
@@ -210,3 +210,5 @@ export const DEFAULT_PRODUCT_FEATURES: ProductFeatures = {
hasNativeConnectors: true,
hasWebCrawler: true,
};
+
+export const CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX = '.search-acl-filter-';
diff --git a/x-pack/plugins/enterprise_search/common/types/kibana_deps.ts b/x-pack/plugins/enterprise_search/common/types/kibana_deps.ts
index 2bc2fed33aa4f..1e268aad1f73c 100644
--- a/x-pack/plugins/enterprise_search/common/types/kibana_deps.ts
+++ b/x-pack/plugins/enterprise_search/common/types/kibana_deps.ts
@@ -11,7 +11,6 @@ import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DiscoverStart } from '@kbn/discover-plugin/public';
import type { FeaturesPluginStart } from '@kbn/features-plugin/public';
import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
-import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
import type { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { SecurityPluginStart } from '@kbn/security-plugin/public';
import type { SharePluginStart } from '@kbn/share-plugin/public';
@@ -24,7 +23,6 @@ export interface KibanaDeps {
discover: DiscoverStart;
features: FeaturesPluginStart;
guidedOnboarding: GuidedOnboardingPluginStart;
- infra: InfraClientStartExports;
licensing: LicensingPluginStart;
security: SecurityPluginStart;
share: SharePluginStart;
diff --git a/x-pack/plugins/enterprise_search/kibana.jsonc b/x-pack/plugins/enterprise_search/kibana.jsonc
index 0a6d3ebee52ae..01e43542e84f7 100644
--- a/x-pack/plugins/enterprise_search/kibana.jsonc
+++ b/x-pack/plugins/enterprise_search/kibana.jsonc
@@ -17,7 +17,7 @@
"data",
"discover",
"charts",
- "infra",
+ "logsShared",
"cloud",
"esUiShared",
"guidedOnboarding",
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_configuration.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_configuration.tsx
index 81bd97840b190..9cd4802ed2be4 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_configuration.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_configuration.tsx
@@ -111,7 +111,7 @@ export const ConnectorConfiguration: React.FC = () => {
@@ -180,7 +180,7 @@ service_type: "${index.connector.service_type || 'changeme'}"
title: i18n.translate(
'xpack.enterpriseSearch.content.indices.configurationConnector.steps.deployConnector.title',
{
- defaultMessage: 'Deploy a connector',
+ defaultMessage: 'Deploy connector',
}
),
titleSize: 'xs',
@@ -325,7 +325,7 @@ service_type: "${index.connector.service_type || 'changeme'}"
'xpack.enterpriseSearch.content.indices.configurationConnector.support.description',
{
defaultMessage:
- 'Your connector will have to be deployed to your own infrastructure.',
+ 'You need to deploy this connector on your own infrastructure.',
}
)}
@@ -345,7 +345,7 @@ service_type: "${index.connector.service_type || 'changeme'}"
{i18n.translate(
'xpack.enterpriseSearch.content.indices.configurationConnector.support.manageKeys.label',
{
- defaultMessage: 'Manage keys',
+ defaultMessage: 'Manage API keys',
}
)}
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_scheduling/connector_cron_editor.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_scheduling/connector_cron_editor.tsx
index 46eccba6a4f70..9c38bdea220ca 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_scheduling/connector_cron_editor.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/connector_scheduling/connector_cron_editor.tsx
@@ -135,7 +135,7 @@ function cronToFrequency(cron: string): Frequency {
if (fields.length < 4) {
return 'YEAR';
}
- if (fields[1] === '*' || fields[1].startsWith('*/')) {
+ if (fields[1] === '*' || fields[1].includes(',')) {
return 'MINUTE';
}
if (fields[2] === '*') {
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx
index 8cf25e16426a8..ea1b1aaecd23f 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/documents.tsx
@@ -20,6 +20,8 @@ import {
import { i18n } from '@kbn/i18n';
+import { CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX } from '../../../../../common/constants';
+
import { KibanaLogic } from '../../../shared/kibana';
import {
@@ -44,7 +46,7 @@ export const SearchIndexDocuments: React.FC = () => {
const indexToShow =
selectedIndexType === 'content-index'
? indexName
- : indexName.replace('search-', '.search-acl-filter-');
+ : indexName.replace('search-', CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX);
const shouldShowAccessControlSwitcher =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx
index 4bc77672f5f7b..5ec31986b2fe4 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx
@@ -25,6 +25,8 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
+import { CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX } from '../../../../../common/constants';
+
import { docLinks } from '../../../shared/doc_links';
import { KibanaLogic } from '../../../shared/kibana';
@@ -51,7 +53,7 @@ export const SearchIndexIndexMappings: React.FC = () => {
const indexToShow =
selectedIndexType === 'content-index'
? indexName
- : indexName.replace('search-', '.search-acl-filter-');
+ : indexName.replace('search-', CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX);
const shouldShowAccessControlSwitch =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
diff --git a/x-pack/plugins/enterprise_search/public/applications/esre/components/esre_guide/esre_docs_section.tsx b/x-pack/plugins/enterprise_search/public/applications/esre/components/esre_guide/esre_docs_section.tsx
index df2bebd9fbfcc..279d707555cde 100644
--- a/x-pack/plugins/enterprise_search/public/applications/esre/components/esre_guide/esre_docs_section.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/esre/components/esre_guide/esre_docs_section.tsx
@@ -77,7 +77,7 @@ export const EsreDocsSection: React.FC = () => (
{i18n.translate('xpack.enterpriseSearch.esre.rrfRankingPanel.step1.rrfDocsLinkText', {
- defaultMessage: 'Reciprocal Rank Fusion documentations',
+ defaultMessage: 'Reciprocal Rank Fusion documentation',
})}
),
diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/__snapshots__/cron_editor.test.tsx.snap b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/__snapshots__/cron_editor.test.tsx.snap
index 2e22e3bfe30b0..d490f4f87057d 100644
--- a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/__snapshots__/cron_editor.test.tsx.snap
+++ b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/__snapshots__/cron_editor.test.tsx.snap
@@ -3391,241 +3391,21 @@ exports[`CronEditor is rendered with a MINUTE frequency 1`] = `
minute="10"
minuteOptions={
Array [
- Object {
- "text": "1",
- "value": "*/1",
- },
- Object {
- "text": "2",
- "value": "*/2",
- },
- Object {
- "text": "3",
- "value": "*/3",
- },
- Object {
- "text": "4",
- "value": "*/4",
- },
Object {
"text": "5",
- "value": "*/5",
- },
- Object {
- "text": "6",
- "value": "*/6",
- },
- Object {
- "text": "7",
- "value": "*/7",
- },
- Object {
- "text": "8",
- "value": "*/8",
- },
- Object {
- "text": "9",
- "value": "*/9",
+ "value": "0,5,10,15,20,25,30,35,40,45,50,55",
},
Object {
"text": "10",
- "value": "*/10",
- },
- Object {
- "text": "11",
- "value": "*/11",
- },
- Object {
- "text": "12",
- "value": "*/12",
- },
- Object {
- "text": "13",
- "value": "*/13",
- },
- Object {
- "text": "14",
- "value": "*/14",
+ "value": "0,10,20,30,40,50",
},
Object {
"text": "15",
- "value": "*/15",
- },
- Object {
- "text": "16",
- "value": "*/16",
- },
- Object {
- "text": "17",
- "value": "*/17",
- },
- Object {
- "text": "18",
- "value": "*/18",
- },
- Object {
- "text": "19",
- "value": "*/19",
- },
- Object {
- "text": "20",
- "value": "*/20",
- },
- Object {
- "text": "21",
- "value": "*/21",
- },
- Object {
- "text": "22",
- "value": "*/22",
- },
- Object {
- "text": "23",
- "value": "*/23",
- },
- Object {
- "text": "24",
- "value": "*/24",
- },
- Object {
- "text": "25",
- "value": "*/25",
- },
- Object {
- "text": "26",
- "value": "*/26",
- },
- Object {
- "text": "27",
- "value": "*/27",
- },
- Object {
- "text": "28",
- "value": "*/28",
- },
- Object {
- "text": "29",
- "value": "*/29",
+ "value": "0,15,30,45",
},
Object {
"text": "30",
- "value": "*/30",
- },
- Object {
- "text": "31",
- "value": "*/31",
- },
- Object {
- "text": "32",
- "value": "*/32",
- },
- Object {
- "text": "33",
- "value": "*/33",
- },
- Object {
- "text": "34",
- "value": "*/34",
- },
- Object {
- "text": "35",
- "value": "*/35",
- },
- Object {
- "text": "36",
- "value": "*/36",
- },
- Object {
- "text": "37",
- "value": "*/37",
- },
- Object {
- "text": "38",
- "value": "*/38",
- },
- Object {
- "text": "39",
- "value": "*/39",
- },
- Object {
- "text": "40",
- "value": "*/40",
- },
- Object {
- "text": "41",
- "value": "*/41",
- },
- Object {
- "text": "42",
- "value": "*/42",
- },
- Object {
- "text": "43",
- "value": "*/43",
- },
- Object {
- "text": "44",
- "value": "*/44",
- },
- Object {
- "text": "45",
- "value": "*/45",
- },
- Object {
- "text": "46",
- "value": "*/46",
- },
- Object {
- "text": "47",
- "value": "*/47",
- },
- Object {
- "text": "48",
- "value": "*/48",
- },
- Object {
- "text": "49",
- "value": "*/49",
- },
- Object {
- "text": "50",
- "value": "*/50",
- },
- Object {
- "text": "51",
- "value": "*/51",
- },
- Object {
- "text": "52",
- "value": "*/52",
- },
- Object {
- "text": "53",
- "value": "*/53",
- },
- Object {
- "text": "54",
- "value": "*/54",
- },
- Object {
- "text": "55",
- "value": "*/55",
- },
- Object {
- "text": "56",
- "value": "*/56",
- },
- Object {
- "text": "57",
- "value": "*/57",
- },
- Object {
- "text": "58",
- "value": "*/58",
- },
- Object {
- "text": "59",
- "value": "*/59",
+ "value": "0,30",
},
]
}
@@ -3690,241 +3470,21 @@ exports[`CronEditor is rendered with a MINUTE frequency 1`] = `
onFocus={[Function]}
options={
Array [
- Object {
- "text": "1",
- "value": "*/1",
- },
- Object {
- "text": "2",
- "value": "*/2",
- },
- Object {
- "text": "3",
- "value": "*/3",
- },
- Object {
- "text": "4",
- "value": "*/4",
- },
Object {
"text": "5",
- "value": "*/5",
- },
- Object {
- "text": "6",
- "value": "*/6",
- },
- Object {
- "text": "7",
- "value": "*/7",
- },
- Object {
- "text": "8",
- "value": "*/8",
- },
- Object {
- "text": "9",
- "value": "*/9",
+ "value": "0,5,10,15,20,25,30,35,40,45,50,55",
},
Object {
"text": "10",
- "value": "*/10",
- },
- Object {
- "text": "11",
- "value": "*/11",
- },
- Object {
- "text": "12",
- "value": "*/12",
- },
- Object {
- "text": "13",
- "value": "*/13",
- },
- Object {
- "text": "14",
- "value": "*/14",
+ "value": "0,10,20,30,40,50",
},
Object {
"text": "15",
- "value": "*/15",
- },
- Object {
- "text": "16",
- "value": "*/16",
- },
- Object {
- "text": "17",
- "value": "*/17",
- },
- Object {
- "text": "18",
- "value": "*/18",
- },
- Object {
- "text": "19",
- "value": "*/19",
- },
- Object {
- "text": "20",
- "value": "*/20",
- },
- Object {
- "text": "21",
- "value": "*/21",
- },
- Object {
- "text": "22",
- "value": "*/22",
- },
- Object {
- "text": "23",
- "value": "*/23",
- },
- Object {
- "text": "24",
- "value": "*/24",
- },
- Object {
- "text": "25",
- "value": "*/25",
- },
- Object {
- "text": "26",
- "value": "*/26",
- },
- Object {
- "text": "27",
- "value": "*/27",
- },
- Object {
- "text": "28",
- "value": "*/28",
- },
- Object {
- "text": "29",
- "value": "*/29",
+ "value": "0,15,30,45",
},
Object {
"text": "30",
- "value": "*/30",
- },
- Object {
- "text": "31",
- "value": "*/31",
- },
- Object {
- "text": "32",
- "value": "*/32",
- },
- Object {
- "text": "33",
- "value": "*/33",
- },
- Object {
- "text": "34",
- "value": "*/34",
- },
- Object {
- "text": "35",
- "value": "*/35",
- },
- Object {
- "text": "36",
- "value": "*/36",
- },
- Object {
- "text": "37",
- "value": "*/37",
- },
- Object {
- "text": "38",
- "value": "*/38",
- },
- Object {
- "text": "39",
- "value": "*/39",
- },
- Object {
- "text": "40",
- "value": "*/40",
- },
- Object {
- "text": "41",
- "value": "*/41",
- },
- Object {
- "text": "42",
- "value": "*/42",
- },
- Object {
- "text": "43",
- "value": "*/43",
- },
- Object {
- "text": "44",
- "value": "*/44",
- },
- Object {
- "text": "45",
- "value": "*/45",
- },
- Object {
- "text": "46",
- "value": "*/46",
- },
- Object {
- "text": "47",
- "value": "*/47",
- },
- Object {
- "text": "48",
- "value": "*/48",
- },
- Object {
- "text": "49",
- "value": "*/49",
- },
- Object {
- "text": "50",
- "value": "*/50",
- },
- Object {
- "text": "51",
- "value": "*/51",
- },
- Object {
- "text": "52",
- "value": "*/52",
- },
- Object {
- "text": "53",
- "value": "*/53",
- },
- Object {
- "text": "54",
- "value": "*/54",
- },
- Object {
- "text": "55",
- "value": "*/55",
- },
- Object {
- "text": "56",
- "value": "*/56",
- },
- Object {
- "text": "57",
- "value": "*/57",
- },
- Object {
- "text": "58",
- "value": "*/58",
- },
- Object {
- "text": "59",
- "value": "*/59",
+ "value": "0,30",
},
]
}
@@ -3970,358 +3530,28 @@ exports[`CronEditor is rendered with a MINUTE frequency 1`] = `
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
({
- value: '*/' + value.toString(),
- text: value.toString(),
-}));
+export const EVERY_MINUTE_OPTIONS = [
+ {
+ text: '5',
+ value: '0,5,10,15,20,25,30,35,40,45,50,55',
+ },
+ {
+ text: '10',
+ value: '0,10,20,30,40,50',
+ },
+ {
+ text: '15',
+ value: '0,15,30,45',
+ },
+ {
+ text: '30',
+ value: '0,30',
+ },
+];
export const MINUTE_OPTIONS = makeSequence(0, 59).map((value) => ({
value: value.toString(),
@@ -111,7 +125,7 @@ export const frequencyToFieldsMap: Record = {
export const frequencyToBaselineFieldsMap: Record = {
MINUTE: {
second: '0',
- minute: '*/1',
+ minute: '0,5,10,15,20,25,30,35,40,45,50,55',
hour: '*',
date: '*',
month: '*',
diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/cron_editor.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/cron_editor.tsx
index bcda5c37f33c7..ed27a69085d97 100644
--- a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/cron_editor.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/cron_editor.tsx
@@ -29,7 +29,6 @@ import { CronMonthly } from './cron_monthly';
import { CronWeekly } from './cron_weekly';
import { CronYearly } from './cron_yearly';
import { cronExpressionToParts, cronPartsToExpression } from './services';
-import { convertFromEveryXMinute, convertToEveryXMinute } from './services/cron';
import { Frequency, Field, FieldToValueMap } from './types';
const excludeBlockListedFrequencies = (
@@ -80,20 +79,14 @@ export class CronEditor extends Component {
}
onChangeFrequency = (frequency: Frequency) => {
- const { onChange, fieldToPreferredValueMap, frequency: oldFrequency } = this.props;
+ const { onChange, fieldToPreferredValueMap } = this.props;
// Update fields which aren't editable with acceptable baseline values.
const editableFields = Object.keys(frequencyToFieldsMap[frequency]) as Field[];
const inheritedFields = editableFields.reduce(
(fieldBaselines, field) => {
if (fieldToPreferredValueMap[field] != null) {
- if (oldFrequency === 'MINUTE') {
- fieldBaselines[field] = convertFromEveryXMinute(fieldToPreferredValueMap[field]);
- } else if (frequency === 'MINUTE') {
- fieldBaselines[field] = convertToEveryXMinute(fieldToPreferredValueMap[field]);
- } else {
- fieldBaselines[field] = fieldToPreferredValueMap[field];
- }
+ fieldBaselines[field] = fieldToPreferredValueMap[field];
}
return fieldBaselines;
},
diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/services/cron.ts b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/services/cron.ts
index fc2019d63c17d..542502fbcbe76 100644
--- a/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/services/cron.ts
+++ b/x-pack/plugins/enterprise_search/public/applications/shared/cron_editor/services/cron.ts
@@ -56,18 +56,3 @@ export function cronPartsToExpression({
}: FieldToValueMap): string {
return `${second} ${minute} ${hour} ${date} ${month} ${day}`;
}
-
-export function convertToEveryXMinute(
- minute: FieldToValueMap['minute']
-): FieldToValueMap['minute'] {
- if (!minute) return minute;
- if (minute.startsWith('*/')) return minute;
- return '*/' + minute;
-}
-
-export function convertFromEveryXMinute(
- minute: FieldToValueMap['minute']
-): FieldToValueMap['minute'] {
- if (!minute) return minute;
- return minute.startsWith('*/') ? minute.slice(2) : minute;
-}
diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx
index d655a7c57a971..5f3af9a500b9b 100644
--- a/x-pack/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx
@@ -7,17 +7,17 @@
import React from 'react';
-import { LogStream, LogStreamProps } from '@kbn/infra-plugin/public';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
+import { LogStream, LogStreamProps } from '@kbn/logs-shared-plugin/public';
/*
- * EnterpriseSearchLogStream is a light wrapper on top of infra's embeddable LogStream component.
+ * EnterpriseSearchLogStream is a light wrapper on top of logsShared's embeddable LogStream component.
* It prepopulates our log source ID (set in server/plugin.ts) and sets a basic 24-hours-ago
* default for timestamps. All other props get passed as-is to the underlying LogStream.
*
* Documentation links for reference:
- * - https://github.com/elastic/kibana/blob/main/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx
- * - Run `yarn storybook infra` for live docs
+ * - https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/components/log_stream/log_stream.stories.mdx
+ * - Run `yarn storybook logsShared` for live docs
*/
interface Props extends Omit {
diff --git a/x-pack/plugins/enterprise_search/public/applications/vector_search/components/vector_search_guide/vector_search_guide.tsx b/x-pack/plugins/enterprise_search/public/applications/vector_search/components/vector_search_guide/vector_search_guide.tsx
index 82b067962e448..1c14178b1583b 100644
--- a/x-pack/plugins/enterprise_search/public/applications/vector_search/components/vector_search_guide/vector_search_guide.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/vector_search/components/vector_search_guide/vector_search_guide.tsx
@@ -87,12 +87,12 @@ export const VectorSearchGuide: React.FC = () => {
{' '}
@@ -216,7 +216,7 @@ export const VectorSearchGuide: React.FC = () => {
description={
}
/>
@@ -235,7 +235,7 @@ export const VectorSearchGuide: React.FC = () => {
description={
}
/>
diff --git a/x-pack/plugins/enterprise_search/server/index.ts b/x-pack/plugins/enterprise_search/server/index.ts
index 704595b708c5e..2918641814341 100644
--- a/x-pack/plugins/enterprise_search/server/index.ts
+++ b/x-pack/plugins/enterprise_search/server/index.ts
@@ -53,4 +53,3 @@ export const CURRENT_CONNECTORS_INDEX = '.elastic-connectors-v1';
export const CONNECTORS_JOBS_INDEX = '.elastic-connectors-sync-jobs';
export const CONNECTORS_VERSION = 1;
export const CRAWLERS_INDEX = '.ent-search-actastic-crawler2_configurations_v2';
-export const CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX = '.search-acl-filter-';
diff --git a/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.test.ts b/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.test.ts
index ca7ae9fc76a66..4e35acd1434b4 100644
--- a/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.test.ts
+++ b/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.test.ts
@@ -7,11 +7,9 @@
import { IScopedClusterClient } from '@kbn/core/server';
-import {
- CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX,
- CONNECTORS_INDEX,
- CONNECTORS_JOBS_INDEX,
-} from '../..';
+import { CONNECTORS_INDEX, CONNECTORS_JOBS_INDEX } from '../..';
+import { CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX } from '../../../common/constants';
+
import { SyncJobType, SyncStatus, TriggerMethod } from '../../../common/types/connectors';
import { ErrorCode } from '../../../common/types/error_codes';
diff --git a/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.ts b/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.ts
index e4ef3288819f6..a3b2164c467a1 100644
--- a/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.ts
+++ b/x-pack/plugins/enterprise_search/server/lib/connectors/start_sync.ts
@@ -7,14 +7,13 @@
import { IScopedClusterClient } from '@kbn/core/server';
-import {
- CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX,
- CONNECTORS_INDEX,
- CONNECTORS_JOBS_INDEX,
-} from '../..';
+import { CONNECTORS_INDEX, CONNECTORS_JOBS_INDEX } from '../..';
import { isConfigEntry } from '../../../common/connectors/is_category_entry';
-import { ENTERPRISE_SEARCH_CONNECTOR_CRAWLER_SERVICE_TYPE } from '../../../common/constants';
+import {
+ CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX,
+ ENTERPRISE_SEARCH_CONNECTOR_CRAWLER_SERVICE_TYPE,
+} from '../../../common/constants';
import {
ConnectorConfiguration,
diff --git a/x-pack/plugins/enterprise_search/server/lib/indices/delete_access_control_index.ts b/x-pack/plugins/enterprise_search/server/lib/indices/delete_access_control_index.ts
new file mode 100644
index 0000000000000..3d185c9fde6f7
--- /dev/null
+++ b/x-pack/plugins/enterprise_search/server/lib/indices/delete_access_control_index.ts
@@ -0,0 +1,22 @@
+/*
+ * 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 { isIndexNotFoundException } from '@kbn/core-saved-objects-migration-server-internal';
+import { IScopedClusterClient } from '@kbn/core/server';
+
+import { CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX } from '../../../common/constants';
+
+export const deleteAccessControlIndex = async (client: IScopedClusterClient, index: string) => {
+ try {
+ await client.asCurrentUser.indices.delete({
+ index: index.replace('search-', CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX),
+ });
+ } catch (e) {
+ // Gracefully exit if index not found. This is a valid case.
+ if (!isIndexNotFoundException(e)) throw e;
+ }
+};
diff --git a/x-pack/plugins/enterprise_search/server/plugin.ts b/x-pack/plugins/enterprise_search/server/plugin.ts
index b072fbdf51503..041a295ff4831 100644
--- a/x-pack/plugins/enterprise_search/server/plugin.ts
+++ b/x-pack/plugins/enterprise_search/server/plugin.ts
@@ -21,7 +21,7 @@ import { DataPluginStart } from '@kbn/data-plugin/server/plugin';
import { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server';
import { GlobalSearchPluginSetup } from '@kbn/global-search-plugin/server';
import type { GuidedOnboardingPluginSetup } from '@kbn/guided-onboarding-plugin/server';
-import { InfraPluginSetup } from '@kbn/infra-plugin/server';
+import { LogsSharedPluginSetup } from '@kbn/logs-shared-plugin/server';
import type { MlPluginSetup } from '@kbn/ml-plugin/server';
import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/server';
import { SpacesPluginStart } from '@kbn/spaces-plugin/server';
@@ -88,7 +88,7 @@ interface PluginsSetup {
features: FeaturesPluginSetup;
globalSearch: GlobalSearchPluginSetup;
guidedOnboarding: GuidedOnboardingPluginSetup;
- infra: InfraPluginSetup;
+ logsShared: LogsSharedPluginSetup;
ml?: MlPluginSetup;
security: SecurityPluginSetup;
usageCollection?: UsageCollectionSetup;
@@ -125,7 +125,7 @@ export class EnterpriseSearchPlugin implements Plugin {
security,
features,
globalSearch,
- infra,
+ logsShared,
customIntegrations,
ml,
guidedOnboarding,
@@ -261,9 +261,9 @@ export class EnterpriseSearchPlugin implements Plugin {
/*
* Register logs source configuration, used by LogStream components
- * @see https://github.com/elastic/kibana/blob/main/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx#with-a-source-configuration
+ * @see https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/components/log_stream/log_stream.stories.mdx#with-a-source-configuration
*/
- infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID, {
+ logsShared.logViews.defineInternalLogView(ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID, {
logIndices: {
indexName: 'logs-app_search.search_relevance_suggestions-*',
type: 'index_name',
@@ -271,7 +271,7 @@ export class EnterpriseSearchPlugin implements Plugin {
name: 'Enterprise Search Search Relevance Logs',
});
- infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID, {
+ logsShared.logViews.defineInternalLogView(ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID, {
logIndices: {
indexName: 'logs-enterprise_search*',
type: 'index_name',
@@ -279,7 +279,7 @@ export class EnterpriseSearchPlugin implements Plugin {
name: 'Enterprise Search Audit Logs',
});
- infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID, {
+ logsShared.logViews.defineInternalLogView(ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID, {
logIndices: {
indexName: 'behavioral_analytics-events-*',
type: 'index_name',
diff --git a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts
index 81233d842d629..5b5a0c7e99b9b 100644
--- a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts
+++ b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts
@@ -26,6 +26,7 @@ import { fetchConnectorByIndexName, fetchConnectors } from '../../lib/connectors
import { fetchCrawlerByIndexName, fetchCrawlers } from '../../lib/crawler/fetch_crawlers';
import { createIndex } from '../../lib/indices/create_index';
+import { deleteAccessControlIndex } from '../../lib/indices/delete_access_control_index';
import { indexOrAliasExists } from '../../lib/indices/exists_index';
import { fetchIndex } from '../../lib/indices/fetch_index';
import { fetchIndices, fetchSearchIndices } from '../../lib/indices/fetch_indices';
@@ -201,6 +202,7 @@ export function registerIndexRoutes({
}
await deleteIndexPipelines(client, indexName);
+ await deleteAccessControlIndex(client, indexName);
await client.asCurrentUser.indices.delete({ index: indexName });
diff --git a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/mapping.ts b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/mapping.ts
index b963157694acf..0ce48c33a9d38 100644
--- a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/mapping.ts
+++ b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/mapping.ts
@@ -7,9 +7,13 @@
import { schema } from '@kbn/config-schema';
+import { ErrorCode } from '../../../common/types/error_codes';
+
import { fetchMapping } from '../../lib/fetch_mapping';
import { RouteDependencies } from '../../plugin';
+import { createError } from '../../utils/create_error';
import { elasticsearchErrorHandler } from '../../utils/elasticsearch_error_handler';
+import { isIndexNotFoundException } from '../../utils/identify_exceptions';
export function registerMappingRoute({ router, log }: RouteDependencies) {
router.get(
@@ -24,12 +28,24 @@ export function registerMappingRoute({ router, log }: RouteDependencies) {
elasticsearchErrorHandler(log, async (context, request, response) => {
const { client } = (await context.core).elasticsearch;
- const mapping = await fetchMapping(client, request.params.index_name);
+ try {
+ const mapping = await fetchMapping(client, request.params.index_name);
- return response.ok({
- body: mapping,
- headers: { 'content-type': 'application/json' },
- });
+ return response.ok({
+ body: mapping,
+ headers: { 'content-type': 'application/json' },
+ });
+ } catch (error) {
+ if (isIndexNotFoundException(error)) {
+ return createError({
+ errorCode: ErrorCode.INDEX_NOT_FOUND,
+ message: 'Could not found index',
+ response,
+ statusCode: 404,
+ });
+ }
+ throw error;
+ }
})
);
}
diff --git a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/search.ts b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/search.ts
index 3ea14a2013a59..40158204e3ea3 100644
--- a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/search.ts
+++ b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/search.ts
@@ -10,10 +10,13 @@ import { SearchResponseBody } from '@elastic/elasticsearch/lib/api/types';
import { schema } from '@kbn/config-schema';
import { ENTERPRISE_SEARCH_DOCUMENTS_DEFAULT_DOC_COUNT } from '../../../common/constants';
+import { ErrorCode } from '../../../common/types/error_codes';
import { fetchSearchResults } from '../../lib/fetch_search_results';
import { RouteDependencies } from '../../plugin';
+import { createError } from '../../utils/create_error';
import { elasticsearchErrorHandler } from '../../utils/elasticsearch_error_handler';
+import { isIndexNotFoundException } from '../../utils/identify_exceptions';
const calculateMeta = (searchResults: SearchResponseBody, page: number, size: number) => {
let totalResults = 0;
@@ -64,21 +67,33 @@ export function registerSearchRoute({ router, log }: RouteDependencies) {
const { client } = (await context.core).elasticsearch;
const { page = 0, size = ENTERPRISE_SEARCH_DOCUMENTS_DEFAULT_DOC_COUNT } = request.query;
const from = page * size;
- const searchResults: SearchResponseBody = await fetchSearchResults(
- client,
- indexName,
- searchQuery,
- from,
- size
- );
+ try {
+ const searchResults: SearchResponseBody = await fetchSearchResults(
+ client,
+ indexName,
+ searchQuery,
+ from,
+ size
+ );
- return response.ok({
- body: {
- meta: calculateMeta(searchResults, page, size),
- results: searchResults,
- },
- headers: { 'content-type': 'application/json' },
- });
+ return response.ok({
+ body: {
+ meta: calculateMeta(searchResults, page, size),
+ results: searchResults,
+ },
+ headers: { 'content-type': 'application/json' },
+ });
+ } catch (error) {
+ if (isIndexNotFoundException(error)) {
+ return createError({
+ errorCode: ErrorCode.INDEX_NOT_FOUND,
+ message: 'Could not found index',
+ response,
+ statusCode: 404,
+ });
+ }
+ throw error;
+ }
})
);
}
diff --git a/x-pack/plugins/enterprise_search/tsconfig.json b/x-pack/plugins/enterprise_search/tsconfig.json
index 0ea008f3691f5..39758cb511103 100644
--- a/x-pack/plugins/enterprise_search/tsconfig.json
+++ b/x-pack/plugins/enterprise_search/tsconfig.json
@@ -22,7 +22,6 @@
"@kbn/usage-collection-plugin",
"@kbn/cloud-plugin",
"@kbn/cloud-chat-plugin",
- "@kbn/infra-plugin",
"@kbn/features-plugin",
"@kbn/lens-plugin",
"@kbn/licensing-plugin",
@@ -60,6 +59,8 @@
"@kbn/core-elasticsearch-server-mocks",
"@kbn/shared-ux-link-redirect-app",
"@kbn/global-search-plugin",
+ "@kbn/logs-shared-plugin",
"@kbn/share-plugin",
+ "@kbn/core-saved-objects-migration-server-internal",
]
}
diff --git a/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.test.ts b/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.test.ts
new file mode 100644
index 0000000000000..3b4c340488572
--- /dev/null
+++ b/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.test.ts
@@ -0,0 +1,33 @@
+/*
+ * 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 type { ChromeBreadcrumb } from '@kbn/core/public';
+import { emptyLastBreadcrumbUrl } from './breadcrumbs';
+
+describe('emptyLastBreadcrumbUrl', () => {
+ it('should empty the URL and onClick function of the last breadcrumb', () => {
+ const breadcrumbs: ChromeBreadcrumb[] = [
+ { text: 'Home', href: '/home', onClick: () => {} },
+ { text: 'Breadcrumb 1', href: '/bc1', onClick: () => {} },
+ { text: 'Last Breadcrumbs', href: '/last_bc', onClick: () => {} },
+ ];
+
+ const expectedBreadcrumbs = [
+ { text: 'Home', href: '/home', onClick: breadcrumbs[0].onClick },
+ { text: 'Breadcrumb 1', href: '/bc1', onClick: breadcrumbs[1].onClick },
+ { text: 'Last Breadcrumbs', href: '', onClick: undefined },
+ ];
+
+ expect(emptyLastBreadcrumbUrl(breadcrumbs)).toEqual(expectedBreadcrumbs);
+ });
+
+ it('should return the original breadcrumbs if the input is empty', () => {
+ const emptyBreadcrumbs: ChromeBreadcrumb[] = [];
+
+ expect(emptyLastBreadcrumbUrl(emptyBreadcrumbs)).toEqual(emptyBreadcrumbs);
+ });
+});
diff --git a/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.ts b/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.ts
new file mode 100644
index 0000000000000..8fa8107226f4c
--- /dev/null
+++ b/x-pack/plugins/ess_security/public/breadcrumbs/breadcrumbs.ts
@@ -0,0 +1,29 @@
+/*
+ * 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 type { PluginStart as SecuritySolutionPluginStart } from '@kbn/security-solution-plugin/public';
+import { ChromeBreadcrumb, CoreStart } from '@kbn/core/public';
+
+export const subscribeBreadcrumbs = (
+ securitySolution: SecuritySolutionPluginStart,
+ core: CoreStart
+) => {
+ securitySolution.getBreadcrumbsNav$().subscribe((breadcrumbsNav) => {
+ const breadcrumbs = [...breadcrumbsNav.leading, ...breadcrumbsNav.trailing];
+ if (breadcrumbs.length > 0) {
+ core.chrome.setBreadcrumbs(emptyLastBreadcrumbUrl(breadcrumbs));
+ }
+ });
+};
+
+export const emptyLastBreadcrumbUrl = (breadcrumbs: ChromeBreadcrumb[]) => {
+ const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
+ if (lastBreadcrumb) {
+ return [...breadcrumbs.slice(0, -1), { ...lastBreadcrumb, href: '', onClick: undefined }];
+ }
+ return breadcrumbs;
+};
diff --git a/x-pack/plugins/ess_security/public/breadcrumbs/index.ts b/x-pack/plugins/ess_security/public/breadcrumbs/index.ts
new file mode 100644
index 0000000000000..e1ed7fcff0986
--- /dev/null
+++ b/x-pack/plugins/ess_security/public/breadcrumbs/index.ts
@@ -0,0 +1,7 @@
+/*
+ * 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.
+ */
+export { subscribeBreadcrumbs } from './breadcrumbs';
diff --git a/x-pack/plugins/ess_security/public/common/jest.config.js b/x-pack/plugins/ess_security/public/common/jest.config.js
deleted file mode 100644
index ae6cd807e4cc1..0000000000000
--- a/x-pack/plugins/ess_security/public/common/jest.config.js
+++ /dev/null
@@ -1,26 +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.
- */
-
-module.exports = {
- preset: '@kbn/test',
- rootDir: '../../../../..',
- roots: ['/x-pack/plugins/ess_security/public/common'],
- testMatch: ['/x-pack/plugins/ess_security/public/common/**/*.test.{js,mjs,ts,tsx}'],
- coverageDirectory:
- '/target/kibana-coverage/jest/x-pack/plugins/ess_security/public/common',
- coverageReporters: ['text', 'html'],
- collectCoverageFrom: [
- '/x-pack/plugins/ess_security/public/common/**/*.{ts,tsx}',
- '!/x-pack/plugins/ess_security/public/common/*.test.{ts,tsx}',
- '!/x-pack/plugins/ess_security/public/common/{__test__,__snapshots__,__examples__,*mock*,tests,test_helpers,integration_tests,types}/**/*',
- '!/x-pack/plugins/ess_security/public/common/*mock*.{ts,tsx}',
- '!/x-pack/plugins/ess_security/public/common/*.test.{ts,tsx}',
- '!/x-pack/plugins/ess_security/public/common/*.d.ts',
- '!/x-pack/plugins/ess_security/public/common/*.config.ts',
- '!/x-pack/plugins/ess_security/public/common/index.{js,ts,tsx}',
- ],
-};
diff --git a/x-pack/plugins/ess_security/public/jest.config.js b/x-pack/plugins/ess_security/public/jest.config.js
index 2bdbadf77ba18..ffee6062ec59b 100644
--- a/x-pack/plugins/ess_security/public/jest.config.js
+++ b/x-pack/plugins/ess_security/public/jest.config.js
@@ -8,7 +8,7 @@ module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
/** all nested directories have their own Jest config file */
- testMatch: ['/x-pack/plugins/ess_security/public/*.test.{js,mjs,ts,tsx}'],
+ testMatch: ['/x-pack/plugins/ess_security/public/**/*.test.{js,mjs,ts,tsx}'],
roots: ['/x-pack/plugins/ess_security/public'],
coverageDirectory: '/target/kibana-coverage/jest/x-pack/plugins/ess_security/public',
coverageReporters: ['text', 'html'],
diff --git a/x-pack/plugins/ess_security/public/plugin.ts b/x-pack/plugins/ess_security/public/plugin.ts
index a87744e00ffcd..52d75c01f8119 100644
--- a/x-pack/plugins/ess_security/public/plugin.ts
+++ b/x-pack/plugins/ess_security/public/plugin.ts
@@ -6,6 +6,7 @@
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
+import { subscribeBreadcrumbs } from './breadcrumbs';
import { getSecurityGetStartedComponent } from './get_started';
import {
EssSecurityPluginSetup,
@@ -26,8 +27,8 @@ export class EssSecurityPlugin
constructor() {}
public setup(
- core: CoreSetup,
- setupDeps: EssSecurityPluginSetupDependencies
+ _core: CoreSetup,
+ _setupDeps: EssSecurityPluginSetupDependencies
): EssSecurityPluginSetup {
return {};
}
@@ -37,6 +38,8 @@ export class EssSecurityPlugin
startDeps: EssSecurityPluginStartDependencies
): EssSecurityPluginStart {
const { securitySolution } = startDeps;
+
+ subscribeBreadcrumbs(securitySolution, core);
securitySolution.setGetStartedPage(getSecurityGetStartedComponent(core, startDeps));
return {};
diff --git a/x-pack/plugins/fleet/common/constants/file_storage.ts b/x-pack/plugins/fleet/common/constants/file_storage.ts
index 554176f40e263..0d796d691b97b 100644
--- a/x-pack/plugins/fleet/common/constants/file_storage.ts
+++ b/x-pack/plugins/fleet/common/constants/file_storage.ts
@@ -8,26 +8,26 @@
// File storage indexes supporting file upload from the host to Elastic/Kibana
// If needing to get an integration specific index name, use the utility functions
// found in `common/services/file_storage`
-export const FILE_STORAGE_METADATA_INDEX_PATTERN = '.fleet-files-*';
-export const FILE_STORAGE_DATA_INDEX_PATTERN = '.fleet-file-data-*';
+export const FILE_STORAGE_METADATA_INDEX_PATTERN = '.fleet-fileds-fromhost-meta-*';
+export const FILE_STORAGE_DATA_INDEX_PATTERN = '.fleet-fileds-fromhost-data-*';
-// File storage indexes supporting user uplaoded files (via kibana) that will be
+// File storage indexes supporting user uploaded files (via kibana) that will be
// delivered to the host agent/endpoint
-export const FILE_STORAGE_TO_HOST_METADATA_INDEX_PATTERN = '.fleet-filedelivery-meta-*';
-export const FILE_STORAGE_TO_HOST_DATA_INDEX_PATTERN = '.fleet-filedelivery-data-*';
+export const FILE_STORAGE_TO_HOST_METADATA_INDEX_PATTERN = '.fleet-fileds-tohost-meta-*';
+export const FILE_STORAGE_TO_HOST_DATA_INDEX_PATTERN = '.fleet-fileds-tohost-data-*';
// which integrations support file upload and the name to use for the file upload index
export const FILE_STORAGE_INTEGRATION_INDEX_NAMES: Readonly<
Record<
string,
- {
+ Readonly<{
/** name to be used for the index */
name: string;
/** If integration supports files sent from host to ES/Kibana */
fromHost: boolean;
/** If integration supports files to be sent to host from kibana */
toHost: boolean;
- }
+ }>
>
> = {
elastic_agent: { name: 'agent', fromHost: true, toHost: false },
diff --git a/x-pack/plugins/fleet/common/services/file_storage.test.ts b/x-pack/plugins/fleet/common/services/file_storage.test.ts
index 0360d7311eb6a..dbf5da61dba1d 100644
--- a/x-pack/plugins/fleet/common/services/file_storage.test.ts
+++ b/x-pack/plugins/fleet/common/services/file_storage.test.ts
@@ -5,24 +5,41 @@
* 2.0.
*/
+import { FILE_STORAGE_METADATA_INDEX_PATTERN } from '../constants';
+
import { getFileDataIndexName, getFileMetadataIndexName } from '..';
+import { getIntegrationNameFromIndexName } from './file_storage';
+
describe('File Storage services', () => {
describe('File Index Names', () => {
it('should generate file metadata index name for files received from host', () => {
- expect(getFileMetadataIndexName('foo')).toEqual('.fleet-files-foo');
+ expect(getFileMetadataIndexName('foo')).toEqual('.fleet-fileds-fromhost-meta-foo');
});
it('should generate file data index name for files received from host', () => {
- expect(getFileDataIndexName('foo')).toEqual('.fleet-file-data-foo');
+ expect(getFileDataIndexName('foo')).toEqual('.fleet-fileds-fromhost-data-foo');
});
it('should generate file metadata index name for files to be delivered to host', () => {
- expect(getFileMetadataIndexName('foo', true)).toEqual('.fleet-filedelivery-meta-foo');
+ expect(getFileMetadataIndexName('foo', true)).toEqual('.fleet-fileds-tohost-meta-foo');
});
it('should generate file data index name for files to be delivered to host', () => {
- expect(getFileDataIndexName('foo', true)).toEqual('.fleet-filedelivery-data-foo');
+ expect(getFileDataIndexName('foo', true)).toEqual('.fleet-fileds-tohost-data-foo');
+ });
+ });
+
+ describe('getIntegrationNameFromIndexName()', () => {
+ it.each([
+ ['regular index names', '.fleet-fileds-fromhost-meta-agent'],
+ ['datastream index names', '.ds-.fleet-fileds-fromhost-data-agent-2023.06.30-00001'],
+ ])('should handle %s', (_, index) => {
+ expect(getIntegrationNameFromIndexName(index, FILE_STORAGE_METADATA_INDEX_PATTERN)).toEqual(
+ 'agent'
+ );
});
+
+ it.todo('should error if index pattern does not include `*`');
});
});
diff --git a/x-pack/plugins/fleet/common/services/file_storage.ts b/x-pack/plugins/fleet/common/services/file_storage.ts
index 6581f671df663..af909a22aa946 100644
--- a/x-pack/plugins/fleet/common/services/file_storage.ts
+++ b/x-pack/plugins/fleet/common/services/file_storage.ts
@@ -56,21 +56,19 @@ export const getFileDataIndexName = (
);
};
-/**
- * Returns the write index name for a given file upload alias name, this is the same for metadata and chunks
- * @param aliasName
- */
-export const getFileWriteIndexName = (aliasName: string) => aliasName + '-000001';
/**
* Returns back the integration name for a given File Data (chunks) index name.
*
* @example
- * // Given a File data index pattern of `.fleet-file-data-*`:
+ * // Given a File data index pattern of `.fleet-fileds-fromhost-data-*`:
*
- * getIntegrationNameFromFileDataIndexName('.fleet-file-data-agent');
+ * getIntegrationNameFromFileDataIndexName('.fleet-fileds-fromhost-data-agent');
* // return 'agent'
*
- * getIntegrationNameFromFileDataIndexName('.fleet-file-data-agent-00001');
+ * getIntegrationNameFromFileDataIndexName('.ds-.fleet-fileds-fromhost-data-agent');
+ * // return 'agent'
+ *
+ * getIntegrationNameFromFileDataIndexName('.ds-.fleet-fileds-fromhost-data-agent-2023.06.30-00001');
* // return 'agent'
*/
export const getIntegrationNameFromFileDataIndexName = (indexName: string): string => {
@@ -87,7 +85,7 @@ export const getIntegrationNameFromIndexName = (
throw new Error(`Unable to parse index name. No '*' in index pattern: ${indexPattern}`);
}
- const indexPieces = indexName.split('-');
+ const indexPieces = indexName.replace(/^\.ds-/, '').split('-');
if (indexPieces[integrationNameIndexPosition]) {
return indexPieces[integrationNameIndexPosition];
@@ -95,15 +93,3 @@ export const getIntegrationNameFromIndexName = (
throw new Error(`Index name ${indexName} does not seem to be a File storage index`);
};
-
-export const getFileStorageWriteIndexBody = (aliasName: string) => ({
- aliases: {
- [aliasName]: {
- is_write_index: true,
- },
- },
- settings: {
- 'index.lifecycle.rollover_alias': aliasName,
- 'index.hidden': true,
- },
-});
diff --git a/x-pack/plugins/fleet/kibana.jsonc b/x-pack/plugins/fleet/kibana.jsonc
index f86c939456445..f0b01080db22d 100644
--- a/x-pack/plugins/fleet/kibana.jsonc
+++ b/x-pack/plugins/fleet/kibana.jsonc
@@ -40,7 +40,7 @@
"kibanaReact",
"cloudChat",
"esUiShared",
- "infra",
+ "logsShared",
"kibanaUtils",
"usageCollection",
"unifiedSearch"
diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx
index 4af6b30c99fb4..e6dae29cea881 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx
@@ -30,7 +30,7 @@ import semverCoerce from 'semver/functions/coerce';
import { createStateContainerReactHelpers } from '@kbn/kibana-utils-plugin/public';
import { RedirectAppLinks } from '@kbn/kibana-react-plugin/public';
import type { TimeRange } from '@kbn/es-query';
-import { LogStream, type LogStreamProps } from '@kbn/infra-plugin/public';
+import { LogStream, type LogStreamProps } from '@kbn/logs-shared-plugin/public';
import type { Agent, AgentPolicy } from '../../../../../types';
import { useLink, useStartServices } from '../../../../../hooks';
diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/assets/assets.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/assets/assets.tsx
index b9a023bef1ef7..2f6e20f097601 100644
--- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/assets/assets.tsx
+++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/assets/assets.tsx
@@ -46,7 +46,7 @@ export const AssetsPage = ({ packageInfo }: AssetsPanelProps) => {
const { spaces } = useStartServices();
const customAssetsExtension = useUIExtension(packageInfo.name, 'package-detail-assets');
- const canReadPackageSettings = useAuthz().integrations.readPackageSettings;
+ const canReadPackageSettings = useAuthz().integrations.readPackageInfo;
const { getPath } = useLink();
const getPackageInstallStatus = useGetPackageInstallStatus();
diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
index f5ef34d28b5c4..1780d3e55169a 100644
--- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
+++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts
@@ -11,18 +11,9 @@ import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import type { IndicesCreateRequest } from '@elastic/elasticsearch/lib/api/types';
-import {
- FILE_STORAGE_INTEGRATION_INDEX_NAMES,
- FILE_STORAGE_INTEGRATION_NAMES,
-} from '../../../../../common/constants';
-
import { ElasticsearchAssetType } from '../../../../types';
import {
- getFileWriteIndexName,
- getFileStorageWriteIndexBody,
getPipelineNameForDatastream,
- getFileDataIndexName,
- getFileMetadataIndexName,
getRegistryDataStreamAssetBaseName,
} from '../../../../../common/services';
import type {
@@ -440,63 +431,6 @@ export async function ensureDefaultComponentTemplates(
);
}
-/*
- * Given a list of integration names, if the integrations support file upload
- * then ensure that the alias has a matching write index, as we use "plain" indices
- * not data streams.
- * e.g .fleet-file-data-agent must have .fleet-file-data-agent-00001 as the write index
- * before files can be uploaded.
- */
-export async function ensureFileUploadWriteIndices(opts: {
- esClient: ElasticsearchClient;
- logger: Logger;
- integrationNames: string[];
-}) {
- const { esClient, logger, integrationNames } = opts;
-
- const integrationsWithFileUpload = integrationNames.filter((integration) =>
- FILE_STORAGE_INTEGRATION_NAMES.includes(integration as any)
- );
-
- if (!integrationsWithFileUpload.length) return [];
-
- const ensure = (aliasName: string) =>
- ensureAliasHasWriteIndex({
- esClient,
- logger,
- aliasName,
- writeIndexName: getFileWriteIndexName(aliasName),
- body: getFileStorageWriteIndexBody(aliasName),
- });
-
- return Promise.all(
- integrationsWithFileUpload.flatMap((integrationName) => {
- const {
- name: indexName,
- fromHost,
- toHost,
- } = FILE_STORAGE_INTEGRATION_INDEX_NAMES[integrationName];
- const indexCreateRequests: Array> = [];
-
- if (fromHost) {
- indexCreateRequests.push(
- ensure(getFileDataIndexName(indexName)),
- ensure(getFileMetadataIndexName(indexName))
- );
- }
-
- if (toHost) {
- indexCreateRequests.push(
- ensure(getFileDataIndexName(indexName, true)),
- ensure(getFileMetadataIndexName(indexName, true))
- );
- }
-
- return indexCreateRequests;
- })
- );
-}
-
export async function ensureComponentTemplate(
esClient: ElasticsearchClient,
logger: Logger,
diff --git a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts
index b884e8c893de8..a5b4ad6f4e00b 100644
--- a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts
+++ b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts
@@ -37,7 +37,6 @@ import type {
PackageVerificationResult,
IndexTemplateEntry,
} from '../../../types';
-import { ensureFileUploadWriteIndices } from '../elasticsearch/template/install';
import { removeLegacyTemplates } from '../elasticsearch/template/remove_legacy';
import { isTopLevelPipeline, deletePreviousPipelines } from '../elasticsearch/ingest_pipeline';
import { installILMPolicy } from '../elasticsearch/ilm/install';
@@ -236,15 +235,6 @@ export async function _installPackage({
logger.warn(`Error removing legacy templates: ${e.message}`);
}
- const { diagnosticFileUploadEnabled } = appContextService.getExperimentalFeatures();
- if (diagnosticFileUploadEnabled) {
- await ensureFileUploadWriteIndices({
- integrationNames: [packageInfo.name],
- esClient,
- logger,
- });
- }
-
// update current backing indices of each data stream
await withPackageSpan('Update write indices', () =>
updateCurrentWriteIndices(esClient, logger, indexTemplates)
diff --git a/x-pack/plugins/fleet/server/services/files/client_from_host.test.ts b/x-pack/plugins/fleet/server/services/files/client_from_host.test.ts
index 068bad018b5e8..0051418b1c00d 100644
--- a/x-pack/plugins/fleet/server/services/files/client_from_host.test.ts
+++ b/x-pack/plugins/fleet/server/services/files/client_from_host.test.ts
@@ -91,11 +91,11 @@ describe('FleetFromHostFilesClient', () => {
esClientMock.search.mockImplementation(async (searchRequest = {}) => {
// File metadata
- if ((searchRequest.index as string).startsWith('.fleet-files-')) {
+ if ((searchRequest.index as string).startsWith('.fleet-fileds-fromhost-meta-')) {
return fleetFilesIndexSearchResponse;
}
- if ((searchRequest.index as string).startsWith('.fleet-file-data-')) {
+ if ((searchRequest.index as string).startsWith('.fleet-fileds-fromhost-data-')) {
return fleetFileDataIndexSearchResponse;
}
@@ -111,8 +111,8 @@ describe('FleetFromHostFilesClient', () => {
expect(createEsFileClientMock).toHaveBeenCalledWith({
elasticsearchClient: esClientMock,
logger: loggerMock,
- metadataIndex: '.fleet-files-foo',
- blobStorageIndex: '.fleet-file-data-foo',
+ metadataIndex: '.fleet-fileds-fromhost-meta-foo',
+ blobStorageIndex: '.fleet-fileds-fromhost-data-foo',
indexIsAlias: true,
});
});
@@ -159,7 +159,7 @@ describe('FleetFromHostFilesClient', () => {
},
},
},
- index: '.fleet-file-data-foo',
+ index: '.fleet-fileds-fromhost-data-foo',
size: 0,
});
});
diff --git a/x-pack/plugins/fleet/server/services/files/client_to_host.test.ts b/x-pack/plugins/fleet/server/services/files/client_to_host.test.ts
index a4820f256da95..1068f34366970 100644
--- a/x-pack/plugins/fleet/server/services/files/client_to_host.test.ts
+++ b/x-pack/plugins/fleet/server/services/files/client_to_host.test.ts
@@ -130,8 +130,8 @@ describe('FleetToHostFilesClient', () => {
expect(createEsFileClientMock).toHaveBeenCalledWith({
elasticsearchClient: esClientMock,
logger: loggerMock,
- metadataIndex: '.fleet-filedelivery-meta-foo',
- blobStorageIndex: '.fleet-filedelivery-data-foo',
+ metadataIndex: '.fleet-fileds-tohost-meta-foo',
+ blobStorageIndex: '.fleet-fileds-tohost-data-foo',
maxSizeBytes: 12345,
indexIsAlias: true,
});
diff --git a/x-pack/plugins/fleet/server/services/files/index.ts b/x-pack/plugins/fleet/server/services/files/index.ts
index 5790164b81d07..8d6cbdb9fd5a4 100644
--- a/x-pack/plugins/fleet/server/services/files/index.ts
+++ b/x-pack/plugins/fleet/server/services/files/index.ts
@@ -34,22 +34,27 @@ export async function getFilesByStatus(
abortController: AbortController,
status: FileStatus = 'READY'
): Promise {
- const result = await esClient.search(
- {
- index: FILE_STORAGE_METADATA_INDEX_PATTERN,
- body: {
- size: ES_SEARCH_LIMIT,
- query: {
- term: {
- 'file.Status': status,
+ const result = await esClient
+ .search(
+ {
+ index: FILE_STORAGE_METADATA_INDEX_PATTERN,
+ body: {
+ size: ES_SEARCH_LIMIT,
+ query: {
+ term: {
+ 'file.Status': status,
+ },
},
+ _source: false,
},
- _source: false,
+ ignore_unavailable: true,
},
- ignore_unavailable: true,
- },
- { signal: abortController.signal }
- );
+ { signal: abortController.signal }
+ )
+ .catch((err) => {
+ Error.captureStackTrace(err);
+ throw err;
+ });
return result.hits.hits;
}
@@ -84,32 +89,37 @@ export async function fileIdsWithoutChunksByIndex(
return acc;
}, {} as FileIdsByIndex);
- const chunks = await esClient.search<{ bid: string }>(
- {
- index: FILE_STORAGE_DATA_INDEX_PATTERN,
- body: {
- size: ES_SEARCH_LIMIT,
- query: {
- bool: {
- must: [
- {
- terms: {
- bid: Array.from(allFileIds),
+ const chunks = await esClient
+ .search<{ bid: string }>(
+ {
+ index: FILE_STORAGE_DATA_INDEX_PATTERN,
+ body: {
+ size: ES_SEARCH_LIMIT,
+ query: {
+ bool: {
+ must: [
+ {
+ terms: {
+ bid: Array.from(allFileIds),
+ },
},
- },
- {
- term: {
- last: true,
+ {
+ term: {
+ last: true,
+ },
},
- },
- ],
+ ],
+ },
},
+ _source: ['bid'],
},
- _source: ['bid'],
},
- },
- { signal: abortController.signal }
- );
+ { signal: abortController.signal }
+ )
+ .catch((err) => {
+ Error.captureStackTrace(err);
+ throw err;
+ });
chunks.hits.hits.forEach((hit) => {
const fileId = hit._source?.bid;
@@ -140,22 +150,27 @@ export function updateFilesStatus(
): Promise {
return Promise.all(
Object.entries(fileIdsByIndex).map(([index, fileIds]) => {
- return esClient.updateByQuery(
- {
- index,
- refresh: true,
- query: {
- ids: {
- values: Array.from(fileIds),
+ return esClient
+ .updateByQuery(
+ {
+ index,
+ refresh: true,
+ query: {
+ ids: {
+ values: Array.from(fileIds),
+ },
+ },
+ script: {
+ source: `ctx._source.file.Status = '${status}'`,
+ lang: 'painless',
},
},
- script: {
- source: `ctx._source.file.Status = '${status}'`,
- lang: 'painless',
- },
- },
- { signal: abortController.signal }
- );
+ { signal: abortController.signal }
+ )
+ .catch((err) => {
+ Error.captureStackTrace(err);
+ throw err;
+ });
})
);
}
diff --git a/x-pack/plugins/fleet/server/services/files/mocks.ts b/x-pack/plugins/fleet/server/services/files/mocks.ts
index 35c276bf5cae7..23c0482b7e111 100644
--- a/x-pack/plugins/fleet/server/services/files/mocks.ts
+++ b/x-pack/plugins/fleet/server/services/files/mocks.ts
@@ -86,7 +86,7 @@ export const createFromHostEsSearchResponseMock =
max_score: 0,
hits: [
{
- _index: '.fleet-files-foo-000001',
+ _index: '.fleet-fileds-fromhost-meta-foo-000001',
_id: '123',
_score: 1.0,
_source: {
diff --git a/x-pack/plugins/fleet/server/services/setup.test.ts b/x-pack/plugins/fleet/server/services/setup.test.ts
index 7d98db879910b..15dccb15053ab 100644
--- a/x-pack/plugins/fleet/server/services/setup.test.ts
+++ b/x-pack/plugins/fleet/server/services/setup.test.ts
@@ -15,9 +15,7 @@ import { ensurePreconfiguredPackagesAndPolicies } from '.';
import { appContextService } from './app_context';
import { getInstallations } from './epm/packages';
import { upgradeManagedPackagePolicies } from './managed_package_policies';
-import { setupFleet, ensureFleetFileUploadIndices } from './setup';
-
-import { ensureFileUploadWriteIndices } from './epm/elasticsearch/template/install';
+import { setupFleet } from './setup';
jest.mock('./preconfiguration');
jest.mock('./preconfiguration/outputs');
@@ -70,8 +68,6 @@ describe('setupFleet', () => {
soClient.find.mockResolvedValue({ saved_objects: [] } as any);
soClient.bulkGet.mockResolvedValue({ saved_objects: [] } as any);
-
- (ensureFileUploadWriteIndices as jest.Mock).mockResolvedValue({});
});
afterEach(async () => {
@@ -138,12 +134,4 @@ describe('setupFleet', () => {
],
});
});
-
- it('should create agent file upload write indices', async () => {
- await ensureFleetFileUploadIndices(soClient, esClient);
-
- expect((ensureFileUploadWriteIndices as jest.Mock).mock.calls[0][0].integrationNames).toEqual([
- 'elastic_agent',
- ]);
- });
});
diff --git a/x-pack/plugins/fleet/server/services/setup.ts b/x-pack/plugins/fleet/server/services/setup.ts
index 90b76b8495e39..92d8f8fb37dda 100644
--- a/x-pack/plugins/fleet/server/services/setup.ts
+++ b/x-pack/plugins/fleet/server/services/setup.ts
@@ -12,11 +12,7 @@ import pMap from 'p-map';
import type { ElasticsearchClient, SavedObjectsClientContract } from '@kbn/core/server';
import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants';
-import {
- AUTO_UPDATE_PACKAGES,
- FILE_STORAGE_INTEGRATION_NAMES,
- FLEET_ELASTIC_AGENT_PACKAGE,
-} from '../../common/constants';
+import { AUTO_UPDATE_PACKAGES } from '../../common/constants';
import type { PreconfigurationError } from '../../common/constants';
import type {
DefaultPackagesInstallationError,
@@ -44,10 +40,7 @@ import { ensureDefaultEnrollmentAPIKeyForAgentPolicy } from './api_keys';
import { getRegistryUrl, settingsService } from '.';
import { awaitIfPending } from './setup_utils';
import { ensureFleetFinalPipelineIsInstalled } from './epm/elasticsearch/ingest_pipeline/install';
-import {
- ensureDefaultComponentTemplates,
- ensureFileUploadWriteIndices,
-} from './epm/elasticsearch/template/install';
+import { ensureDefaultComponentTemplates } from './epm/elasticsearch/template/install';
import { getInstallations, reinstallPackageForInstallation } from './epm/packages';
import { isPackageInstalled } from './epm/packages/install';
import type { UpgradeManagedPackagePoliciesResult } from './managed_package_policies';
@@ -60,7 +53,6 @@ import {
ensurePreconfiguredFleetServerHosts,
getPreconfiguredFleetServerHostFromConfig,
} from './preconfiguration/fleet_server_host';
-import { getInstallationsByName } from './epm/packages/get';
export interface SetupStatus {
isInitialized: boolean;
@@ -125,7 +117,6 @@ async function createSetupSideEffects(
logger.debug('Setting up Fleet Elasticsearch assets');
await ensureFleetGlobalEsAssets(soClient, esClient);
- await ensureFleetFileUploadIndices(soClient, esClient);
// Ensure that required packages are always installed even if they're left out of the config
const preconfiguredPackageNames = new Set(packages.map((pkg) => pkg.name));
@@ -207,32 +198,6 @@ async function createSetupSideEffects(
};
}
-/**
- * Ensure ES assets shared by all Fleet index template are installed
- */
-export async function ensureFleetFileUploadIndices(
- soClient: SavedObjectsClientContract,
- esClient: ElasticsearchClient
-) {
- const { diagnosticFileUploadEnabled } = appContextService.getExperimentalFeatures();
- if (!diagnosticFileUploadEnabled) return;
- const logger = appContextService.getLogger();
- const installedFileUploadIntegrations = await getInstallationsByName({
- savedObjectsClient: soClient,
- pkgNames: [...FILE_STORAGE_INTEGRATION_NAMES],
- });
-
- const integrationNames = installedFileUploadIntegrations.map(({ name }) => name);
- if (!integrationNames.includes(FLEET_ELASTIC_AGENT_PACKAGE)) {
- integrationNames.push(FLEET_ELASTIC_AGENT_PACKAGE);
- }
- logger.debug(`Ensuring file upload write indices for ${integrationNames}`);
- return ensureFileUploadWriteIndices({
- esClient,
- logger,
- integrationNames,
- });
-}
/**
* Ensure ES assets shared by all Fleet index template are installed
*/
diff --git a/x-pack/plugins/fleet/server/tasks/check_deleted_files_task.ts b/x-pack/plugins/fleet/server/tasks/check_deleted_files_task.ts
index b7ebdd0748e9d..a7611d73cd313 100644
--- a/x-pack/plugins/fleet/server/tasks/check_deleted_files_task.ts
+++ b/x-pack/plugins/fleet/server/tasks/check_deleted_files_task.ts
@@ -72,6 +72,7 @@ export class CheckDeletedFilesTask {
}
this.wasStarted = true;
+ this.logger.info(`Started with interval of [${INTERVAL}] and timeout of [${TIMEOUT}]`);
try {
await taskManager.ensureScheduled({
@@ -85,7 +86,7 @@ export class CheckDeletedFilesTask {
params: { version: VERSION },
});
} catch (e) {
- this.logger.error(`Error scheduling task, received error: ${e}`);
+ this.logger.error(`Error scheduling task, received error: ${e.message}`, e);
}
};
@@ -104,19 +105,34 @@ export class CheckDeletedFilesTask {
throwUnrecoverableError(new Error('Outdated task version'));
}
+ this.logger.info(`[runTask()] started`);
+
+ const endRun = (msg: string = '') => {
+ this.logger.info(`[runTask()] ended${msg ? ': ' + msg : ''}`);
+ };
+
const [{ elasticsearch }] = await core.getStartServices();
const esClient = elasticsearch.client.asInternalUser;
try {
const readyFiles = await getFilesByStatus(esClient, this.abortController);
- if (!readyFiles.length) return;
+
+ if (!readyFiles.length) {
+ endRun('no files to process');
+ return;
+ }
const { fileIdsByIndex: deletedFileIdsByIndex, allFileIds: allDeletedFileIds } =
await fileIdsWithoutChunksByIndex(esClient, this.abortController, readyFiles);
- if (!allDeletedFileIds.size) return;
+
+ if (!allDeletedFileIds.size) {
+ endRun('No files with deleted chunks');
+ return;
+ }
this.logger.info(`Attempting to update ${allDeletedFileIds.size} files to DELETED status`);
- this.logger.debug(`Attempting to file ids: ${deletedFileIdsByIndex}`);
+ this.logger.debug(`Attempting to update file ids: ${deletedFileIdsByIndex}`);
+
const updatedFilesResponses = await updateFilesStatus(
esClient,
this.abortController,
@@ -130,12 +146,16 @@ export class CheckDeletedFilesTask {
this.logger.warn(`Failed to update ${failures.length} files to DELETED status`);
this.logger.debug(`Failed to update files to DELETED status: ${failures}`);
}
+
+ endRun('success');
} catch (err) {
if (err instanceof errors.RequestAbortedError) {
this.logger.warn(`request aborted due to timeout: ${err}`);
+ endRun();
return;
}
this.logger.error(err);
+ endRun('error');
}
};
}
diff --git a/x-pack/plugins/fleet/tsconfig.json b/x-pack/plugins/fleet/tsconfig.json
index dc858ff5029a8..4e8ec7de3fcc7 100644
--- a/x-pack/plugins/fleet/tsconfig.json
+++ b/x-pack/plugins/fleet/tsconfig.json
@@ -42,7 +42,7 @@
"@kbn/cloud-chat-plugin",
"@kbn/kibana-react-plugin",
"@kbn/es-ui-shared-plugin",
- "@kbn/infra-plugin",
+ "@kbn/logs-shared-plugin",
"@kbn/kibana-utils-plugin",
"@kbn/unified-search-plugin",
"@kbn/storybook",
diff --git a/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts b/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts
index 2eec5b035c793..4f5b977dd3b82 100644
--- a/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts
+++ b/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import * as rt from 'io-ts';
-import { persistedLogViewReferenceRT } from '../../../log_views';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import { commonSearchSuccessResponseFieldsRT } from '../../../utils/elasticsearch_runtime_types';
export const LOG_DOCUMENT_COUNT_RULE_TYPE_ID = 'logs.alert.document.count';
diff --git a/x-pack/plugins/infra/common/http_api/index.ts b/x-pack/plugins/infra/common/http_api/index.ts
index 9f63896dbca9f..cfa4841d9aa57 100644
--- a/x-pack/plugins/infra/common/http_api/index.ts
+++ b/x-pack/plugins/infra/common/http_api/index.ts
@@ -20,6 +20,4 @@ export * as inventoryViewsV1 from './inventory_views/v1';
export * as logAlertsV1 from './log_alerts/v1';
export * as logAnalysisResultsV1 from './log_analysis/results/v1';
export * as logAnalysisValidationV1 from './log_analysis/validation/v1';
-export * as logEntriesV1 from './log_entries/v1';
-export * as logViewsV1 from './log_views/v1';
export * as metricsExplorerViewsV1 from './metrics_explorer_views/v1';
diff --git a/x-pack/plugins/infra/common/http_api/inventory_views/v1/common.ts b/x-pack/plugins/infra/common/http_api/inventory_views/v1/common.ts
index 65e056f30e0d9..f1eb9b24ee039 100644
--- a/x-pack/plugins/infra/common/http_api/inventory_views/v1/common.ts
+++ b/x-pack/plugins/infra/common/http_api/inventory_views/v1/common.ts
@@ -4,9 +4,10 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
-import { nonEmptyStringRt } from '@kbn/io-ts-utils';
+
import * as rt from 'io-ts';
import { either } from 'fp-ts/Either';
+import { inventoryViewRT } from '../../../inventory_views';
export const INVENTORY_VIEW_URL = '/api/infra/inventory_views';
export const INVENTORY_VIEW_URL_ENTITY = `${INVENTORY_VIEW_URL}/{inventoryViewId}`;
@@ -33,30 +34,8 @@ export const inventoryViewRequestQueryRT = rt.partial({
sourceId: rt.string,
});
-export type InventoryViewRequestQuery = rt.TypeOf;
-
-const inventoryViewAttributesResponseRT = rt.intersection([
- rt.strict({
- name: nonEmptyStringRt,
- isDefault: rt.boolean,
- isStatic: rt.boolean,
- }),
- rt.UnknownRecord,
-]);
-
-const inventoryViewResponseRT = rt.exact(
- rt.intersection([
- rt.type({
- id: rt.string,
- attributes: inventoryViewAttributesResponseRT,
- }),
- rt.partial({
- updatedAt: rt.number,
- version: rt.string,
- }),
- ])
-);
-
export const inventoryViewResponsePayloadRT = rt.type({
- data: inventoryViewResponseRT,
+ data: inventoryViewRT,
});
+
+export type InventoryViewRequestQuery = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/http_api/inventory_views/v1/create_inventory_view.ts b/x-pack/plugins/infra/common/http_api/inventory_views/v1/create_inventory_view.ts
index 8bad088b00542..67a3bd7df1a70 100644
--- a/x-pack/plugins/infra/common/http_api/inventory_views/v1/create_inventory_view.ts
+++ b/x-pack/plugins/infra/common/http_api/inventory_views/v1/create_inventory_view.ts
@@ -5,16 +5,18 @@
* 2.0.
*/
-import { nonEmptyStringRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
+import { inventoryViewAttributesRT, inventoryViewRT } from '../../../inventory_views';
-export const createInventoryViewAttributesRequestPayloadRT = rt.intersection([
- rt.type({
- name: nonEmptyStringRt,
- }),
- rt.UnknownRecord,
- rt.exact(rt.partial({ isDefault: rt.undefined, isStatic: rt.undefined })),
-]);
+export const createInventoryViewAttributesRequestPayloadRT = rt.exact(
+ rt.intersection([
+ inventoryViewAttributesRT,
+ rt.partial({
+ isDefault: rt.undefined,
+ isStatic: rt.undefined,
+ }),
+ ])
+);
export type CreateInventoryViewAttributesRequestPayload = rt.TypeOf<
typeof createInventoryViewAttributesRequestPayloadRT
@@ -23,3 +25,5 @@ export type CreateInventoryViewAttributesRequestPayload = rt.TypeOf<
export const createInventoryViewRequestPayloadRT = rt.type({
attributes: createInventoryViewAttributesRequestPayloadRT,
});
+
+export type CreateInventoryViewResponsePayload = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/http_api/inventory_views/v1/find_inventory_view.ts b/x-pack/plugins/infra/common/http_api/inventory_views/v1/find_inventory_view.ts
index 17a9820a93a4d..3452a22a45d17 100644
--- a/x-pack/plugins/infra/common/http_api/inventory_views/v1/find_inventory_view.ts
+++ b/x-pack/plugins/infra/common/http_api/inventory_views/v1/find_inventory_view.ts
@@ -5,28 +5,11 @@
* 2.0.
*/
-import { nonEmptyStringRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
-
-export const findInventoryViewAttributesResponseRT = rt.strict({
- name: nonEmptyStringRt,
- isDefault: rt.boolean,
- isStatic: rt.boolean,
-});
-
-const findInventoryViewResponseRT = rt.exact(
- rt.intersection([
- rt.type({
- id: rt.string,
- attributes: findInventoryViewAttributesResponseRT,
- }),
- rt.partial({
- updatedAt: rt.number,
- version: rt.string,
- }),
- ])
-);
+import { singleInventoryViewRT } from '../../../inventory_views';
export const findInventoryViewResponsePayloadRT = rt.type({
- data: rt.array(findInventoryViewResponseRT),
+ data: rt.array(singleInventoryViewRT),
});
+
+export type FindInventoryViewResponsePayload = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/http_api/inventory_views/v1/get_inventory_view.ts b/x-pack/plugins/infra/common/http_api/inventory_views/v1/get_inventory_view.ts
index 8e5cef06bb916..a13541c1e8a44 100644
--- a/x-pack/plugins/infra/common/http_api/inventory_views/v1/get_inventory_view.ts
+++ b/x-pack/plugins/infra/common/http_api/inventory_views/v1/get_inventory_view.ts
@@ -6,7 +6,10 @@
*/
import * as rt from 'io-ts';
+import { inventoryViewRT } from '../../../inventory_views';
export const getInventoryViewRequestParamsRT = rt.type({
inventoryViewId: rt.string,
});
+
+export type GetInventoryViewResposePayload = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/http_api/inventory_views/v1/update_inventory_view.ts b/x-pack/plugins/infra/common/http_api/inventory_views/v1/update_inventory_view.ts
index b21bafbecec18..5698ab2a0b2c9 100644
--- a/x-pack/plugins/infra/common/http_api/inventory_views/v1/update_inventory_view.ts
+++ b/x-pack/plugins/infra/common/http_api/inventory_views/v1/update_inventory_view.ts
@@ -5,16 +5,18 @@
* 2.0.
*/
-import { nonEmptyStringRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
+import { inventoryViewAttributesRT, inventoryViewRT } from '../../../inventory_views';
-export const updateInventoryViewAttributesRequestPayloadRT = rt.intersection([
- rt.type({
- name: nonEmptyStringRt,
- }),
- rt.UnknownRecord,
- rt.exact(rt.partial({ isDefault: rt.undefined, isStatic: rt.undefined })),
-]);
+export const updateInventoryViewAttributesRequestPayloadRT = rt.exact(
+ rt.intersection([
+ inventoryViewAttributesRT,
+ rt.partial({
+ isDefault: rt.undefined,
+ isStatic: rt.undefined,
+ }),
+ ])
+);
export type UpdateInventoryViewAttributesRequestPayload = rt.TypeOf<
typeof updateInventoryViewAttributesRequestPayloadRT
@@ -23,3 +25,5 @@ export type UpdateInventoryViewAttributesRequestPayload = rt.TypeOf<
export const updateInventoryViewRequestPayloadRT = rt.type({
attributes: updateInventoryViewAttributesRequestPayloadRT,
});
+
+export type UpdateInventoryViewResponsePayload = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/http_api/latest.ts b/x-pack/plugins/infra/common/http_api/latest.ts
index 28cdf220f710e..98787a2c581a2 100644
--- a/x-pack/plugins/infra/common/http_api/latest.ts
+++ b/x-pack/plugins/infra/common/http_api/latest.ts
@@ -9,6 +9,4 @@ export * from './inventory_views/v1';
export * from './log_alerts/v1';
export * from './log_analysis/results/v1';
export * from './log_analysis/validation/v1';
-export * from './log_entries/v1';
-export * from './log_views/v1';
export * from './metrics_explorer_views/v1';
diff --git a/x-pack/plugins/infra/common/http_api/log_alerts/v1/chart_preview_data.ts b/x-pack/plugins/infra/common/http_api/log_alerts/v1/chart_preview_data.ts
index 5647b9d09bdcc..7f0424f0df53b 100644
--- a/x-pack/plugins/infra/common/http_api/log_alerts/v1/chart_preview_data.ts
+++ b/x-pack/plugins/infra/common/http_api/log_alerts/v1/chart_preview_data.ts
@@ -6,6 +6,7 @@
*/
import * as rt from 'io-ts';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import {
ThresholdRT,
countCriteriaRT,
@@ -13,7 +14,6 @@ import {
timeSizeRT,
groupByRT,
} from '../../../alerting/logs/log_threshold/types';
-import { persistedLogViewReferenceRT } from '../../../log_views';
export const LOG_ALERTS_CHART_PREVIEW_DATA_PATH = '/api/infra/log_alerts/chart_preview_data';
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies.ts
index 56ee97a468462..3553962063990 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies.ts
@@ -7,7 +7,7 @@
import * as rt from 'io-ts';
-import { persistedLogViewReferenceRT } from '../../../../log_views';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import { timeRangeRT, routeTimingMetadataRT } from '../../../shared';
import {
logEntryAnomalyRT,
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies_datasets.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies_datasets.ts
index 8de55d96ba3c0..c07007be05115 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies_datasets.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_anomalies_datasets.ts
@@ -6,7 +6,7 @@
*/
import * as rt from 'io-ts';
-import { persistedLogViewReferenceRT } from '../../../../log_views';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import {
badRequestErrorRT,
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_categories.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_categories.ts
index 9e838174bb6a1..e84825b8c6835 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_categories.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_categories.ts
@@ -7,7 +7,7 @@
import * as rt from 'io-ts';
-import { persistedLogViewReferenceRT } from '../../../../log_views';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import {
badRequestErrorRT,
forbiddenErrorRT,
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_datasets.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_datasets.ts
index 6523559103fdc..e051e313d9b8e 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_datasets.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_datasets.ts
@@ -7,13 +7,13 @@
import * as rt from 'io-ts';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../../shared';
-import { persistedLogViewReferenceRT } from '../../../../log_views';
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH =
'/api/infra/log_analysis/results/log_entry_category_datasets';
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_examples.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_examples.ts
index 00fff8aabf9d1..fc6ece5d7b7f7 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_examples.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_category_examples.ts
@@ -5,16 +5,14 @@
* 2.0.
*/
+import { logEntryContextRT, persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import * as rt from 'io-ts';
-
-import { persistedLogViewReferenceRT } from '../../../../log_views';
import {
badRequestErrorRT,
forbiddenErrorRT,
- timeRangeRT,
routeTimingMetadataRT,
+ timeRangeRT,
} from '../../../shared';
-import { logEntryContextRT } from '../../../../log_entry';
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_category_examples';
diff --git a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_examples.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_examples.ts
index 8233962df6bfa..ebc78693f4983 100644
--- a/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_examples.ts
+++ b/x-pack/plugins/infra/common/http_api/log_analysis/results/v1/log_entry_examples.ts
@@ -6,7 +6,7 @@
*/
import * as rt from 'io-ts';
-import { persistedLogViewReferenceRT } from '../../../../log_views';
+import { persistedLogViewReferenceRT } from '@kbn/logs-shared-plugin/common';
import { logEntryExampleRT } from '../../../../log_analysis';
import {
badRequestErrorRT,
diff --git a/x-pack/plugins/infra/common/inventory_views/types.ts b/x-pack/plugins/infra/common/inventory_views/types.ts
index 49979c1063efa..a493d2332f212 100644
--- a/x-pack/plugins/infra/common/inventory_views/types.ts
+++ b/x-pack/plugins/infra/common/inventory_views/types.ts
@@ -5,19 +5,89 @@
* 2.0.
*/
-import { nonEmptyStringRt } from '@kbn/io-ts-utils';
+import { isoToEpochRt, nonEmptyStringRt, inRangeRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
+import {
+ SnapshotCustomMetricInputRT,
+ SnapshotGroupByRT,
+ SnapshotMetricInputRT,
+} from '../http_api/snapshot_api';
+import { ItemTypeRT } from '../inventory_models/types';
+
+export const inventoryColorPaletteRT = rt.keyof({
+ status: null,
+ temperature: null,
+ cool: null,
+ warm: null,
+ positive: null,
+ negative: null,
+});
+
+const inventoryLegendOptionsRT = rt.type({
+ palette: inventoryColorPaletteRT,
+ steps: inRangeRt(2, 18),
+ reverseColors: rt.boolean,
+});
+
+export const inventorySortOptionRT = rt.type({
+ by: rt.keyof({ name: null, value: null }),
+ direction: rt.keyof({ asc: null, desc: null }),
+});
+
+export const inventoryViewOptionsRT = rt.keyof({ table: null, map: null });
+
+export const inventoryMapBoundsRT = rt.type({
+ min: inRangeRt(0, 1),
+ max: inRangeRt(0, 1),
+});
+
+export const inventoryFiltersStateRT = rt.type({
+ kind: rt.literal('kuery'),
+ expression: rt.string,
+});
+
+export const inventoryOptionsStateRT = rt.intersection([
+ rt.type({
+ accountId: rt.string,
+ autoBounds: rt.boolean,
+ boundsOverride: inventoryMapBoundsRT,
+ customMetrics: rt.array(SnapshotCustomMetricInputRT),
+ customOptions: rt.array(
+ rt.type({
+ text: rt.string,
+ field: rt.string,
+ })
+ ),
+ groupBy: SnapshotGroupByRT,
+ metric: SnapshotMetricInputRT,
+ nodeType: ItemTypeRT,
+ region: rt.string,
+ sort: inventorySortOptionRT,
+ view: inventoryViewOptionsRT,
+ }),
+ rt.partial({ legend: inventoryLegendOptionsRT, source: rt.string, timelineOpen: rt.boolean }),
+]);
+
+export const inventoryViewBasicAttributesRT = rt.type({
+ name: nonEmptyStringRt,
+});
+
+const inventoryViewFlagsRT = rt.partial({ isDefault: rt.boolean, isStatic: rt.boolean });
export const inventoryViewAttributesRT = rt.intersection([
- rt.strict({
- name: nonEmptyStringRt,
- isDefault: rt.boolean,
- isStatic: rt.boolean,
+ inventoryOptionsStateRT,
+ inventoryViewBasicAttributesRT,
+ inventoryViewFlagsRT,
+ rt.type({
+ autoReload: rt.boolean,
+ filterQuery: inventoryFiltersStateRT,
}),
- rt.UnknownRecord,
+ rt.partial({ time: rt.number }),
]);
-export type InventoryViewAttributes = rt.TypeOf;
+const singleInventoryViewAttributesRT = rt.exact(
+ rt.intersection([inventoryViewBasicAttributesRT, inventoryViewFlagsRT])
+);
export const inventoryViewRT = rt.exact(
rt.intersection([
@@ -26,10 +96,31 @@ export const inventoryViewRT = rt.exact(
attributes: inventoryViewAttributesRT,
}),
rt.partial({
- updatedAt: rt.number,
+ updatedAt: isoToEpochRt,
+ version: rt.string,
+ }),
+ ])
+);
+
+export const singleInventoryViewRT = rt.exact(
+ rt.intersection([
+ rt.type({
+ id: rt.string,
+ attributes: singleInventoryViewAttributesRT,
+ }),
+ rt.partial({
+ updatedAt: isoToEpochRt,
version: rt.string,
}),
])
);
+export type InventoryColorPalette = rt.TypeOf;
+export type InventoryFiltersState = rt.TypeOf;
+export type InventoryLegendOptions = rt.TypeOf;
+export type InventoryMapBounds = rt.TypeOf;
+export type InventoryOptionsState = rt.TypeOf;
+export type InventorySortOption = rt.TypeOf;
export type InventoryView = rt.TypeOf;
+export type InventoryViewAttributes = rt.TypeOf;
+export type InventoryViewOptions = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/locators/helpers.ts b/x-pack/plugins/infra/common/locators/helpers.ts
index 9ede09e7f1b1a..b4258053a0c01 100644
--- a/x-pack/plugins/infra/common/locators/helpers.ts
+++ b/x-pack/plugins/infra/common/locators/helpers.ts
@@ -5,23 +5,25 @@
* 2.0.
*/
-import { flowRight } from 'lodash';
import type { DiscoverAppLocatorParams } from '@kbn/discover-plugin/common';
import type { DiscoverStart } from '@kbn/discover-plugin/public';
-import { findInventoryFields } from '../inventory_models';
-import { MESSAGE_FIELD, TIMESTAMP_FIELD } from '../constants';
-import type { TimeRange } from '../time';
-import type { LogsLocatorParams } from './logs_locator';
-import type { InfraClientCoreSetup } from '../../public/types';
import {
DEFAULT_LOG_VIEW,
LogViewColumnConfiguration,
LogViewReference,
+ ResolvedLogView,
+} from '@kbn/logs-shared-plugin/common';
+import { flowRight } from 'lodash';
+import type { InfraClientCoreSetup } from '../../public/types';
+import { MESSAGE_FIELD, TIMESTAMP_FIELD } from '../constants';
+import { findInventoryFields } from '../inventory_models';
+import type { TimeRange } from '../time';
+import {
replaceLogFilterInQueryString,
replaceLogPositionInQueryString,
replaceLogViewInQueryString,
- ResolvedLogView,
-} from '../log_views';
+} from '../url_state_storage_service';
+import type { LogsLocatorParams } from './logs_locator';
import type { NodeLogsLocatorParams } from './node_logs_locator';
interface LocationToDiscoverParams {
@@ -59,9 +61,9 @@ export const getLocationToDiscover = async ({
filter,
logView = DEFAULT_LOG_VIEW,
}: LocationToDiscoverParams) => {
- const [, plugins, pluginStart] = await core.getStartServices();
- const { discover } = plugins;
- const { logViews } = pluginStart;
+ const [, plugins] = await core.getStartServices();
+ const { discover, logsShared } = plugins;
+ const { logViews } = logsShared;
const resolvedLogView = await logViews.client.getResolvedLogView(logView);
const discoverParams: DiscoverAppLocatorParams = {
diff --git a/x-pack/plugins/infra/common/locators/locators.test.ts b/x-pack/plugins/infra/common/locators/locators.test.ts
index 5a4ea0047e2d7..c0573d942e757 100644
--- a/x-pack/plugins/infra/common/locators/locators.test.ts
+++ b/x-pack/plugins/infra/common/locators/locators.test.ts
@@ -13,7 +13,7 @@ import type { NodeLogsLocatorParams } from './node_logs_locator';
import { coreMock } from '@kbn/core/public/mocks';
import { findInventoryFields } from '../inventory_models';
import moment from 'moment';
-import { DEFAULT_LOG_VIEW, LogViewReference } from '../log_views';
+import { DEFAULT_LOG_VIEW, LogViewReference } from '@kbn/logs-shared-plugin/common';
const setupLogsLocator = async () => {
const deps: LogsLocatorDependencies = {
diff --git a/x-pack/plugins/infra/common/locators/logs_locator.ts b/x-pack/plugins/infra/common/locators/logs_locator.ts
index f4e65634aa762..ee9006f359e66 100644
--- a/x-pack/plugins/infra/common/locators/logs_locator.ts
+++ b/x-pack/plugins/infra/common/locators/logs_locator.ts
@@ -7,7 +7,7 @@
import type { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public';
import { SerializableRecord } from '@kbn/utility-types';
-import type { LogViewReference } from '../log_views';
+import type { LogViewReference } from '@kbn/logs-shared-plugin/common';
import type { TimeRange } from '../time';
import type { InfraClientCoreSetup } from '../../public/types';
diff --git a/x-pack/plugins/infra/common/metrics_explorer_views/types.ts b/x-pack/plugins/infra/common/metrics_explorer_views/types.ts
index 47ecb06ceace5..0d0c2fa3166e0 100644
--- a/x-pack/plugins/infra/common/metrics_explorer_views/types.ts
+++ b/x-pack/plugins/infra/common/metrics_explorer_views/types.ts
@@ -9,7 +9,7 @@ import { nonEmptyStringRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
export const metricsExplorerViewAttributesRT = rt.intersection([
- rt.strict({
+ rt.type({
name: nonEmptyStringRt,
isDefault: rt.boolean,
isStatic: rt.boolean,
diff --git a/x-pack/plugins/infra/common/saved_views/index.ts b/x-pack/plugins/infra/common/saved_views/index.ts
new file mode 100644
index 0000000000000..6cc0ccaa93a6d
--- /dev/null
+++ b/x-pack/plugins/infra/common/saved_views/index.ts
@@ -0,0 +1,8 @@
+/*
+ * 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.
+ */
+
+export * from './types';
diff --git a/x-pack/plugins/infra/common/saved_views/types.ts b/x-pack/plugins/infra/common/saved_views/types.ts
new file mode 100644
index 0000000000000..01bf806da44d9
--- /dev/null
+++ b/x-pack/plugins/infra/common/saved_views/types.ts
@@ -0,0 +1,70 @@
+/*
+ * 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 {
+ QueryObserverBaseResult,
+ UseMutateAsyncFunction,
+ UseMutateFunction,
+} from '@tanstack/react-query';
+
+import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser';
+
+export type ServerError = IHttpFetchError;
+
+export interface SavedViewState {
+ views?: SavedViewItem[];
+ currentView?: TView | null;
+ isCreatingView: boolean;
+ isFetchingCurrentView: boolean;
+ isFetchingViews: boolean;
+ isUpdatingView: boolean;
+}
+
+export interface SavedViewOperations<
+ TView extends { id: TView['id'] },
+ TId extends TView['id'] = TView['id'],
+ TPayload = any,
+ TConfig = any
+> {
+ createView: UseMutateAsyncFunction;
+ deleteViewById: UseMutateFunction>;
+ fetchViews: QueryObserverBaseResult['refetch'];
+ updateViewById: UseMutateAsyncFunction>;
+ switchViewById: (id: TId) => void;
+ setDefaultViewById: UseMutateFunction>;
+}
+
+export interface SavedViewResult<
+ TView extends {
+ id: TView['id'];
+ },
+ TId extends string = '',
+ TPayload = any,
+ TConfig = any
+> extends SavedViewState,
+ SavedViewOperations {}
+
+export interface UpdateViewParams {
+ id: string;
+ attributes: TRequestPayload;
+}
+
+export interface MutationContext {
+ id?: string;
+ previousViews?: TView[];
+}
+
+export interface BasicAttributes {
+ name?: string;
+ time?: number;
+ isDefault?: boolean;
+ isStatic?: boolean;
+}
+export interface SavedViewItem {
+ id: string;
+ attributes: BasicAttributes;
+}
diff --git a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts
index f8daaa1b9227b..c6b53abee7143 100644
--- a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts
+++ b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts
@@ -6,14 +6,15 @@
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
-import * as rt from 'io-ts';
import {
logEntryAfterCursorRT,
logEntryBeforeCursorRT,
logEntryCursorRT,
logEntryRT,
-} from '../../log_entry';
-import { logViewColumnConfigurationRT, logViewReferenceRT } from '../../log_views';
+ logViewColumnConfigurationRT,
+ logViewReferenceRT,
+} from '@kbn/logs-shared-plugin/common';
+import * as rt from 'io-ts';
import { jsonObjectRT } from '../../typed_json';
import { searchStrategyErrorRT } from '../common/errors';
diff --git a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entry.ts b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entry.ts
index 6d2a7891264d1..131450d588c0f 100644
--- a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entry.ts
+++ b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entry.ts
@@ -5,9 +5,12 @@
* 2.0.
*/
+import {
+ logEntryCursorRT,
+ logEntryFieldRT,
+ logViewReferenceRT,
+} from '@kbn/logs-shared-plugin/common';
import * as rt from 'io-ts';
-import { logEntryCursorRT, logEntryFieldRT } from '../../log_entry';
-import { logViewReferenceRT } from '../../log_views';
import { searchStrategyErrorRT } from '../common/errors';
export const LOG_ENTRY_SEARCH_STRATEGY = 'infra-log-entry';
diff --git a/x-pack/plugins/infra/common/log_views/url_state_storage_service.ts b/x-pack/plugins/infra/common/url_state_storage_service.ts
similarity index 90%
rename from x-pack/plugins/infra/common/log_views/url_state_storage_service.ts
rename to x-pack/plugins/infra/common/url_state_storage_service.ts
index 973fcd53ca98c..5d701ad1876bb 100644
--- a/x-pack/plugins/infra/common/log_views/url_state_storage_service.ts
+++ b/x-pack/plugins/infra/common/url_state_storage_service.ts
@@ -10,15 +10,15 @@ import { encode } from '@kbn/rison';
import type { Query } from '@kbn/es-query';
import { parse, stringify } from 'query-string';
import moment, { DurationInputObject } from 'moment';
-import type { FilterStateInUrl } from '../../public/observability_logs/log_stream_query_state';
-import type { PositionStateInUrl } from '../../public/observability_logs/log_stream_position_state/src/url_state_storage_service';
import {
defaultFilterStateKey,
defaultPositionStateKey,
DEFAULT_REFRESH_INTERVAL,
LogViewReference,
-} from '.';
-import type { TimeRange } from '../time';
+} from '@kbn/logs-shared-plugin/common';
+import type { FilterStateInUrl } from '../public/observability_logs/log_stream_query_state';
+import type { PositionStateInUrl } from '../public/observability_logs/log_stream_position_state/src/url_state_storage_service';
+import type { TimeRange } from './time';
export const defaultLogViewKey = 'logView';
diff --git a/x-pack/plugins/infra/kibana.jsonc b/x-pack/plugins/infra/kibana.jsonc
index c9a9ca0e18674..973d979ed90aa 100644
--- a/x-pack/plugins/infra/kibana.jsonc
+++ b/x-pack/plugins/infra/kibana.jsonc
@@ -20,6 +20,7 @@
"features",
"fieldFormats",
"lens",
+ "logsShared",
"observability",
"observabilityShared",
"ruleRegistry",
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/components/explain_log_rate_spike.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/components/explain_log_rate_spike.tsx
index b51c9beae3836..a8acacd8debd1 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/components/explain_log_rate_spike.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_details_app_section/components/explain_log_rate_spike.tsx
@@ -52,7 +52,7 @@ export const ExplainLogRateSpikes: FC {
const { services } = useKibanaContextForPlugin();
- const { dataViews, logViews } = services;
+ const { dataViews, logsShared } = services;
const [dataView, setDataView] = useState();
const [esSearchQuery, setEsSearchQuery] = useState();
const [logSpikeParams, setLogSpikeParams] = useState<
@@ -61,9 +61,8 @@ export const ExplainLogRateSpikes: FC {
const getDataView = async () => {
- const { timestampField, dataViewReference } = await logViews.client.getResolvedLogView(
- rule.params.logView
- );
+ const { timestampField, dataViewReference } =
+ await logsShared.logViews.client.getResolvedLogView(rule.params.logView);
if (dataViewReference.id) {
const logDataView = await dataViews.get(dataViewReference.id);
@@ -94,7 +93,7 @@ export const ExplainLogRateSpikes: FC import('./components/logs_history_chart'));
@@ -44,7 +44,7 @@ const AlertDetailsAppSection = ({
alert,
setAlertSummaryFields,
}: AlertDetailsAppSectionProps) => {
- const { observability, logViews } = useKibanaContextForPlugin().services;
+ const { observability, logsShared } = useKibanaContextForPlugin().services;
const theme = useTheme();
const timeRange = getPaddedAlertTimeRange(alert.fields[ALERT_START]!, alert.fields[ALERT_END]);
const alertEnd = alert.fields[ALERT_END] ? moment(alert.fields[ALERT_END]).valueOf() : undefined;
@@ -66,7 +66,7 @@ const AlertDetailsAppSection = ({
const { derivedDataView } = useLogView({
initialLogViewReference: rule.params.logView,
- logViews: logViews.client,
+ logViews: logsShared.logViews.client,
});
const { hasAtLeast } = useLicense();
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_dropdown.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_dropdown.tsx
index df324169c98e0..bb2dbc7afdc36 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_dropdown.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/alert_dropdown.tsx
@@ -9,7 +9,7 @@ import React, { useState, useCallback, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiPopover, EuiContextMenuItem, EuiContextMenuPanel, EuiHeaderLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
-import { useLogViewContext } from '../../../hooks/use_log_view';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { AlertFlyout } from './alert_flyout';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx
index c5af2938f5456..33f63fe6a49c3 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criteria.tsx
@@ -12,7 +12,7 @@ import { i18n } from '@kbn/i18n';
import type {
PersistedLogViewReference,
ResolvedLogViewField,
-} from '../../../../../common/log_views';
+} from '@kbn/logs-shared-plugin/common';
import { Criterion } from './criterion';
import {
PartialRuleParams,
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion.tsx
index 2e394bb093ec8..f2bb1d8ed5785 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion.tsx
@@ -22,12 +22,12 @@ import { i18n } from '@kbn/i18n';
import { isFinite, isNumber } from 'lodash';
import React, { useCallback, useMemo, useState } from 'react';
import type { IErrorObject } from '@kbn/triggers-actions-ui-plugin/public';
+import type { ResolvedLogViewField } from '@kbn/logs-shared-plugin/common';
import {
Comparator,
ComparatorToi18nMap,
Criterion as CriterionType,
} from '../../../../../common/alerting/logs/log_threshold/types';
-import type { ResolvedLogViewField } from '../../../../../common/log_views';
const firstCriterionFieldPrefix = i18n.translate(
'xpack.infra.logs.alertFlyout.firstCriterionFieldPrefix',
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion_preview_chart.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion_preview_chart.tsx
index b8dbc56402b2b..6b2357a4f4611 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion_preview_chart.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/criterion_preview_chart.tsx
@@ -21,9 +21,9 @@ import {
} from '@elastic/charts';
import { EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { getChartTheme } from '../../../../utils/get_chart_theme';
import { useIsDarkMode } from '../../../../hooks/use_is_dark_mode';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
import { ExecutionTimeRange } from '../../../../types';
import {
ChartContainer,
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx
index d9275a1ff0178..475bb0b1fbdef 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/editor.tsx
@@ -13,7 +13,8 @@ import {
ForLastExpression,
RuleTypeParamsExpressionProps,
} from '@kbn/triggers-actions-ui-plugin/public';
-import { PersistedLogViewReference, ResolvedLogViewField } from '../../../../../common/log_views';
+import { LogViewProvider, useLogViewContext } from '@kbn/logs-shared-plugin/public';
+import { PersistedLogViewReference, ResolvedLogViewField } from '@kbn/logs-shared-plugin/common';
import {
Comparator,
isOptimizableGroupedThreshold,
@@ -28,7 +29,6 @@ import {
import { decodeOrThrow } from '../../../../../common/runtime_types';
import { ObjectEntries } from '../../../../../common/utility_types';
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
-import { LogViewProvider, useLogViewContext } from '../../../../hooks/use_log_view';
import { GroupByExpression } from '../../../common/group_by_expression/group_by_expression';
import { errorsRT } from '../../validation';
import { Criteria } from './criteria';
@@ -95,7 +95,7 @@ export const ExpressionEditor: React.FC<
> = (props) => {
const isInternal = props.metadata?.isInternal ?? false;
const {
- services: { logViews },
+ services: { logsShared },
} = useKibanaContextForPlugin(); // injected during alert registration
return (
@@ -105,7 +105,7 @@ export const ExpressionEditor: React.FC<
) : (
-
+
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/hooks/use_chart_preview_data.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/hooks/use_chart_preview_data.tsx
index d633a055c46ef..ad042d77a584c 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/hooks/use_chart_preview_data.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/hooks/use_chart_preview_data.tsx
@@ -8,6 +8,7 @@
import { HttpHandler } from '@kbn/core/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useMemo, useState } from 'react';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { isRatioRule } from '../../../../../../common/alerting/logs/log_threshold';
import {
GetLogAlertsChartPreviewDataAlertParamsSubset,
@@ -16,7 +17,6 @@ import {
getLogAlertsChartPreviewDataSuccessResponsePayloadRT,
LOG_ALERTS_CHART_PREVIEW_DATA_PATH,
} from '../../../../../../common/http_api';
-import { PersistedLogViewReference } from '../../../../../../common/log_views';
import { decodeOrThrow } from '../../../../../../common/runtime_types';
import { ExecutionTimeRange } from '../../../../../types';
import { useTrackedPromise } from '../../../../../utils/use_tracked_promise';
diff --git a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/log_view_switcher.tsx b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/log_view_switcher.tsx
index f3988002a7f7e..8dfa7295b6769 100644
--- a/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/log_view_switcher.tsx
+++ b/x-pack/plugins/infra/public/alerting/log_threshold/components/expression_editor/log_view_switcher.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexItem, EuiFlexGroup, EuiExpression, EuiToolTip } from '@elastic/eui';
-import { ResolvedLogView } from '../../../../../common/log_views';
+import { ResolvedLogView } from '@kbn/logs-shared-plugin/common';
const description = i18n.translate('xpack.infra.logs.alertFlyout.logViewDescription', {
defaultMessage: 'Log View',
diff --git a/x-pack/plugins/infra/public/apps/discover_app.tsx b/x-pack/plugins/infra/public/apps/discover_app.tsx
index dd99a5e4dd625..2ea704fa9b21f 100644
--- a/x-pack/plugins/infra/public/apps/discover_app.tsx
+++ b/x-pack/plugins/infra/public/apps/discover_app.tsx
@@ -6,8 +6,8 @@
*/
import { createKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
import type { AppMountParameters, CoreStart } from '@kbn/core/public';
+import { getLogViewReferenceFromUrl } from '@kbn/logs-shared-plugin/public';
import type { InfraClientStartExports } from '../types';
-import { getLogViewReferenceFromUrl } from '../observability_logs/log_view_state';
export const renderApp = (
core: CoreStart,
diff --git a/x-pack/plugins/infra/public/common/visualizations/lens/formulas/host/disk_space_usage.ts b/x-pack/plugins/infra/public/common/visualizations/lens/formulas/host/disk_space_usage.ts
index 20a0e1f2dc983..9599e65d4de9b 100644
--- a/x-pack/plugins/infra/public/common/visualizations/lens/formulas/host/disk_space_usage.ts
+++ b/x-pack/plugins/infra/public/common/visualizations/lens/formulas/host/disk_space_usage.ts
@@ -5,9 +5,19 @@
* 2.0.
*/
-import type { LensChartConfig } from '../../../types';
+import type { LensChartConfig, LensLineChartConfig } from '../../../types';
import { getFilters } from './utils';
+export const diskSpaceUsageLineChart: LensLineChartConfig = {
+ extraVisualizationState: {
+ yLeftExtent: {
+ mode: 'custom',
+ lowerBound: 0,
+ upperBound: 1,
+ },
+ },
+};
+
export const diskSpaceUsage: LensChartConfig = {
title: 'Disk Space Usage',
formula: {
@@ -20,4 +30,5 @@ export const diskSpaceUsage: LensChartConfig = {
},
},
getFilters,
+ lineChartConfig: diskSpaceUsageLineChart,
};
diff --git a/x-pack/plugins/infra/public/components/asset_details/__stories__/context/fixtures/log_entries.ts b/x-pack/plugins/infra/public/components/asset_details/__stories__/context/fixtures/log_entries.ts
index 6212c256647ef..35549673701fc 100644
--- a/x-pack/plugins/infra/public/components/asset_details/__stories__/context/fixtures/log_entries.ts
+++ b/x-pack/plugins/infra/public/components/asset_details/__stories__/context/fixtures/log_entries.ts
@@ -11,11 +11,11 @@ import type {
IKibanaSearchResponse,
ISearchOptions,
} from '@kbn/data-plugin/public';
+import { defaultLogViewAttributes } from '@kbn/logs-shared-plugin/common';
import {
type LogEntriesSearchResponsePayload,
LOG_ENTRIES_SEARCH_STRATEGY,
} from '../../../../../../common/search_strategies/log_entries/log_entries';
-import { defaultLogViewAttributes } from '../../../../../../common/log_views';
import { generateFakeEntries } from '../../../../../test_utils/entries';
export const getLogEntries = ({ params }: IKibanaSearchRequest, options?: ISearchOptions) => {
diff --git a/x-pack/plugins/infra/public/components/asset_details/tabs/logs/logs.tsx b/x-pack/plugins/infra/public/components/asset_details/tabs/logs/logs.tsx
index d928eda5a2137..d2311b91fa1b2 100644
--- a/x-pack/plugins/infra/public/components/asset_details/tabs/logs/logs.tsx
+++ b/x-pack/plugins/infra/public/components/asset_details/tabs/logs/logs.tsx
@@ -11,10 +11,10 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { EuiFieldSearch, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
-import { DEFAULT_LOG_VIEW, LogViewReference } from '../../../../../common/log_views';
+import { LogStream } from '@kbn/logs-shared-plugin/public';
+import { DEFAULT_LOG_VIEW, LogViewReference } from '@kbn/logs-shared-plugin/common';
import type { InventoryItemType } from '../../../../../common/inventory_models/types';
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
-import { LogStream } from '../../../log_stream';
import { findInventoryFields } from '../../../../../common/inventory_models';
import { InfraLoadingPanel } from '../../../loading';
diff --git a/x-pack/plugins/infra/public/components/asset_details/types.ts b/x-pack/plugins/infra/public/components/asset_details/types.ts
index c42953ab8fb3e..a3d519641da3a 100644
--- a/x-pack/plugins/infra/public/components/asset_details/types.ts
+++ b/x-pack/plugins/infra/public/components/asset_details/types.ts
@@ -5,7 +5,7 @@
* 2.0.
*/
-import type { LogViewReference } from '../../../common/log_views';
+import { LogViewReference } from '@kbn/logs-shared-plugin/common';
import type { InventoryItemType } from '../../../common/inventory_models/types';
import type { InfraAssetMetricType, SnapshotCustomMetricInput } from '../../../common/http_api';
diff --git a/x-pack/plugins/infra/public/components/log_stream/log_stream_embeddable.tsx b/x-pack/plugins/infra/public/components/log_stream/log_stream_embeddable.tsx
index d2d59fe519353..1986354b5e9bd 100644
--- a/x-pack/plugins/infra/public/components/log_stream/log_stream_embeddable.tsx
+++ b/x-pack/plugins/infra/public/components/log_stream/log_stream_embeddable.tsx
@@ -13,10 +13,10 @@ import { Subscription } from 'rxjs';
import type { TimeRange } from '@kbn/es-query';
import { Embeddable, EmbeddableInput, IContainer } from '@kbn/embeddable-plugin/public';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
+import { LogStream } from '@kbn/logs-shared-plugin/public';
import { CoreProviders } from '../../apps/common_providers';
import { InfraClientStartDeps, InfraClientStartExports } from '../../types';
import { datemathToEpochMillis } from '../../utils/datemath';
-import { LazyLogStreamWrapper } from './lazy_log_stream_wrapper';
export const LOG_STREAM_EMBEDDABLE = 'LOG_STREAM_EMBEDDABLE';
@@ -90,7 +90,7 @@ export class LogStreamEmbeddable extends Embeddable {
>
-
void;
diff --git a/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx
index e60a606ce0ce3..6533bebf74fc6 100644
--- a/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx
+++ b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx
@@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import classNames from 'classnames';
import * as React from 'react';
-import { LogEntryTime } from '../../../../common/log_entry';
+import { LogEntryTime } from '@kbn/logs-shared-plugin/common';
import { LogSearchButtons } from './log_search_buttons';
import { LogSearchInput } from './log_search_input';
diff --git a/x-pack/plugins/infra/public/components/saved_views/manage_views_flyout.tsx b/x-pack/plugins/infra/public/components/saved_views/manage_views_flyout.tsx
index e503bdebafa03..67235c96a8bcc 100644
--- a/x-pack/plugins/infra/public/components/saved_views/manage_views_flyout.tsx
+++ b/x-pack/plugins/infra/public/components/saved_views/manage_views_flyout.tsx
@@ -24,21 +24,15 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiBasicTableColumn } from '@elastic/eui';
import { EuiButtonIcon } from '@elastic/eui';
-import { MetricsExplorerView } from '../../../common/metrics_explorer_views';
-import type { InventoryView } from '../../../common/inventory_views';
-import { UseInventoryViewsResult } from '../../hooks/use_inventory_views';
-import { UseMetricsExplorerViewsResult } from '../../hooks/use_metrics_explorer_views';
+import { SavedViewOperations, SavedViewItem } from '../../../common/saved_views';
-type View = InventoryView | MetricsExplorerView;
-type UseViewResult = UseInventoryViewsResult | UseMetricsExplorerViewsResult;
-
-export interface ManageViewsFlyoutProps {
- views: UseViewResult['views'];
+export interface ManageViewsFlyoutProps {
+ views?: SavedViewItem[];
loading: boolean;
onClose(): void;
- onMakeDefaultView: UseViewResult['setDefaultViewById'];
- onSwitchView: UseViewResult['switchViewById'];
- onDeleteView: UseViewResult['deleteViewById'];
+ onMakeDefaultView: SavedViewOperations['setDefaultViewById'];
+ onSwitchView: SavedViewOperations['switchViewById'];
+ onDeleteView: SavedViewOperations['deleteViewById'];
}
interface DeleteConfimationProps {
@@ -50,18 +44,18 @@ const searchConfig = {
box: { incremental: true },
};
-export function ManageViewsFlyout({
+export function ManageViewsFlyout({
onClose,
views = [],
onSwitchView,
onMakeDefaultView,
onDeleteView,
loading,
-}: ManageViewsFlyoutProps) {
+}: ManageViewsFlyoutProps) {
// Add name as top level property to allow in memory search
const namedViews = useMemo(() => views.map(addOwnName), [views]);
- const renderName = (name: string, item: View) => (
+ const renderName = (name: string, item: SavedViewItem) => (
);
- const renderDeleteAction = (item: View) => {
+ const renderDeleteAction = (item: SavedViewItem) => {
return (
{
+ const renderMakeDefaultAction = (item: SavedViewItem) => {
return (
> = [
+ const columns: Array> = [
{
field: 'name',
name: i18n.translate('xpack.infra.openView.columnNames.name', { defaultMessage: 'Name' }),
@@ -193,4 +187,7 @@ const DeleteConfimation = ({ isDisabled, onConfirm }: DeleteConfimationProps) =>
/**
* Helpers
*/
-const addOwnName = (view: View) => ({ ...view, name: view.attributes.name });
+const addOwnName = (view: TSavedViewState) => ({
+ ...view,
+ name: view.attributes.name,
+});
diff --git a/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx b/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx
index b52d83cac60c6..11d45a51a0b2c 100644
--- a/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx
+++ b/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx
@@ -10,35 +10,30 @@ import { i18n } from '@kbn/i18n';
import { EuiButton, EuiPopover, EuiListGroup, EuiListGroupItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { NonEmptyString } from '@kbn/io-ts-utils';
+import {
+ SavedViewState,
+ SavedViewOperations,
+ SavedViewItem,
+ BasicAttributes,
+} from '../../../common/saved_views';
import { ManageViewsFlyout } from './manage_views_flyout';
import { useBoolean } from '../../hooks/use_boolean';
import { UpsertViewModal } from './upsert_modal';
-import { UseInventoryViewsResult } from '../../hooks/use_inventory_views';
-import { UseMetricsExplorerViewsResult } from '../../hooks/use_metrics_explorer_views';
-
-type UseViewProps =
- | 'currentView'
- | 'views'
- | 'isFetchingViews'
- | 'isFetchingCurrentView'
- | 'isCreatingView'
- | 'isUpdatingView';
-
-type UseViewResult = UseInventoryViewsResult | UseMetricsExplorerViewsResult;
-type InventoryViewsResult = Pick;
-type MetricsExplorerViewsResult = Pick;
-
-interface Props extends InventoryViewsResult, MetricsExplorerViewsResult {
- viewState: ViewState & { time?: number };
- onCreateView: UseViewResult['createView'];
- onDeleteView: UseViewResult['deleteViewById'];
- onUpdateView: UseViewResult['updateViewById'];
- onLoadViews: UseViewResult['fetchViews'];
- onSetDefaultView: UseViewResult['setDefaultViewById'];
- onSwitchView: UseViewResult['switchViewById'];
+
+interface Props
+ extends SavedViewState {
+ viewState: TViewState & BasicAttributes;
+ onCreateView: SavedViewOperations['createView'];
+ onDeleteView: SavedViewOperations['deleteViewById'];
+ onUpdateView: SavedViewOperations['updateViewById'];
+ onLoadViews: SavedViewOperations['fetchViews'];
+ onSetDefaultView: SavedViewOperations['setDefaultViewById'];
+ onSwitchView: SavedViewOperations['switchViewById'];
}
-export function SavedViewsToolbarControls(props: Props) {
+export function SavedViewsToolbarControls(
+ props: Props
+) {
const {
currentView,
views,
diff --git a/x-pack/plugins/infra/public/containers/logs/view_log_in_context/view_log_in_context.ts b/x-pack/plugins/infra/public/containers/logs/view_log_in_context/view_log_in_context.ts
index 1ea8f71da129e..8327a14c28256 100644
--- a/x-pack/plugins/infra/public/containers/logs/view_log_in_context/view_log_in_context.ts
+++ b/x-pack/plugins/infra/public/containers/logs/view_log_in_context/view_log_in_context.ts
@@ -7,8 +7,7 @@
import { useState } from 'react';
import createContainer from 'constate';
-import { LogViewReference } from '../../../../common/log_views';
-import { LogEntry } from '../../../../common/log_entry';
+import { LogEntry, LogViewReference } from '@kbn/logs-shared-plugin/common';
interface ViewLogInContextProps {
logViewReference: LogViewReference;
diff --git a/x-pack/plugins/infra/public/hooks/use_inventory_views.ts b/x-pack/plugins/infra/public/hooks/use_inventory_views.ts
index 5bbc52e17afda..93873a307d59d 100644
--- a/x-pack/plugins/infra/public/hooks/use_inventory_views.ts
+++ b/x-pack/plugins/infra/public/hooks/use_inventory_views.ts
@@ -9,63 +9,29 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
-import {
- QueryObserverBaseResult,
- UseMutateAsyncFunction,
- UseMutateFunction,
- useMutation,
- useQuery,
- useQueryClient,
-} from '@tanstack/react-query';
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
-import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser';
-import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
import {
- CreateInventoryViewAttributesRequestPayload,
- UpdateInventoryViewAttributesRequestPayload,
-} from '../../common/http_api/latest';
+ MutationContext,
+ SavedViewResult,
+ ServerError,
+ UpdateViewParams,
+} from '../../common/saved_views';
+import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
+import { CreateInventoryViewAttributesRequestPayload } from '../../common/http_api/latest';
import type { InventoryView } from '../../common/inventory_views';
import { useKibanaContextForPlugin } from './use_kibana';
import { useUrlState } from '../utils/use_url_state';
import { useSavedViewsNotifier } from './use_saved_views_notifier';
import { useSourceContext } from '../containers/metrics_source';
-interface UpdateViewParams {
- id: string;
- attributes: UpdateInventoryViewAttributesRequestPayload;
-}
-
-export interface UseInventoryViewsResult {
- views?: InventoryView[];
- currentView?: InventoryView | null;
- createView: UseMutateAsyncFunction<
- InventoryView,
- ServerError,
- CreateInventoryViewAttributesRequestPayload
- >;
- deleteViewById: UseMutateFunction;
- fetchViews: QueryObserverBaseResult['refetch'];
- updateViewById: UseMutateAsyncFunction;
- switchViewById: (id: InventoryViewId) => void;
- setDefaultViewById: UseMutateFunction<
- MetricsSourceConfigurationResponse,
- ServerError,
- string,
- MutationContext
- >;
- isCreatingView: boolean;
- isFetchingCurrentView: boolean;
- isFetchingViews: boolean;
- isUpdatingView: boolean;
-}
-
-type ServerError = IHttpFetchError;
-
-interface MutationContext {
- id?: string;
- previousViews?: InventoryView[];
-}
+export type UseInventoryViewsResult = SavedViewResult<
+ InventoryView,
+ InventoryViewId,
+ CreateInventoryViewAttributesRequestPayload,
+ MetricsSourceConfigurationResponse
+>;
const queryKeys = {
find: ['inventory-views-find'] as const,
@@ -122,7 +88,7 @@ export const useInventoryViews = (): UseInventoryViewsResult => {
MetricsSourceConfigurationResponse,
ServerError,
string,
- MutationContext
+ MutationContext
>({
mutationFn: (id) => updateSourceConfiguration({ inventoryDefaultView: id }),
/**
@@ -167,7 +133,7 @@ export const useInventoryViews = (): UseInventoryViewsResult => {
const { mutateAsync: updateViewById, isLoading: isUpdatingView } = useMutation<
InventoryView,
ServerError,
- UpdateViewParams
+ UpdateViewParams
>({
mutationFn: ({ id, attributes }) => inventoryViews.client.updateInventoryView(id, attributes),
onError: (error) => {
@@ -178,7 +144,12 @@ export const useInventoryViews = (): UseInventoryViewsResult => {
},
});
- const { mutate: deleteViewById } = useMutation({
+ const { mutate: deleteViewById } = useMutation<
+ null,
+ ServerError,
+ string,
+ MutationContext
+ >({
mutationFn: (id: string) => inventoryViews.client.deleteInventoryView(id),
/**
* To provide a quick feedback, we perform an optimistic update on the list
diff --git a/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts b/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts
deleted file mode 100644
index 3d95dfb72abb0..0000000000000
--- a/x-pack/plugins/infra/public/hooks/use_log_view.mock.ts
+++ /dev/null
@@ -1,77 +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 { interpret } from 'xstate';
-import { createLogViewMock } from '../../common/log_views/log_view.mock';
-import { createResolvedLogViewMockFromAttributes } from '../../common/log_views/resolved_log_view.mock';
-import {
- createLogViewNotificationChannel,
- createPureLogViewStateMachine,
-} from '../observability_logs/log_view_state/src';
-import { useLogView } from './use_log_view';
-
-type UseLogView = typeof useLogView;
-type IUseLogView = ReturnType;
-
-const defaultLogViewId = 'default';
-
-export const createUninitializedUseLogViewMock =
- (logViewId: string = defaultLogViewId) =>
- (): IUseLogView => ({
- derivedDataView: undefined,
- hasFailedLoading: false,
- hasFailedLoadingLogView: false,
- hasFailedLoadingLogViewStatus: false,
- hasFailedResolvingLogView: false,
- isLoading: false,
- isLoadingLogView: false,
- isLoadingLogViewStatus: false,
- isResolvingLogView: false,
- isUninitialized: true,
- latestLoadLogViewFailures: [],
- load: jest.fn(),
- retry: jest.fn(),
- logView: undefined,
- logViewReference: { type: 'log-view-reference', logViewId },
- logViewStatus: undefined,
- resolvedLogView: undefined,
- update: jest.fn(),
- changeLogViewReference: jest.fn(),
- revertToDefaultLogView: jest.fn(),
- logViewStateService: interpret(
- createPureLogViewStateMachine({ logViewReference: { type: 'log-view-reference', logViewId } })
- ),
- logViewStateNotifications: createLogViewNotificationChannel(),
- isPersistedLogView: false,
- isInlineLogView: false,
- });
-
-export const createLoadingUseLogViewMock =
- (logViewId: string = defaultLogViewId) =>
- (): IUseLogView => ({
- ...createUninitializedUseLogViewMock(logViewId)(),
- isLoading: true,
- isLoadingLogView: true,
- isLoadingLogViewStatus: true,
- isResolvingLogView: true,
- });
-
-export const createLoadedUseLogViewMock = async (logViewId: string = defaultLogViewId) => {
- const logView = createLogViewMock(logViewId);
- const resolvedLogView = await createResolvedLogViewMockFromAttributes(logView.attributes);
-
- return (): IUseLogView => {
- return {
- ...createUninitializedUseLogViewMock(logViewId)(),
- logView,
- resolvedLogView,
- logViewStatus: {
- index: 'available',
- },
- };
- };
-};
diff --git a/x-pack/plugins/infra/public/hooks/use_metrics_explorer_views.ts b/x-pack/plugins/infra/public/hooks/use_metrics_explorer_views.ts
index 210a23a3b21ef..f2c9500f9ea63 100644
--- a/x-pack/plugins/infra/public/hooks/use_metrics_explorer_views.ts
+++ b/x-pack/plugins/infra/public/hooks/use_metrics_explorer_views.ts
@@ -9,63 +9,29 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
-import {
- QueryObserverBaseResult,
- UseMutateAsyncFunction,
- UseMutateFunction,
- useMutation,
- useQuery,
- useQueryClient,
-} from '@tanstack/react-query';
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useUiTracker } from '@kbn/observability-shared-plugin/public';
-import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser';
-import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
import {
- CreateMetricsExplorerViewAttributesRequestPayload,
- UpdateMetricsExplorerViewAttributesRequestPayload,
-} from '../../common/http_api/latest';
+ MutationContext,
+ SavedViewResult,
+ ServerError,
+ UpdateViewParams,
+} from '../../common/saved_views';
+import { MetricsSourceConfigurationResponse } from '../../common/metrics_sources';
+import { CreateMetricsExplorerViewAttributesRequestPayload } from '../../common/http_api/latest';
import { MetricsExplorerView } from '../../common/metrics_explorer_views';
import { useKibanaContextForPlugin } from './use_kibana';
import { useUrlState } from '../utils/use_url_state';
import { useSavedViewsNotifier } from './use_saved_views_notifier';
import { useSourceContext } from '../containers/metrics_source';
-interface UpdateViewParams {
- id: string;
- attributes: UpdateMetricsExplorerViewAttributesRequestPayload;
-}
-
-export interface UseMetricsExplorerViewsResult {
- views?: MetricsExplorerView[];
- currentView?: MetricsExplorerView | null;
- createView: UseMutateAsyncFunction<
- MetricsExplorerView,
- ServerError,
- CreateMetricsExplorerViewAttributesRequestPayload
- >;
- deleteViewById: UseMutateFunction;
- fetchViews: QueryObserverBaseResult['refetch'];
- updateViewById: UseMutateAsyncFunction;
- switchViewById: (id: MetricsExplorerViewId) => void;
- setDefaultViewById: UseMutateFunction<
- MetricsSourceConfigurationResponse,
- ServerError,
- string,
- MutationContext
- >;
- isCreatingView: boolean;
- isFetchingCurrentView: boolean;
- isFetchingViews: boolean;
- isUpdatingView: boolean;
-}
-
-type ServerError = IHttpFetchError;
-
-interface MutationContext {
- id?: string;
- previousViews?: MetricsExplorerView[];
-}
+export type UseMetricsExplorerViewsResult = SavedViewResult<
+ MetricsExplorerView,
+ MetricsExplorerViewId,
+ CreateMetricsExplorerViewAttributesRequestPayload,
+ MetricsSourceConfigurationResponse
+>;
const queryKeys = {
find: ['metrics-explorer-views-find'] as const,
@@ -122,7 +88,7 @@ export const useMetricsExplorerViews = (): UseMetricsExplorerViewsResult => {
MetricsSourceConfigurationResponse,
ServerError,
string,
- MutationContext
+ MutationContext
>({
mutationFn: (id) => updateSourceConfiguration({ metricsExplorerDefaultView: id }),
/**
@@ -167,7 +133,7 @@ export const useMetricsExplorerViews = (): UseMetricsExplorerViewsResult => {
const { mutateAsync: updateViewById, isLoading: isUpdatingView } = useMutation<
MetricsExplorerView,
ServerError,
- UpdateViewParams
+ UpdateViewParams
>({
mutationFn: ({ id, attributes }) =>
metricsExplorerViews.client.updateMetricsExplorerView(id, attributes),
@@ -179,7 +145,12 @@ export const useMetricsExplorerViews = (): UseMetricsExplorerViewsResult => {
},
});
- const { mutate: deleteViewById } = useMutation({
+ const { mutate: deleteViewById } = useMutation<
+ null,
+ ServerError,
+ string,
+ MutationContext
+ >({
mutationFn: (id: string) => metricsExplorerViews.client.deleteMetricsExplorerView(id),
/**
* To provide a quick feedback, we perform an optimistic update on the list
diff --git a/x-pack/plugins/infra/public/index.ts b/x-pack/plugins/infra/public/index.ts
index 4bd094b3d79f4..49a0257a22b38 100644
--- a/x-pack/plugins/infra/public/index.ts
+++ b/x-pack/plugins/infra/public/index.ts
@@ -29,6 +29,4 @@ export { InfraFormatterType } from './lib/lib';
export type InfraAppId = 'logs' | 'metrics';
// Shared components
-export { LazyLogStreamWrapper as LogStream } from './components/log_stream/lazy_log_stream_wrapper';
-export type { LogStreamProps } from './components/log_stream';
export type { InfraClientStartExports } from './types';
diff --git a/x-pack/plugins/infra/public/lib/lib.ts b/x-pack/plugins/infra/public/lib/lib.ts
index a37a9af7d9320..ac6527b9cc9c3 100644
--- a/x-pack/plugins/infra/public/lib/lib.ts
+++ b/x-pack/plugins/infra/public/lib/lib.ts
@@ -7,14 +7,16 @@
import { i18n } from '@kbn/i18n';
import * as rt from 'io-ts';
-import {
+import type { InventoryMapBounds } from '../../common/inventory_views';
+import type {
InfraTimerangeInput,
SnapshotGroupBy,
SnapshotMetricInput,
SnapshotNodeMetric,
SnapshotNodePath,
} from '../../common/http_api/snapshot_api';
-import { WaffleSortOption } from '../pages/metrics/inventory_view/hooks/use_waffle_options';
+import type { WaffleSortOption } from '../pages/metrics/inventory_view/hooks/use_waffle_options';
+export type { InventoryColorPalette } from '../../common/inventory_views';
export interface InfraWaffleMapNode {
pathId: string;
@@ -72,9 +74,6 @@ export const PALETTES = {
}),
};
-export const InventoryColorPaletteRT = rt.keyof(PALETTES);
-export type InventoryColorPalette = rt.TypeOf;
-
export const StepRuleRT = rt.intersection([
rt.type({
value: rt.number,
@@ -136,10 +135,7 @@ export interface InfraOptions {
wafflemap: InfraWaffleMapOptions;
}
-export interface InfraWaffleMapBounds {
- min: number;
- max: number;
-}
+export type InfraWaffleMapBounds = InventoryMapBounds;
export type InfraFormatter = (value: string | number) => string;
export enum InfraFormatterType {
diff --git a/x-pack/plugins/infra/public/mocks.tsx b/x-pack/plugins/infra/public/mocks.tsx
index d977e13ddd980..9b232c515ce81 100644
--- a/x-pack/plugins/infra/public/mocks.tsx
+++ b/x-pack/plugins/infra/public/mocks.tsx
@@ -8,14 +8,12 @@
import React from 'react';
import { createLocatorMock } from '../common/locators/locators.mock';
import { createInventoryViewsServiceStartMock } from './services/inventory_views/inventory_views_service.mock';
-import { createLogViewsServiceStartMock } from './services/log_views/log_views_service.mock';
import { createMetricsExplorerViewsServiceStartMock } from './services/metrics_explorer_views/metrics_explorer_views_service.mock';
import { createTelemetryServiceMock } from './services/telemetry/telemetry_service.mock';
import { InfraClientStartExports } from './types';
export const createInfraPluginStartMock = () => ({
inventoryViews: createInventoryViewsServiceStartMock(),
- logViews: createLogViewsServiceStartMock(),
metricsExplorerViews: createMetricsExplorerViewsServiceStartMock(),
telemetry: createTelemetryServiceMock(),
locators: createLocatorMock(),
diff --git a/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/state_machine.ts b/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/state_machine.ts
index b7c02e916dc57..d2a71c65702eb 100644
--- a/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/state_machine.ts
+++ b/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/state_machine.ts
@@ -8,7 +8,8 @@
import { RefreshInterval } from '@kbn/data-plugin/public';
import { TimeRange } from '@kbn/es-query';
import { actions, ActorRefFrom, createMachine, EmittedFrom } from 'xstate';
-import { DEFAULT_REFRESH_INTERVAL } from '../../../../../common/log_views';
+import { DEFAULT_REFRESH_INTERVAL } from '@kbn/logs-shared-plugin/common';
+import type { LogViewNotificationChannel } from '@kbn/logs-shared-plugin/public';
import { datemathToEpochMillis } from '../../../../utils/datemath';
import { createLogStreamPositionStateMachine } from '../../../log_stream_position_state/src/state_machine';
import {
@@ -16,7 +17,6 @@ import {
DEFAULT_TIMERANGE,
LogStreamQueryStateMachineDependencies,
} from '../../../log_stream_query_state';
-import type { LogViewNotificationChannel } from '../../../log_view_state';
import { OmitDeprecatedState } from '../../../xstate_helpers';
import {
waitForInitialQueryParameters,
diff --git a/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/types.ts b/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/types.ts
index eb42dccdf2486..12c707ebb91fd 100644
--- a/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/types.ts
+++ b/x-pack/plugins/infra/public/observability_logs/log_stream_page/state/src/types.ts
@@ -6,8 +6,13 @@
*/
import { TimeRange } from '@kbn/es-query';
+import type { LogViewStatus } from '@kbn/logs-shared-plugin/common';
+import type {
+ LogViewContextWithError,
+ LogViewContextWithResolvedLogView,
+ LogViewNotificationEvent,
+} from '@kbn/logs-shared-plugin/public';
import { TimeKey } from '../../../../../common/time';
-import type { LogViewStatus } from '../../../../../common/log_views';
import {
JumpToTargetPositionEvent,
LogStreamPositionContext,
@@ -22,11 +27,6 @@ import {
UpdateTimeRangeEvent,
} from '../../../log_stream_query_state';
import { LogStreamQueryNotificationEvent } from '../../../log_stream_query_state/src/notifications';
-import type {
- LogViewContextWithError,
- LogViewContextWithResolvedLogView,
- LogViewNotificationEvent,
-} from '../../../log_view_state';
export interface ReceivedInitialQueryParametersEvent {
type: 'RECEIVED_INITIAL_QUERY_PARAMETERS';
diff --git a/x-pack/plugins/infra/public/observability_logs/log_stream_position_state/src/url_state_storage_service.ts b/x-pack/plugins/infra/public/observability_logs/log_stream_position_state/src/url_state_storage_service.ts
index 5607bf9207054..c98ab9e147444 100644
--- a/x-pack/plugins/infra/public/observability_logs/log_stream_position_state/src/url_state_storage_service.ts
+++ b/x-pack/plugins/infra/public/observability_logs/log_stream_position_state/src/url_state_storage_service.ts
@@ -10,6 +10,7 @@ import { IKbnUrlStateStorage, withNotifyOnErrors } from '@kbn/kibana-utils-plugi
import * as Either from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/function';
import { InvokeCreator } from 'xstate';
+import { replaceStateKeyInQueryString } from '../../../../common/url_state_storage_service';
import { minimalTimeKeyRT, pickTimeKey } from '../../../../common/time';
import { createPlainError, formatErrors } from '../../../../common/runtime_types';
import type { LogStreamPositionContext, LogStreamPositionEvent } from './types';
@@ -97,3 +98,13 @@ export type PositionStateInUrl = rt.TypeOf;
const decodePositionQueryValueFromUrl = (queryValueFromUrl: unknown) => {
return positionStateInUrlRT.decode(queryValueFromUrl);
};
+
+export const replaceLogPositionInQueryString = (time?: number) =>
+ Number.isNaN(time) || time == null
+ ? (value: string) => value
+ : replaceStateKeyInQueryString(defaultPositionStateKey, {
+ position: {
+ time,
+ tiebreaker: 0,
+ },
+ });
diff --git a/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/state_machine.ts b/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/state_machine.ts
index 1a69642037d19..1c0de464121c8 100644
--- a/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/state_machine.ts
+++ b/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/state_machine.ts
@@ -14,7 +14,7 @@ import type {
import { EsQueryConfig } from '@kbn/es-query';
import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
import { actions, ActorRefFrom, createMachine, SpecialTargets, send } from 'xstate';
-import { DEFAULT_REFRESH_INTERVAL } from '../../../../common/log_views';
+import { DEFAULT_REFRESH_INTERVAL } from '@kbn/logs-shared-plugin/common';
import { OmitDeprecatedState, sendIfDefined } from '../../xstate_helpers';
import { logStreamQueryNotificationEventSelectors } from './notifications';
import {
diff --git a/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/url_state_storage_service.ts b/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/url_state_storage_service.ts
index 448fb941e037c..fb65fcd987a11 100644
--- a/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/url_state_storage_service.ts
+++ b/x-pack/plugins/infra/public/observability_logs/log_stream_query_state/src/url_state_storage_service.ts
@@ -16,9 +16,11 @@ import {
defaultFilterStateKey,
defaultPositionStateKey,
DEFAULT_REFRESH_INTERVAL,
- getTimeRangeStartFromTime,
+} from '@kbn/logs-shared-plugin/common';
+import {
getTimeRangeEndFromTime,
-} from '../../../../common/log_views';
+ getTimeRangeStartFromTime,
+} from '../../../../common/url_state_storage_service';
import { minimalTimeKeyRT } from '../../../../common/time';
import { datemathStringRT } from '../../../utils/datemath';
import { createPlainError, formatErrors } from '../../../../common/runtime_types';
diff --git a/x-pack/plugins/infra/public/observability_logs/xstate_helpers/src/state_machine_playground.tsx b/x-pack/plugins/infra/public/observability_logs/xstate_helpers/src/state_machine_playground.tsx
index 78f1c5f15dee9..5a40bd5d32292 100644
--- a/x-pack/plugins/infra/public/observability_logs/xstate_helpers/src/state_machine_playground.tsx
+++ b/x-pack/plugins/infra/public/observability_logs/xstate_helpers/src/state_machine_playground.tsx
@@ -7,7 +7,7 @@
import { EuiButton } from '@elastic/eui';
import React, { useCallback } from 'react';
-import { useLogViewContext } from '../../../hooks/use_log_view';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
export const StateMachinePlayground = () => {
const { changeLogViewReference, revertToDefaultLogView, update, isLoading, logViewStateService } =
diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx
index 3bbe00c5314cf..663df4c0f4d1a 100644
--- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx
+++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx
@@ -7,7 +7,7 @@
import { useEffect } from 'react';
import { useLocation, useParams } from 'react-router-dom';
-import { DEFAULT_LOG_VIEW } from '../../../common/log_views';
+import { DEFAULT_LOG_VIEW } from '@kbn/logs-shared-plugin/common';
import { getFilterFromLocation, getTimeFromLocation } from './query_params';
import { useKibanaContextForPlugin } from '../../hooks/use_kibana';
diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx
index 66898bf38b4b4..e3382d43c0e15 100644
--- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx
+++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx
@@ -7,7 +7,7 @@
import { useEffect } from 'react';
import { RouteComponentProps } from 'react-router-dom';
-import { DEFAULT_LOG_VIEW } from '../../../common/log_views';
+import { DEFAULT_LOG_VIEW } from '@kbn/logs-shared-plugin/common';
import { InventoryItemType } from '../../../common/inventory_models/types';
import { useKibanaContextForPlugin } from '../../hooks/use_kibana';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx
index bde85aa99ec7f..d6a1e9f2ddc5e 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx
@@ -8,6 +8,7 @@
import { i18n } from '@kbn/i18n';
import React, { useCallback, useEffect } from 'react';
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { isJobStatusWithResults } from '../../../../common/log_analysis';
import { LoadingPage } from '../../../components/loading_page';
import {
@@ -22,7 +23,6 @@ import {
import { SubscriptionSplashPage } from '../../../components/subscription_splash_content';
import { useLogAnalysisCapabilitiesContext } from '../../../containers/logs/log_analysis';
import { useLogEntryCategoriesModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_categories';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { LogsPageTemplate } from '../shared/page_template';
import { LogEntryCategoriesResultsContent } from './page_results_content';
import { LogEntryCategoriesSetupContent } from './page_setup_content';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx
index 6e1d3f4a4f0bd..5cb6a12166c53 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx
@@ -6,12 +6,12 @@
*/
import React from 'react';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { InlineLogViewSplashPage } from '../../../components/logging/inline_log_view_splash_page';
import { LogAnalysisSetupFlyoutStateProvider } from '../../../components/logging/log_analysis_setup/setup_flyout';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import { LogEntryCategoriesModuleProvider } from '../../../containers/logs/log_analysis/modules/log_entry_categories';
import { useActiveKibanaSpace } from '../../../hooks/use_kibana_space';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { ConnectedLogViewErrorPage } from '../shared/page_log_view_error';
export const LogEntryCategoriesPageProviders: React.FunctionComponent = ({ children }) => {
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx
index f26f8768a4459..e1e317136deed 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx
@@ -15,6 +15,7 @@ import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { MLJobsAwaitingNodeWarning, ML_PAGES, useMlHref } from '@kbn/ml-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { TimeRange } from '../../../../common/time/time_range';
import { CategoryJobNoticesSection } from '../../../components/logging/log_analysis_job_status';
import { AnalyzeInMlButton } from '../../../components/logging/log_analysis_results';
@@ -24,7 +25,6 @@ import { useLogAnalysisCapabilitiesContext } from '../../../containers/logs/log_
import { useLogEntryCategoriesModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_categories';
import { ViewLogInContextProvider } from '../../../containers/logs/view_log_in_context';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { LogsPageTemplate } from '../shared/page_template';
import { PageViewLogInContext } from '../stream/page_view_log_in_context';
import { TopCategoriesSection } from './sections/top_categories';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_details_row.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_details_row.tsx
index dbf143f95d0bc..34cced7d92ffd 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_details_row.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_details_row.tsx
@@ -6,7 +6,7 @@
*/
import React, { useEffect } from 'react';
-import { PersistedLogViewReference } from '../../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { useLogEntryCategoryExamples } from '../../use_log_entry_category_examples';
import { LogEntryExampleMessages } from '../../../../../components/logging/log_entry_examples/log_entry_examples';
import { TimeRange } from '../../../../../../common/time/time_range';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx
index 96c0a23ac755e..0811ec1708530 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_example_message.tsx
@@ -5,28 +5,27 @@
* 2.0.
*/
-import React, { useState, useCallback } from 'react';
import { i18n } from '@kbn/i18n';
+import { LogEntry, LogEntryContext } from '@kbn/logs-shared-plugin/common';
+import {
+ LogEntryColumn,
+ LogEntryContextMenu,
+ LogEntryFieldColumn,
+ LogEntryMessageColumn,
+ LogEntryRowWrapper,
+ LogEntryTimestampColumn,
+} from '@kbn/logs-shared-plugin/public';
+import { useLinkProps, useUiTracker } from '@kbn/observability-shared-plugin/public';
import { encode } from '@kbn/rison';
import moment from 'moment';
-
-import { useUiTracker, useLinkProps } from '@kbn/observability-shared-plugin/public';
-import { LogEntry, LogEntryContext } from '../../../../../../common/log_entry';
-import { TimeRange } from '../../../../../../common/time';
+import React, { useCallback, useState } from 'react';
import {
getFriendlyNameForPartitionId,
partitionField,
} from '../../../../../../common/log_analysis';
+import { TimeRange } from '../../../../../../common/time';
import { useViewLogInProviderContext } from '../../../../../containers/logs/view_log_in_context';
-import {
- LogEntryColumn,
- LogEntryFieldColumn,
- LogEntryMessageColumn,
- LogEntryRowWrapper,
- LogEntryTimestampColumn,
-} from '../../../../../components/logging/log_text_stream';
import { LogColumnConfiguration } from '../../../../../utils/source_configuration';
-import { LogEntryContextMenu } from '../../../../../components/logging/log_text_stream/log_entry_context_menu';
export const exampleMessageScale = 'medium' as const;
export const exampleTimestampFormat = 'dateTime' as const;
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx
index c9f93ee618ddb..6dd07a80c8652 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx
@@ -9,7 +9,7 @@ import { EuiLoadingSpinner } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
-import { PersistedLogViewReference } from '../../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { LogEntryCategory } from '../../../../../../common/log_analysis';
import { TimeRange } from '../../../../../../common/time';
import { LoadingOverlayWrapper } from '../../../../../components/loading_overlay_wrapper';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx
index 3d06a212fe581..f119a08cbd10a 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx
@@ -12,7 +12,7 @@ import React, { useMemo, useCallback } from 'react';
import useSet from 'react-use/lib/useSet';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
-import { PersistedLogViewReference } from '../../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
LogEntryCategory,
LogEntryCategoryDataset,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts
index db17c0b866b7b..14e7ebfbebd35 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
getLogEntryCategoryDatasetsRequestPayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_examples.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_examples.ts
index a27e734235c3b..3e4947ca1e84f 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_examples.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_examples.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
getLogEntryCategoryExamplesRequestPayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts
index 5104ad897c880..c4a1b6d095a29 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
getLogEntryCategoriesRequestPayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts
index 7ef8d57b29d9f..20f7adb106857 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts
@@ -7,7 +7,7 @@
import { useMemo, useState } from 'react';
-import { PersistedLogViewReference } from '../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
GetLogEntryCategoriesSuccessResponsePayload,
GetLogEntryCategoryDatasetsSuccessResponsePayload,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_category_examples.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_category_examples.tsx
index 8152cae426448..c5516fdbc02f9 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_category_examples.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_category_examples.tsx
@@ -6,7 +6,7 @@
*/
import { useMemo, useState } from 'react';
-import { PersistedLogViewReference } from '../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { LogEntryCategoryExample } from '../../../../common/http_api';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx
index 1f6fe04e59161..533381dcbf7c3 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx
@@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n';
import React, { memo, useCallback, useEffect } from 'react';
import useInterval from 'react-use/lib/useInterval';
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { isJobStatusWithResults } from '../../../../common/log_analysis';
import { LoadingPage } from '../../../components/loading_page';
import {
@@ -24,7 +25,6 @@ import { SubscriptionSplashPage } from '../../../components/subscription_splash_
import { useLogAnalysisCapabilitiesContext } from '../../../containers/logs/log_analysis';
import { useLogEntryCategoriesModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_categories';
import { useLogEntryRateModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_rate';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { LogsPageTemplate } from '../shared/page_template';
import { LogEntryRateResultsContent } from './page_results_content';
import { LogEntryRateSetupContent } from './page_setup_content';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx
index 7e1381cbd4f21..46ce90cff63cc 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx
@@ -6,6 +6,7 @@
*/
import React from 'react';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { InlineLogViewSplashPage } from '../../../components/logging/inline_log_view_splash_page';
import { LogAnalysisSetupFlyoutStateProvider } from '../../../components/logging/log_analysis_setup/setup_flyout';
import { SourceLoadingPage } from '../../../components/source_loading_page';
@@ -13,7 +14,6 @@ import { LogEntryCategoriesModuleProvider } from '../../../containers/logs/log_a
import { LogEntryRateModuleProvider } from '../../../containers/logs/log_analysis/modules/log_entry_rate';
import { LogEntryFlyoutProvider } from '../../../containers/logs/log_flyout';
import { useActiveKibanaSpace } from '../../../hooks/use_kibana_space';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { ConnectedLogViewErrorPage } from '../shared/page_log_view_error';
export const LogEntryRatePageProviders: React.FunctionComponent = ({ children }) => {
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx
index b535c1fd155de..a4d861e38ade1 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx
@@ -14,6 +14,7 @@ import { encode } from '@kbn/rison';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { MLJobsAwaitingNodeWarning } from '@kbn/ml-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
+import { useLogViewContext, LogEntryFlyout } from '@kbn/logs-shared-plugin/public';
import { isJobStatusWithResults } from '../../../../common/log_analysis';
import { TimeKey } from '../../../../common/time';
import {
@@ -23,12 +24,10 @@ import {
import { DatasetsSelector } from '../../../components/logging/log_analysis_results/datasets_selector';
import { ManageJobsButton } from '../../../components/logging/log_analysis_setup/manage_jobs_button';
import { useLogAnalysisSetupFlyoutStateContext } from '../../../components/logging/log_analysis_setup/setup_flyout';
-import { LogEntryFlyout } from '../../../components/logging/log_entry_flyout';
import { useLogAnalysisCapabilitiesContext } from '../../../containers/logs/log_analysis/log_analysis_capabilities';
import { useLogEntryCategoriesModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_categories';
import { useLogEntryRateModuleContext } from '../../../containers/logs/log_analysis/modules/log_entry_rate';
import { useLogEntryFlyoutContext } from '../../../containers/logs/log_flyout';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { LogsPageTemplate } from '../shared/page_template';
import { AnomaliesResults } from './sections/anomalies';
import { useDatasetFiltering } from './use_dataset_filtering';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx
index 493b5c4077c69..5fe150e3c2724 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx
@@ -11,10 +11,10 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import useMount from 'react-use/lib/useMount';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
+import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { isCategoryAnomaly, LogEntryAnomaly } from '../../../../../../common/log_analysis';
import { TimeRange } from '../../../../../../common/time/time_range';
import { LogEntryExampleMessages } from '../../../../../components/logging/log_entry_examples/log_entry_examples';
-import { useLogViewContext } from '../../../../../hooks/use_log_view';
import { useLogEntryExamples } from '../../use_log_entry_examples';
import { LogEntryExampleMessage, LogEntryExampleMessageHeaders } from './log_entry_example';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx
index 5b23f5f9e2a45..288fc3df39c8e 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx
@@ -12,8 +12,6 @@ import { i18n } from '@kbn/i18n';
import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useLinkProps, shouldHandleLinkEvent } from '@kbn/observability-shared-plugin/public';
-import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana';
-import { getFriendlyNameForPartitionId } from '../../../../../../common/log_analysis';
import {
LogEntryColumn,
LogEntryFieldColumn,
@@ -23,11 +21,11 @@ import {
LogEntryContextMenu,
LogEntryColumnWidths,
iconColumnId,
-} from '../../../../../components/logging/log_text_stream';
-import {
LogColumnHeadersWrapper,
LogColumnHeader,
-} from '../../../../../components/logging/log_text_stream/column_headers';
+} from '@kbn/logs-shared-plugin/public';
+import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana';
+import { getFriendlyNameForPartitionId } from '../../../../../../common/log_analysis';
import { TimeRange } from '../../../../../../common/time/time_range';
import { partitionField } from '../../../../../../common/log_analysis/job_parameters';
import { LogEntryExample, isCategoryAnomaly } from '../../../../../../common/log_analysis';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies.ts
index dc8ab4772473d..b6a515ae6f134 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
getLogEntryAnomaliesRequestPayloadRT,
getLogEntryAnomaliesSuccessReponsePayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies_datasets.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies_datasets.ts
index 093a906008582..a93712c5d5a86 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies_datasets.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies_datasets.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { decodeOrThrow } from '../../../../../common/runtime_types';
import {
getLogEntryAnomaliesDatasetsRequestPayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_examples.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_examples.ts
index f6d90692ad470..6cf35b95868e1 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_examples.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_examples.ts
@@ -6,7 +6,7 @@
*/
import type { HttpHandler } from '@kbn/core/public';
-import { PersistedLogViewReference } from '../../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import {
getLogEntryExamplesRequestPayloadRT,
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_anomalies_results.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_anomalies_results.ts
index db4fc77964173..745b5a7cd5aec 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_anomalies_results.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_anomalies_results.ts
@@ -7,7 +7,7 @@
import { useMemo, useState, useCallback, useEffect, useReducer } from 'react';
import useMount from 'react-use/lib/useMount';
-import { PersistedLogViewReference } from '../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { useTrackedPromise, CanceledPromiseError } from '../../../utils/use_tracked_promise';
import { callGetLogEntryAnomaliesAPI } from './service_calls/get_log_entry_anomalies';
import { callGetLogEntryAnomaliesDatasetsAPI } from './service_calls/get_log_entry_anomalies_datasets';
diff --git a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_examples.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_examples.ts
index a678f5deaf07a..4301f08ab41da 100644
--- a/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_examples.ts
+++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_examples.ts
@@ -6,7 +6,7 @@
*/
import { useMemo, useState } from 'react';
-import { PersistedLogViewReference } from '../../../../common/log_views';
+import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
import { LogEntryExample } from '../../../../common/log_analysis';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
diff --git a/x-pack/plugins/infra/public/pages/logs/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/page_providers.tsx
index e185a62ea9646..f4112b7bd0a05 100644
--- a/x-pack/plugins/infra/public/pages/logs/page_providers.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/page_providers.tsx
@@ -6,21 +6,21 @@
*/
import React, { useState } from 'react';
-import { LogAnalysisCapabilitiesProvider } from '../../containers/logs/log_analysis';
-import { useKibanaContextForPlugin } from '../../hooks/use_kibana';
-import { LogViewProvider } from '../../hooks/use_log_view';
import {
+ LogViewProvider,
initializeFromUrl as createInitializeFromUrl,
updateContextInUrl as createUpdateContextInUrl,
listenForUrlChanges as createListenForUrlChanges,
-} from '../../observability_logs/log_view_state/src/url_state_storage_service';
+} from '@kbn/logs-shared-plugin/public';
+import { LogAnalysisCapabilitiesProvider } from '../../containers/logs/log_analysis';
+import { useKibanaContextForPlugin } from '../../hooks/use_kibana';
import { useKbnUrlStateStorageFromRouterContext } from '../../utils/kbn_url_state_context';
export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
const {
services: {
notifications: { toasts: toastsService },
- logViews: { client },
+ logsShared,
},
} = useKibanaContextForPlugin();
@@ -38,7 +38,7 @@ export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
return (
{
return (
-
+
{({ buckets, start, end }) => (
)}
-
+
);
}}
@@ -293,6 +299,16 @@ export const StreamPageLogsContent = React.memo<{
);
});
+const WithSummaryAndQuery = (props: Omit) => {
+ const serializedParsedQuery = useSelector(useLogStreamPageStateContext(), (logStreamPageState) =>
+ logStreamPageState.matches({ hasLogViewIndices: 'initialized' })
+ ? stringify(logStreamPageState.context.parsedQuery)
+ : null
+ );
+
+ return ;
+};
+
type InitializedLogStreamPageState = MatchedStateFromActor<
LogStreamPageActorRef,
{ hasLogViewIndices: 'initialized' }
diff --git a/x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx
index 0a9f5ae9395e3..9b058bd03acd3 100644
--- a/x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx
@@ -7,20 +7,21 @@
import stringify from 'json-stable-stringify';
import React, { useMemo } from 'react';
+import {
+ LogHighlightsStateProvider,
+ LogPositionStateProvider,
+ LogStreamProvider,
+ useLogPositionStateContext,
+ useLogStreamContext,
+ useLogViewContext,
+} from '@kbn/logs-shared-plugin/public';
import {
LogStreamPageActorRef,
LogStreamPageCallbacks,
} from '../../../observability_logs/log_stream_page/state';
import { LogEntryFlyoutProvider } from '../../../containers/logs/log_flyout';
-import { LogHighlightsStateProvider } from '../../../containers/logs/log_highlights/log_highlights';
-import {
- LogPositionStateProvider,
- useLogPositionStateContext,
-} from '../../../containers/logs/log_position';
-import { LogStreamProvider, useLogStreamContext } from '../../../containers/logs/log_stream';
import { LogViewConfigurationProvider } from '../../../containers/logs/log_view_configuration';
import { ViewLogInContextProvider } from '../../../containers/logs/view_log_in_context';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { MatchedStateFromActor } from '../../../observability_logs/xstate_helpers';
const ViewLogInContext: React.FC = ({ children }) => {
diff --git a/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx
index 99c9d498fc6cc..9ea8e60eef0b9 100644
--- a/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx
@@ -8,15 +8,17 @@
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useMemo } from 'react';
+import {
+ useLogHighlightsStateContext,
+ useLogPositionStateContext,
+ useLogViewContext,
+} from '@kbn/logs-shared-plugin/public';
import { LogCustomizationMenu } from '../../../components/logging/log_customization_menu';
import { LogHighlightsMenu } from '../../../components/logging/log_highlights_menu';
import { LogTextScaleControls } from '../../../components/logging/log_text_scale_controls';
import { LogTextWrapControls } from '../../../components/logging/log_text_wrap_controls';
-import { useLogHighlightsStateContext } from '../../../containers/logs/log_highlights/log_highlights';
-import { useLogPositionStateContext } from '../../../containers/logs/log_position';
import { useLogViewConfigurationContext } from '../../../containers/logs/log_view_configuration';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
-import { useLogViewContext } from '../../../hooks/use_log_view';
import { StreamLiveButton } from './components/stream_live_button';
export const LogsToolbar = () => {
diff --git a/x-pack/plugins/infra/public/pages/logs/stream/page_view_log_in_context.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_view_log_in_context.tsx
index 15dbbcca7ce9f..2917b7b21d78f 100644
--- a/x-pack/plugins/infra/public/pages/logs/stream/page_view_log_in_context.tsx
+++ b/x-pack/plugins/infra/public/pages/logs/stream/page_view_log_in_context.tsx
@@ -17,10 +17,10 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { isEmpty } from 'lodash';
import React, { useCallback, useMemo } from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
-import { LogEntry } from '../../../../common/log_entry';
+import { LogEntry } from '@kbn/logs-shared-plugin/common';
+import { LogStream } from '@kbn/logs-shared-plugin/public';
import { useViewLogInProviderContext } from '../../../containers/logs/view_log_in_context';
import { useViewportDimensions } from '../../../utils/use_viewport_dimensions';
-import { LogStream } from '../../../components/log_stream';
const MODAL_MARGIN = 25;
diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpis/tile.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpis/tile.tsx
index cf409e878cb71..0c1d254342b84 100644
--- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpis/tile.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/kpis/tile.tsx
@@ -85,13 +85,14 @@ export const Tile = ({
const filters = useMemo(() => {
return [
+ ...searchCriteria.filters,
buildCombinedHostsFilter({
field: 'host.name',
values: hostNodes.map((p) => p.name),
dataView,
}),
];
- }, [hostNodes, dataView]);
+ }, [searchCriteria.filters, hostNodes, dataView]);
const handleBrushEnd = useCallback(
({ range }: BrushTriggerEvent['data']) => {
@@ -122,9 +123,10 @@ export const Tile = ({
() =>
getExtraActions({
timeRange: afterLoadedState.dateRange,
+ query: searchCriteria.query,
filters,
}),
- [afterLoadedState.dateRange, filters, getExtraActions]
+ [afterLoadedState.dateRange, filters, getExtraActions, searchCriteria.query]
);
return (
@@ -168,6 +170,7 @@ export const Tile = ({
lastReloadRequestTime={afterLoadedState.lastReloadRequestTime}
dateRange={afterLoadedState.dateRange}
filters={afterLoadedState.filters}
+ query={afterLoadedState.query}
onBrushEnd={handleBrushEnd}
loading={loading}
/>
diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_link_to_stream.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_link_to_stream.tsx
index ac3981026ea8e..cd2537418e46c 100644
--- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_link_to_stream.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_link_to_stream.tsx
@@ -8,7 +8,7 @@ import React from 'react';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { EuiButtonEmpty } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
-import { LogViewReference } from '../../../../../../../common/log_views';
+import { LogViewReference } from '@kbn/logs-shared-plugin/common';
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana';
interface LogsLinkToStreamProps {
diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_tab_content.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_tab_content.tsx
index 6fe796d33e909..66cbc9d1c1b1b 100644
--- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_tab_content.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/logs/logs_tab_content.tsx
@@ -8,8 +8,8 @@
import React, { useMemo } from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
+import { LogStream } from '@kbn/logs-shared-plugin/public';
import { InfraLoadingPanel } from '../../../../../../components/loading';
-import { LogStream } from '../../../../../../components/log_stream';
import { useHostsViewContext } from '../../../hooks/use_hosts_view';
import { useUnifiedSearchContext } from '../../../hooks/use_unified_search';
import { useLogsSearchUrlState } from '../../../hooks/use_logs_search_url_state';
diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/metrics/metric_chart.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/metrics/metric_chart.tsx
index 51a0a4ea30931..5d7e946f25e2a 100644
--- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/metrics/metric_chart.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/metrics/metric_chart.tsx
@@ -65,21 +65,23 @@ export const MetricChart = ({ title, type, breakdownSize }: MetricChartProps) =>
const filters = useMemo(() => {
return [
+ ...searchCriteria.filters,
buildCombinedHostsFilter({
field: 'host.name',
values: currentPage.map((p) => p.name),
dataView,
}),
];
- }, [currentPage, dataView]);
+ }, [currentPage, dataView, searchCriteria.filters]);
const extraActions: Action[] = useMemo(
() =>
getExtraActions({
timeRange: afterLoadedState.dateRange,
+ query: afterLoadedState.query,
filters,
}),
- [afterLoadedState.dateRange, filters, getExtraActions]
+ [afterLoadedState.dateRange, afterLoadedState.query, filters, getExtraActions]
);
const handleBrushEnd = useCallback(
@@ -137,6 +139,7 @@ export const MetricChart = ({ title, type, breakdownSize }: MetricChartProps) =>
lastReloadRequestTime={afterLoadedState.lastReloadRequestTime}
dateRange={afterLoadedState.dateRange}
filters={filters}
+ query={afterLoadedState.query}
onBrushEnd={handleBrushEnd}
loading={loading}
hasTitle
diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_log_view_reference.ts b/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_log_view_reference.ts
index 7335855189526..46a062001bb74 100644
--- a/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_log_view_reference.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_log_view_reference.ts
@@ -8,8 +8,8 @@
// import { useMemo } from 'react';
import useAsync from 'react-use/lib/useAsync';
import { v4 as uuidv4 } from 'uuid';
+import { DEFAULT_LOG_VIEW, LogViewReference } from '@kbn/logs-shared-plugin/common';
import { useLazyRef } from '../../../../hooks/use_lazy_ref';
-import { DEFAULT_LOG_VIEW, type LogViewReference } from '../../../../../common/log_views';
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
interface Props {
@@ -18,13 +18,11 @@ interface Props {
}
export const useLogViewReference = ({ id, extraFields = [] }: Props) => {
const {
- services: {
- logViews: { client },
- },
+ services: { logsShared },
} = useKibanaContextForPlugin();
const { loading, value: defaultLogView } = useAsync(
- () => client.getLogView(DEFAULT_LOG_VIEW),
+ () => logsShared.logViews.client.getLogView(DEFAULT_LOG_VIEW),
[]
);
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx
index 3024ff3d1bd06..ddbf4ae52788b 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx
@@ -14,9 +14,9 @@ import { EuiFlexGroup } from '@elastic/eui';
import { EuiFlexItem } from '@elastic/eui';
import { EuiButtonEmpty } from '@elastic/eui';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
+import { LogStream } from '@kbn/logs-shared-plugin/public';
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana';
import { TabContent, TabProps } from './shared';
-import { LogStream } from '../../../../../../components/log_stream';
import { useWaffleOptionsContext } from '../../../hooks/use_waffle_options';
import { findInventoryFields } from '../../../../../../../common/inventory_models';
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/saved_views.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/saved_views.tsx
index 4547b0dbb0147..feb5283a39dcb 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/saved_views.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/saved_views.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import { useInventoryViews } from '../../../../hooks/use_inventory_views';
import { SavedViewsToolbarControls } from '../../../../components/saved_views/toolbar_control';
-import { useWaffleViewState, WaffleViewState } from '../hooks/use_waffle_view_state';
+import { useWaffleViewState } from '../hooks/use_waffle_view_state';
export const SavedViews = () => {
const { viewState } = useWaffleViewState();
@@ -28,7 +28,7 @@ export const SavedViews = () => {
} = useInventoryViews();
return (
-
+ {
return true;
};
-export const DEFAULT_WAFFLE_FILTERS_STATE: WaffleFiltersState = { kind: 'kuery', expression: '' };
+export const DEFAULT_WAFFLE_FILTERS_STATE: InventoryFiltersState = {
+ kind: 'kuery',
+ expression: '',
+};
export const useWaffleFilters = () => {
const { createDerivedIndexPattern } = useSourceContext();
const indexPattern = createDerivedIndexPattern();
- const [urlState, setUrlState] = useUrlState({
+ const [urlState, setUrlState] = useUrlState({
defaultState: DEFAULT_WAFFLE_FILTERS_STATE,
decodeUrlState,
encodeUrlState,
urlStateKey: 'waffleFilter',
});
- const [state, setState] = useState(urlState);
+ const [state, setState] = useState(urlState);
useEffect(() => setUrlState(state), [setUrlState, state]);
@@ -61,7 +68,7 @@ export const useWaffleFilters = () => {
[setState]
);
- const applyFilterQuery = useCallback((filterQuery: WaffleFiltersState) => {
+ const applyFilterQuery = useCallback((filterQuery: InventoryFiltersState) => {
setState(filterQuery);
setFilterQueryDraft(filterQuery.expression);
}, []);
@@ -87,14 +94,10 @@ export const useWaffleFilters = () => {
};
};
-export const WaffleFiltersStateRT = rt.type({
- kind: rt.literal('kuery'),
- expression: rt.string,
-});
-
-export type WaffleFiltersState = rt.TypeOf;
-const encodeUrlState = WaffleFiltersStateRT.encode;
+// temporary
+export type WaffleFiltersState = InventoryFiltersState;
+const encodeUrlState = inventoryFiltersStateRT.encode;
const decodeUrlState = (value: unknown) =>
- pipe(WaffleFiltersStateRT.decode(value), fold(constant(undefined), identity));
+ pipe(inventoryFiltersStateRT.decode(value), fold(constant(undefined), identity));
export const WaffleFilters = createContainter(useWaffleFilters);
export const [WaffleFiltersProvider, useWaffleFiltersContext] = WaffleFilters;
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts
index 8767be4f8a27e..9151e591a09f1 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts
@@ -6,23 +6,25 @@
*/
import { useCallback, useState, useEffect } from 'react';
-import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
import createContainer from 'constate';
-import { useAlertPrefillContext } from '../../../../alerting/use_alert_prefill';
-import { InventoryColorPaletteRT } from '../../../../lib/lib';
+import { InventoryViewOptions } from '../../../../../common/inventory_views/types';
import {
+ type InventoryLegendOptions,
+ type InventoryOptionsState,
+ type InventorySortOption,
+ inventoryOptionsStateRT,
+} from '../../../../../common/inventory_views';
+import { useAlertPrefillContext } from '../../../../alerting/use_alert_prefill';
+import type {
SnapshotMetricInput,
SnapshotGroupBy,
SnapshotCustomMetricInput,
- SnapshotMetricInputRT,
- SnapshotGroupByRT,
- SnapshotCustomMetricInputRT,
} from '../../../../../common/http_api/snapshot_api';
import { useUrlState } from '../../../../utils/use_url_state';
-import { InventoryItemType, ItemTypeRT } from '../../../../../common/inventory_models/types';
+import type { InventoryItemType } from '../../../../../common/inventory_models/types';
export const DEFAULT_LEGEND: WaffleLegendOptions = {
palette: 'cool',
@@ -75,7 +77,7 @@ export const useWaffleOptions = () => {
);
const changeView = useCallback(
- (view: string) => setState((previous) => ({ ...previous, view })),
+ (view: string) => setState((previous) => ({ ...previous, view: view as InventoryViewOptions })),
[setState]
);
@@ -160,51 +162,15 @@ export const useWaffleOptions = () => {
};
};
-const WaffleLegendOptionsRT = rt.type({
- palette: InventoryColorPaletteRT,
- steps: rt.number,
- reverseColors: rt.boolean,
-});
-
-export type WaffleLegendOptions = rt.TypeOf;
-
-export const WaffleSortOptionRT = rt.type({
- by: rt.keyof({ name: null, value: null }),
- direction: rt.keyof({ asc: null, desc: null }),
-});
-
-export const WaffleOptionsStateRT = rt.intersection([
- rt.type({
- metric: SnapshotMetricInputRT,
- groupBy: SnapshotGroupByRT,
- nodeType: ItemTypeRT,
- view: rt.string,
- customOptions: rt.array(
- rt.type({
- text: rt.string,
- field: rt.string,
- })
- ),
- boundsOverride: rt.type({
- min: rt.number,
- max: rt.number,
- }),
- autoBounds: rt.boolean,
- accountId: rt.string,
- region: rt.string,
- customMetrics: rt.array(SnapshotCustomMetricInputRT),
- sort: WaffleSortOptionRT,
- }),
- rt.partial({ source: rt.string, legend: WaffleLegendOptionsRT, timelineOpen: rt.boolean }),
-]);
-
-export type WaffleSortOption = rt.TypeOf;
-export type WaffleOptionsState = rt.TypeOf;
-const encodeUrlState = (state: WaffleOptionsState) => {
- return WaffleOptionsStateRT.encode(state);
+export type WaffleLegendOptions = InventoryLegendOptions;
+export type WaffleSortOption = InventorySortOption;
+export type WaffleOptionsState = InventoryOptionsState;
+
+const encodeUrlState = (state: InventoryOptionsState) => {
+ return inventoryOptionsStateRT.encode(state);
};
const decodeUrlState = (value: unknown) => {
- const state = pipe(WaffleOptionsStateRT.decode(value), fold(constant(undefined), identity));
+ const state = pipe(inventoryOptionsStateRT.decode(value), fold(constant(undefined), identity));
if (state) {
state.source = 'url';
}
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts
index 6e685a6cc105f..c1ff4c67addbb 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts
@@ -6,17 +6,10 @@
*/
import { useCallback } from 'react';
-import {
- useWaffleOptionsContext,
- DEFAULT_WAFFLE_OPTIONS_STATE,
- WaffleOptionsState,
-} from './use_waffle_options';
+import { InventoryViewAttributes } from '../../../../../common/inventory_views';
+import { useWaffleOptionsContext, DEFAULT_WAFFLE_OPTIONS_STATE } from './use_waffle_options';
import { useWaffleTimeContext, DEFAULT_WAFFLE_TIME_STATE } from './use_waffle_time';
-import {
- useWaffleFiltersContext,
- DEFAULT_WAFFLE_FILTERS_STATE,
- WaffleFiltersState,
-} from './use_waffle_filters';
+import { useWaffleFiltersContext, DEFAULT_WAFFLE_FILTERS_STATE } from './use_waffle_filters';
export const DEFAULT_WAFFLE_VIEW_STATE: WaffleViewState = {
...DEFAULT_WAFFLE_OPTIONS_STATE,
@@ -65,8 +58,8 @@ export const useWaffleViewState = () => {
};
const onViewChange = useCallback(
- (newState) => {
- const attributes = newState.attributes as WaffleViewState;
+ (newState: { attributes: WaffleViewState }) => {
+ const attributes = newState.attributes;
setWaffleOptionsState({
sort: attributes.sort,
@@ -102,8 +95,7 @@ export const useWaffleViewState = () => {
};
};
-export type WaffleViewState = WaffleOptionsState & {
- time: number;
- autoReload: boolean;
- filterQuery: WaffleFiltersState;
-};
+export type WaffleViewState = Omit<
+ InventoryViewAttributes,
+ 'name' | 'isDefault' | 'isStatic' | 'source'
+>;
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_legend.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_legend.ts
index c7015764ddf24..cd37b0d8aab25 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_legend.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_legend.ts
@@ -5,7 +5,10 @@
* 2.0.
*/
-import { InventoryColorPalette, InfraWaffleMapSteppedGradientLegend } from '../../../../lib/lib';
+import type {
+ InventoryColorPalette,
+ InfraWaffleMapSteppedGradientLegend,
+} from '../../../../lib/lib';
import { getColorPalette } from './get_color_palette';
export const createLegend = (
diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts
index 73b09017fecc0..9b48b9391f9bd 100644
--- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts
@@ -13,7 +13,7 @@ import * as rt from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import { constant, identity } from 'fp-ts/lib/function';
-import { replaceStateKeyInQueryString } from '../../../../../common/log_views';
+import { replaceStateKeyInQueryString } from '../../../../../common/url_state_storage_service';
import { useUrlState } from '../../../../utils/use_url_state';
const parseRange = (range: MetricsTimeInput) => {
diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/saved_views.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/saved_views.tsx
index 2d329f121f008..ddce0eac506fe 100644
--- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/saved_views.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/saved_views.tsx
@@ -31,7 +31,7 @@ export const SavedViews = ({ viewState }: Props) => {
} = useMetricsExplorerViews();
return (
-
+
currentView={currentView}
views={views}
isFetchingViews={isFetchingViews}
diff --git a/x-pack/plugins/infra/public/plugin.ts b/x-pack/plugins/infra/public/plugin.ts
index 36c873c3b22df..7ea1dbdfa7cd2 100644
--- a/x-pack/plugins/infra/public/plugin.ts
+++ b/x-pack/plugins/infra/public/plugin.ts
@@ -19,7 +19,6 @@ import { ObservabilityTriggerId } from '@kbn/observability-shared-plugin/common'
import { BehaviorSubject, combineLatest, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { DISCOVER_APP_TARGET, LOGS_APP_TARGET } from '../common/constants';
-import { defaultLogViewsStaticConfig } from '../common/log_views';
import { InfraPublicConfig } from '../common/plugin_config_types';
import { createInventoryMetricRuleType } from './alerting/inventory';
import { createLogThresholdRuleType } from './alerting/log_threshold';
@@ -39,7 +38,6 @@ import {
import { createMetricsFetchData, createMetricsHasData } from './metrics_overview_fetchers';
import { registerFeatures } from './register_feature';
import { InventoryViewsService } from './services/inventory_views';
-import { LogViewsService } from './services/log_views';
import { MetricsExplorerViewsService } from './services/metrics_explorer_views';
import { TelemetryService } from './services/telemetry';
import {
@@ -56,7 +54,6 @@ import { getLogsHasDataFetcher, getLogsOverviewDataFetcher } from './utils/logs_
export class Plugin implements InfraClientPluginClass {
public config: InfraPublicConfig;
private inventoryViews: InventoryViewsService;
- private logViews: LogViewsService;
private metricsExplorerViews: MetricsExplorerViewsService;
private telemetry: TelemetryService;
private locators?: InfraLocators;
@@ -68,10 +65,6 @@ export class Plugin implements InfraClientPluginClass {
this.config = context.config.get();
this.inventoryViews = new InventoryViewsService();
- this.logViews = new LogViewsService({
- messageFields:
- this.config.sources?.default?.fields?.message ?? defaultLogViewsStaticConfig.messageFields,
- });
this.metricsExplorerViews = new MetricsExplorerViewsService();
this.telemetry = new TelemetryService();
this.appTarget = this.config.logs.app_target;
@@ -106,6 +99,10 @@ export class Plugin implements InfraClientPluginClass {
fetchData: createMetricsFetchData(core.getStartServices),
});
+ pluginsSetup.logsShared.logViews.setLogViewsStaticConfig({
+ messageFields: this.config.sources?.default?.fields?.message,
+ });
+
const startDep$AndHostViewFlag$ = combineLatest([
from(core.getStartServices()),
core.uiSettings.get$(enableInfrastructureHostsView),
@@ -342,12 +339,6 @@ export class Plugin implements InfraClientPluginClass {
http: core.http,
});
- const logViews = this.logViews.start({
- http: core.http,
- dataViews: plugins.dataViews,
- search: plugins.data.search,
- });
-
const metricsExplorerViews = this.metricsExplorerViews.start({
http: core.http,
});
@@ -356,7 +347,6 @@ export class Plugin implements InfraClientPluginClass {
const startContract: InfraClientStartExports = {
inventoryViews,
- logViews,
metricsExplorerViews,
telemetry,
locators: this.locators!,
diff --git a/x-pack/plugins/infra/public/services/inventory_views/inventory_views_client.ts b/x-pack/plugins/infra/public/services/inventory_views/inventory_views_client.ts
index eeabd15e60a4b..5cfda02fa4c17 100644
--- a/x-pack/plugins/infra/public/services/inventory_views/inventory_views_client.ts
+++ b/x-pack/plugins/infra/public/services/inventory_views/inventory_views_client.ts
@@ -9,15 +9,18 @@ import { HttpStart } from '@kbn/core/public';
import {
CreateInventoryViewAttributesRequestPayload,
createInventoryViewRequestPayloadRT,
+ CreateInventoryViewResponsePayload,
+ FindInventoryViewResponsePayload,
findInventoryViewResponsePayloadRT,
+ GetInventoryViewResposePayload,
getInventoryViewUrl,
inventoryViewResponsePayloadRT,
UpdateInventoryViewAttributesRequestPayload,
+ UpdateInventoryViewResponsePayload,
} from '../../../common/http_api/latest';
import {
DeleteInventoryViewError,
FetchInventoryViewError,
- InventoryView,
UpsertInventoryViewError,
} from '../../../common/inventory_views';
import { decodeOrThrow } from '../../../common/runtime_types';
@@ -26,7 +29,7 @@ import { IInventoryViewsClient } from './types';
export class InventoryViewsClient implements IInventoryViewsClient {
constructor(private readonly http: HttpStart) {}
- async findInventoryViews(): Promise {
+ async findInventoryViews(): Promise {
const response = await this.http.get(getInventoryViewUrl()).catch((error) => {
throw new FetchInventoryViewError(`Failed to fetch inventory views: ${error}`);
});
@@ -40,7 +43,7 @@ export class InventoryViewsClient implements IInventoryViewsClient {
return data;
}
- async getInventoryView(inventoryViewId: string): Promise {
+ async getInventoryView(inventoryViewId: string): Promise {
const response = await this.http.get(getInventoryViewUrl(inventoryViewId)).catch((error) => {
throw new FetchInventoryViewError(
`Failed to fetch inventory view "${inventoryViewId}": ${error}`
@@ -60,7 +63,7 @@ export class InventoryViewsClient implements IInventoryViewsClient {
async createInventoryView(
inventoryViewAttributes: CreateInventoryViewAttributesRequestPayload
- ): Promise {
+ ): Promise {
const response = await this.http
.post(getInventoryViewUrl(), {
body: JSON.stringify(
@@ -85,7 +88,7 @@ export class InventoryViewsClient implements IInventoryViewsClient {
async updateInventoryView(
inventoryViewId: string,
inventoryViewAttributes: UpdateInventoryViewAttributesRequestPayload
- ): Promise {
+ ): Promise {
const response = await this.http
.put(getInventoryViewUrl(inventoryViewId), {
body: JSON.stringify(
diff --git a/x-pack/plugins/infra/public/services/inventory_views/types.ts b/x-pack/plugins/infra/public/services/inventory_views/types.ts
index 573c144e9c441..e2e26e6ef7f5b 100644
--- a/x-pack/plugins/infra/public/services/inventory_views/types.ts
+++ b/x-pack/plugins/infra/public/services/inventory_views/types.ts
@@ -8,9 +8,12 @@
import { HttpStart } from '@kbn/core/public';
import {
CreateInventoryViewAttributesRequestPayload,
+ CreateInventoryViewResponsePayload,
+ FindInventoryViewResponsePayload,
+ GetInventoryViewResposePayload,
UpdateInventoryViewAttributesRequestPayload,
+ UpdateInventoryViewResponsePayload,
} from '../../../common/http_api/latest';
-import type { InventoryView } from '../../../common/inventory_views';
export type InventoryViewsServiceSetup = void;
@@ -23,14 +26,14 @@ export interface InventoryViewsServiceStartDeps {
}
export interface IInventoryViewsClient {
- findInventoryViews(): Promise;
- getInventoryView(inventoryViewId: string): Promise;
+ findInventoryViews(): Promise;
+ getInventoryView(inventoryViewId: string): Promise;
createInventoryView(
inventoryViewAttributes: CreateInventoryViewAttributesRequestPayload
- ): Promise;
+ ): Promise;
updateInventoryView(
inventoryViewId: string,
inventoryViewAttributes: UpdateInventoryViewAttributesRequestPayload
- ): Promise;
+ ): Promise;
deleteInventoryView(inventoryViewId: string): Promise;
}
diff --git a/x-pack/plugins/infra/public/test_utils/entries.ts b/x-pack/plugins/infra/public/test_utils/entries.ts
index 4dc3732fd49d5..35dad808cdf4f 100644
--- a/x-pack/plugins/infra/public/test_utils/entries.ts
+++ b/x-pack/plugins/infra/public/test_utils/entries.ts
@@ -6,16 +6,7 @@
*/
import faker from 'faker';
-import { LogEntry } from '../../common/log_entry';
-import { LogViewColumnConfiguration } from '../../common/log_views';
-
-export const ENTRIES_EMPTY = {
- data: {
- entries: [],
- topCursor: null,
- bottomCursor: null,
- },
-};
+import { LogEntry, LogViewColumnConfiguration } from '@kbn/logs-shared-plugin/common';
export function generateFakeEntries(
count: number,
diff --git a/x-pack/plugins/infra/public/types.ts b/x-pack/plugins/infra/public/types.ts
index 5c78c1534a5a4..488d92573e746 100644
--- a/x-pack/plugins/infra/public/types.ts
+++ b/x-pack/plugins/infra/public/types.ts
@@ -38,6 +38,10 @@ import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import { CasesUiStart } from '@kbn/cases-plugin/public';
import { DiscoverStart } from '@kbn/discover-plugin/public';
import { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public';
+import {
+ LogsSharedClientSetupExports,
+ LogsSharedClientStartExports,
+} from '@kbn/logs-shared-plugin/public';
import { FieldFormatsSetup, FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { LicensingPluginSetup, LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { UnwrapPromise } from '../common/utility_types';
@@ -46,7 +50,6 @@ import type {
UseNodeMetricsTableOptions,
} from './components/infrastructure_node_metrics_tables/shared';
import { InventoryViewsServiceStart } from './services/inventory_views';
-import { LogViewsServiceStart } from './services/log_views';
import { MetricsExplorerViewsServiceStart } from './services/metrics_explorer_views';
import { ITelemetryClient } from './services/telemetry';
import type { InfraLocators } from '../common/locators';
@@ -58,7 +61,6 @@ export interface InfraClientSetupExports {
export interface InfraClientStartExports {
inventoryViews: InventoryViewsServiceStart;
- logViews: LogViewsServiceStart;
metricsExplorerViews: MetricsExplorerViewsServiceStart;
telemetry: ITelemetryClient;
locators: InfraLocators;
@@ -74,6 +76,7 @@ export interface InfraClientStartExports {
}
export interface InfraClientSetupDeps {
+ logsShared: LogsSharedClientSetupExports;
home?: HomePublicPluginSetup;
observability: ObservabilityPublicSetup;
observabilityShared: ObservabilitySharedPluginSetup;
@@ -97,6 +100,7 @@ export interface InfraClientStartDeps {
embeddable?: EmbeddableStart;
kibanaVersion?: string;
lens: LensPublicStart;
+ logsShared: LogsSharedClientStartExports;
ml: MlPluginStart;
observability: ObservabilityPublicStart;
observabilityShared: ObservabilitySharedPluginStart;
diff --git a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts
index 5ebacc0e7773b..186e4c9bc1ed0 100644
--- a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts
+++ b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts
@@ -12,7 +12,7 @@ import {
FetchDataParams,
LogsFetchDataResponse,
} from '@kbn/observability-plugin/public';
-import { DEFAULT_LOG_VIEW } from '../../common/log_views';
+import { DEFAULT_LOG_VIEW } from '@kbn/logs-shared-plugin/common';
import { TIMESTAMP_FIELD } from '../../common/constants';
import { InfraClientStartDeps, InfraClientStartServicesAccessor } from '../types';
@@ -38,9 +38,11 @@ type StatsAndSeries = Pick;
export function getLogsHasDataFetcher(getStartServices: InfraClientStartServicesAccessor) {
return async () => {
- const [, , { logViews }] = await getStartServices();
- const resolvedLogView = await logViews.client.getResolvedLogView(DEFAULT_LOG_VIEW);
- const logViewStatus = await logViews.client.getResolvedLogViewStatus(resolvedLogView);
+ const [, { logsShared }] = await getStartServices();
+ const resolvedLogView = await logsShared.logViews.client.getResolvedLogView(DEFAULT_LOG_VIEW);
+ const logViewStatus = await logsShared.logViews.client.getResolvedLogViewStatus(
+ resolvedLogView
+ );
const hasData = logViewStatus.index === 'available';
const indices = resolvedLogView.indices;
@@ -56,8 +58,8 @@ export function getLogsOverviewDataFetcher(
getStartServices: InfraClientStartServicesAccessor
): FetchData {
return async (params) => {
- const [, { data }, { logViews }] = await getStartServices();
- const resolvedLogView = await logViews.client.getResolvedLogView(DEFAULT_LOG_VIEW);
+ const [, { data, logsShared }] = await getStartServices();
+ const resolvedLogView = await logsShared.logViews.client.getResolvedLogView(DEFAULT_LOG_VIEW);
const { stats, series } = await fetchLogsOverview(
{
diff --git a/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts b/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts
index dad3dedc4bb46..85d7f14586913 100644
--- a/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts
+++ b/x-pack/plugins/infra/public/utils/logs_overview_fetches.test.ts
@@ -6,10 +6,11 @@
*/
import { CoreStart } from '@kbn/core/public';
-import { of } from 'rxjs';
import { coreMock } from '@kbn/core/public/mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
-import { createResolvedLogViewMock } from '../../common/log_views/resolved_log_view.mock';
+import { createResolvedLogViewMock } from '@kbn/logs-shared-plugin/common/mocks';
+import { createLogsSharedPluginStartMock } from '@kbn/logs-shared-plugin/public/mocks';
+import { of } from 'rxjs';
import { createInfraPluginStartMock } from '../mocks';
import { InfraClientStartDeps, InfraClientStartExports } from '../types';
import { getLogsHasDataFetcher, getLogsOverviewDataFetcher } from './logs_overview_fetchers';
@@ -24,10 +25,18 @@ const DEFAULT_PARAMS = {
function setup() {
const core = coreMock.createStart();
const data = dataPluginMock.createStartContract();
+ const logsShared = createLogsSharedPluginStartMock();
const pluginStart = createInfraPluginStartMock();
- const pluginDeps = { data } as InfraClientStartDeps;
+ const pluginDeps = { data, logsShared } as unknown as InfraClientStartDeps;
const dataSearch = data.search.search as jest.MockedFunction;
+ const getResolvedLogView = logsShared.logViews.client.getResolvedLogView as jest.MockedFunction<
+ typeof logsShared.logViews.client.getResolvedLogView
+ >;
+ const getResolvedLogViewStatus = logsShared.logViews.client
+ .getResolvedLogViewStatus as jest.MockedFunction<
+ typeof logsShared.logViews.client.getResolvedLogViewStatus
+ >;
const mockedGetStartServices = jest.fn(() =>
Promise.resolve<[CoreStart, InfraClientStartDeps, InfraClientStartExports]>([
@@ -36,7 +45,15 @@ function setup() {
pluginStart,
])
);
- return { core, dataSearch, mockedGetStartServices, pluginStart };
+ return {
+ core,
+ dataSearch,
+ mockedGetStartServices,
+ pluginDeps,
+ pluginStart,
+ getResolvedLogView,
+ getResolvedLogViewStatus,
+ };
}
describe('Logs UI Observability Homepage Functions', () => {
@@ -46,62 +63,59 @@ describe('Logs UI Observability Homepage Functions', () => {
describe('getLogsHasDataFetcher()', () => {
it('should return true when non-empty indices exist', async () => {
- const { mockedGetStartServices, pluginStart } = setup();
+ const { mockedGetStartServices, pluginDeps, getResolvedLogView, getResolvedLogViewStatus } =
+ setup();
- pluginStart.logViews.client.getResolvedLogView.mockResolvedValue(
- createResolvedLogViewMock({ indices: 'test-index' })
- );
- pluginStart.logViews.client.getResolvedLogViewStatus.mockResolvedValue({
- index: 'available',
- });
+ getResolvedLogView.mockResolvedValue(createResolvedLogViewMock({ indices: 'test-index' }));
+ getResolvedLogViewStatus.mockResolvedValue({ index: 'available' });
const hasData = getLogsHasDataFetcher(mockedGetStartServices);
const response = await hasData();
- expect(pluginStart.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(1);
+ expect(pluginDeps.logsShared.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(
+ 1
+ );
expect(response).toEqual({ hasData: true, indices: 'test-index' });
});
it('should return false when only empty indices exist', async () => {
- const { mockedGetStartServices, pluginStart } = setup();
+ const { mockedGetStartServices, pluginDeps, getResolvedLogView, getResolvedLogViewStatus } =
+ setup();
- pluginStart.logViews.client.getResolvedLogView.mockResolvedValue(
- createResolvedLogViewMock({ indices: 'test-index' })
- );
- pluginStart.logViews.client.getResolvedLogViewStatus.mockResolvedValue({
- index: 'empty',
- });
+ getResolvedLogView.mockResolvedValue(createResolvedLogViewMock({ indices: 'test-index' }));
+ getResolvedLogViewStatus.mockResolvedValue({ index: 'empty' });
const hasData = getLogsHasDataFetcher(mockedGetStartServices);
const response = await hasData();
- expect(pluginStart.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(1);
+ expect(pluginDeps.logsShared.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(
+ 1
+ );
expect(response).toEqual({ hasData: false, indices: 'test-index' });
});
it('should return false when no index exists', async () => {
- const { mockedGetStartServices, pluginStart } = setup();
+ const { mockedGetStartServices, pluginDeps, getResolvedLogView, getResolvedLogViewStatus } =
+ setup();
- pluginStart.logViews.client.getResolvedLogView.mockResolvedValue(
- createResolvedLogViewMock({ indices: 'test-index' })
- );
- pluginStart.logViews.client.getResolvedLogViewStatus.mockResolvedValue({
- index: 'missing',
- });
+ getResolvedLogView.mockResolvedValue(createResolvedLogViewMock({ indices: 'test-index' }));
+ getResolvedLogViewStatus.mockResolvedValue({ index: 'missing' });
const hasData = getLogsHasDataFetcher(mockedGetStartServices);
const response = await hasData();
- expect(pluginStart.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(1);
+ expect(pluginDeps.logsShared.logViews.client.getResolvedLogViewStatus).toHaveBeenCalledTimes(
+ 1
+ );
expect(response).toEqual({ hasData: false, indices: 'test-index' });
});
});
describe('getLogsOverviewDataFetcher()', () => {
it('should work', async () => {
- const { mockedGetStartServices, dataSearch, pluginStart } = setup();
+ const { mockedGetStartServices, dataSearch, getResolvedLogView } = setup();
- pluginStart.logViews.client.getResolvedLogView.mockResolvedValue(createResolvedLogViewMock());
+ getResolvedLogView.mockResolvedValue(createResolvedLogViewMock());
dataSearch.mockReturnValue(
of({
diff --git a/x-pack/plugins/infra/public/utils/url_state.tsx b/x-pack/plugins/infra/public/utils/url_state.tsx
index 8fc4961bba221..a07b8afbc68f8 100644
--- a/x-pack/plugins/infra/public/utils/url_state.tsx
+++ b/x-pack/plugins/infra/public/utils/url_state.tsx
@@ -11,7 +11,7 @@ import React from 'react';
import { Route } from '@kbn/shared-ux-router';
import { decode, RisonValue } from '@kbn/rison';
import { throttle } from 'lodash';
-import { replaceStateKeyInQueryString } from '../../common/log_views';
+import { replaceStateKeyInQueryString } from '../../common/url_state_storage_service';
interface UrlStateContainerProps {
urlState: UrlState | undefined;
diff --git a/x-pack/plugins/infra/public/utils/use_url_state.ts b/x-pack/plugins/infra/public/utils/use_url_state.ts
index 3d269f9eb058c..8fc03d2d9dda2 100644
--- a/x-pack/plugins/infra/public/utils/use_url_state.ts
+++ b/x-pack/plugins/infra/public/utils/use_url_state.ts
@@ -10,7 +10,7 @@ import { Location } from 'history';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { decode, RisonValue } from '@kbn/rison';
import { useHistory } from 'react-router-dom';
-import { replaceStateKeyInQueryString } from '../../common/log_views';
+import { replaceStateKeyInQueryString } from '../../common/url_state_storage_service';
export const useUrlState = ({
defaultState,
diff --git a/x-pack/plugins/infra/server/features.ts b/x-pack/plugins/infra/server/features.ts
index a1b1a7b729193..e9fec4a5b4f5d 100644
--- a/x-pack/plugins/infra/server/features.ts
+++ b/x-pack/plugins/infra/server/features.ts
@@ -7,6 +7,7 @@
import { i18n } from '@kbn/i18n';
import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
+import { logViewSavedObjectName } from '@kbn/logs-shared-plugin/server';
import { LOG_DOCUMENT_COUNT_RULE_TYPE_ID } from '../common/alerting/logs/log_threshold/types';
import {
METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID,
@@ -14,7 +15,6 @@ import {
} from '../common/alerting/metrics';
import { LOGS_FEATURE_ID, METRICS_FEATURE_ID } from '../common/constants';
import { infraSourceConfigurationSavedObjectName } from './lib/sources/saved_object_type';
-import { logViewSavedObjectName } from './saved_objects';
export const METRICS_FEATURE = {
id: METRICS_FEATURE_ID,
diff --git a/x-pack/plugins/infra/server/infra_server.ts b/x-pack/plugins/infra/server/infra_server.ts
index 4d29974ceb75f..e54713faba76a 100644
--- a/x-pack/plugins/infra/server/infra_server.ts
+++ b/x-pack/plugins/infra/server/infra_server.ts
@@ -22,12 +22,6 @@ import {
initValidateLogAnalysisDatasetsRoute,
initValidateLogAnalysisIndicesRoute,
} from './routes/log_analysis';
-import {
- initLogEntriesHighlightsRoute,
- initLogEntriesSummaryHighlightsRoute,
- initLogEntriesSummaryRoute,
-} from './routes/log_entries';
-import { initLogViewRoutes } from './routes/log_views';
import { initMetadataRoute } from './routes/metadata';
import { initMetricsAPIRoute } from './routes/metrics_api';
import { initMetricExplorerRoute } from './routes/metrics_explorer';
@@ -55,10 +49,6 @@ export const initInfraServer = (libs: InfraBackendLibs) => {
initValidateLogAnalysisDatasetsRoute(libs);
initValidateLogAnalysisIndicesRoute(libs);
initGetLogEntryExamplesRoute(libs);
- initLogEntriesHighlightsRoute(libs);
- initLogEntriesSummaryRoute(libs);
- initLogEntriesSummaryHighlightsRoute(libs);
- initLogViewRoutes(libs);
initMetricExplorerRoute(libs);
initMetricsExplorerViewRoutes(libs);
initMetricsAPIRoute(libs);
diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts
index 22351750fbab4..61c8b935806ac 100644
--- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts
+++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts
@@ -24,6 +24,7 @@ import { PluginSetupContract as AlertingPluginContract } from '@kbn/alerting-plu
import { MlPluginSetup } from '@kbn/ml-plugin/server';
import { RuleRegistryPluginSetupContract } from '@kbn/rule-registry-plugin/server';
import { ObservabilityPluginSetup } from '@kbn/observability-plugin/server';
+import { LogsSharedPluginSetup, LogsSharedPluginStart } from '@kbn/logs-shared-plugin/server';
import { VersionedRouteConfig } from '@kbn/core-http-server';
export interface InfraServerPluginSetupDeps {
@@ -38,11 +39,13 @@ export interface InfraServerPluginSetupDeps {
usageCollection: UsageCollectionSetup;
visTypeTimeseries: VisTypeTimeseriesSetup;
ml?: MlPluginSetup;
+ logsShared: LogsSharedPluginSetup;
}
export interface InfraServerPluginStartDeps {
data: DataPluginStart;
dataViews: DataViewsPluginStart;
+ logsShared: LogsSharedPluginStart;
}
export interface CallWithRequestParams extends estypes.RequestBase {
diff --git a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.test.ts b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.test.ts
index 0860da5c7a184..d0a301726138e 100644
--- a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.test.ts
+++ b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.test.ts
@@ -29,6 +29,7 @@ import { createInventoryMetricThresholdExecutor } from './inventory_metric_thres
import { ConditionResult } from './evaluate_condition';
import { InfraBackendLibs } from '../../infra_types';
import { infraPluginMock } from '../../../mocks';
+import { logsSharedPluginMock } from '@kbn/logs-shared-plugin/server/mocks';
jest.mock('./evaluate_condition', () => ({ evaluateCondition: jest.fn() }));
@@ -121,7 +122,7 @@ const mockLibs = {
},
getStartServices: () => [
null,
- infraPluginMock.createSetupContract(),
+ { logsShared: logsSharedPluginMock.createStartContract() },
infraPluginMock.createStartContract(),
],
configuration: createMockStaticConfiguration({}),
diff --git a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts
index 5a1dba9faae14..0754c79a99688 100644
--- a/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts
+++ b/x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/inventory_metric_threshold_executor.ts
@@ -162,8 +162,8 @@ export const createInventoryMetricThresholdExecutor = (libs: InfraBackendLibs) =
}
const source = await libs.sources.getSourceConfiguration(savedObjectsClient, sourceId);
- const [, , { logViews }] = await libs.getStartServices();
- const logQueryFields: LogQueryFields | undefined = await logViews
+ const [, { logsShared }] = await libs.getStartServices();
+ const logQueryFields: LogQueryFields | undefined = await logsShared.logViews
.getClient(savedObjectsClient, esClient)
.getResolvedLogView({
type: 'log-view-reference',
diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts
index 97c43ea578e73..f54334ef22e5c 100644
--- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts
+++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts
@@ -6,6 +6,7 @@
*/
import { i18n } from '@kbn/i18n';
+import { ResolvedLogView } from '@kbn/logs-shared-plugin/common';
import {
ExecutionTimeRange,
GroupedSearchQueryResponse,
@@ -19,7 +20,6 @@ import {
Point,
Series,
} from '../../../../common/http_api';
-import { ResolvedLogView } from '../../../../common/log_views';
import { decodeOrThrow } from '../../../../common/runtime_types';
import type { InfraPluginRequestHandlerContext } from '../../../types';
import { KibanaFramework } from '../../adapters/framework/kibana_framework_adapter';
diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts
index 7091fc62a2bba..9b93e021ae8f1 100644
--- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts
+++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts
@@ -201,12 +201,12 @@ export const createLogThresholdExecutor = (libs: InfraBackendLibs) =>
return alert;
};
- const [, , { logViews }] = await libs.getStartServices();
+ const [, { logsShared }] = await libs.getStartServices();
try {
const validatedParams = decodeOrThrow(ruleParamsRT)(params);
- const { indices, timestampField, runtimeMappings } = await logViews
+ const { indices, timestampField, runtimeMappings } = await logsShared.logViews
.getClient(savedObjectsClient, scopedClusterClient.asCurrentUser)
.getResolvedLogView(validatedParams.logView);
diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_references_manager.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_references_manager.ts
index 7a44311b40fcd..12b67b6f260e4 100644
--- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_references_manager.ts
+++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_references_manager.ts
@@ -6,9 +6,9 @@
*/
import type { SavedObjectReference } from '@kbn/core-saved-objects-common';
-import { logViewSavedObjectName } from '../../../saved_objects';
+import { logViewReferenceRT } from '@kbn/logs-shared-plugin/common';
+import { logViewSavedObjectName } from '@kbn/logs-shared-plugin/server';
import { RuleParams, ruleParamsRT } from '../../../../common/alerting/logs/log_threshold';
-import { logViewReferenceRT } from '../../../../common/log_views';
import { decodeOrThrow } from '../../../../common/runtime_types';
export const LOG_VIEW_REFERENCE_NAME = 'log-view-reference-0';
diff --git a/x-pack/plugins/infra/server/lib/infra_types.ts b/x-pack/plugins/infra/server/lib/infra_types.ts
index f9fe976f692a5..e31bad1b5ffeb 100644
--- a/x-pack/plugins/infra/server/lib/infra_types.ts
+++ b/x-pack/plugins/infra/server/lib/infra_types.ts
@@ -10,18 +10,18 @@ import type { IBasePath } from '@kbn/core/server';
import type { handleEsError } from '@kbn/es-ui-shared-plugin/server';
import type { AlertsLocatorParams } from '@kbn/observability-plugin/common';
import type { LocatorPublic } from '@kbn/share-plugin/common';
+import type { ILogsSharedLogEntriesDomain } from '@kbn/logs-shared-plugin/server';
import { RulesServiceSetup } from '../services/rules';
import { InfraConfig, InfraPluginStartServicesAccessor } from '../types';
import { KibanaFramework } from './adapters/framework/kibana_framework_adapter';
import { InfraFieldsDomain } from './domains/fields_domain';
-import { InfraLogEntriesDomain } from './domains/log_entries_domain';
import { InfraMetricsDomain } from './domains/metrics_domain';
import { InfraSources } from './sources';
import { InfraSourceStatus } from './source_status';
export interface InfraDomainLibs {
fields: InfraFieldsDomain;
- logEntries: InfraLogEntriesDomain;
+ logEntries: ILogsSharedLogEntriesDomain;
metrics: InfraMetricsDomain;
}
diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts
index b17afa68d2d4d..591376450be38 100644
--- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts
+++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts
@@ -6,6 +6,7 @@
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
+import { PersistedLogViewReference, ResolvedLogView } from '@kbn/logs-shared-plugin/common';
import {
AnomaliesSort,
getJobId,
@@ -16,7 +17,6 @@ import {
logEntryRateJobTypes,
Pagination,
} from '../../../common/log_analysis';
-import { PersistedLogViewReference, ResolvedLogView } from '../../../common/log_views';
import { startTracingSpan, TracingSpan } from '../../../common/performance_tracing';
import { decodeOrThrow } from '../../../common/runtime_types';
import type {
diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts
index d8eb18e4890b5..88678f4c79c53 100644
--- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts
+++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts
@@ -7,6 +7,11 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ElasticsearchClient } from '@kbn/core/server';
+import {
+ LogEntryContext,
+ PersistedLogViewReference,
+ ResolvedLogView,
+} from '@kbn/logs-shared-plugin/common';
import {
CategoriesSort,
compareDatasetsByMaximumAnomalyScore,
@@ -14,8 +19,6 @@ import {
jobCustomSettingsRT,
logEntryCategoriesJobTypes,
} from '../../../common/log_analysis';
-import { LogEntryContext } from '../../../common/log_entry';
-import { PersistedLogViewReference, ResolvedLogView } from '../../../common/log_views';
import { startTracingSpan } from '../../../common/performance_tracing';
import { decodeOrThrow } from '../../../common/runtime_types';
import type { MlAnomalyDetectors, MlSystem } from '../../types';
diff --git a/x-pack/plugins/infra/server/mocks.ts b/x-pack/plugins/infra/server/mocks.ts
index 7e5a349cb1e01..a15575572a076 100644
--- a/x-pack/plugins/infra/server/mocks.ts
+++ b/x-pack/plugins/infra/server/mocks.ts
@@ -5,18 +5,21 @@
* 2.0.
*/
-import { createInventoryViewsServiceStartMock } from './services/inventory_views/inventory_views_service.mock';
import {
- createLogViewsServiceSetupMock,
- createLogViewsServiceStartMock,
-} from './services/log_views/log_views_service.mock';
-import { createMetricsExplorerViewsServiceStartMock } from './services/metrics_explorer_views/metrics_explorer_views_service.mock';
+ createInventoryViewsServiceSetupMock,
+ createInventoryViewsServiceStartMock,
+} from './services/inventory_views/inventory_views_service.mock';
+import {
+ createMetricsExplorerViewsServiceSetupMock,
+ createMetricsExplorerViewsServiceStartMock,
+} from './services/metrics_explorer_views/metrics_explorer_views_service.mock';
import { InfraPluginSetup, InfraPluginStart } from './types';
const createInfraSetupMock = () => {
const infraSetupMock: jest.Mocked = {
defineInternalSourceConfiguration: jest.fn(),
- logViews: createLogViewsServiceSetupMock(),
+ inventoryViews: createInventoryViewsServiceSetupMock(),
+ metricsExplorerViews: createMetricsExplorerViewsServiceSetupMock(),
};
return infraSetupMock;
@@ -26,7 +29,6 @@ const createInfraStartMock = () => {
const infraStartMock: jest.Mocked = {
getMetricIndices: jest.fn(),
inventoryViews: createInventoryViewsServiceStartMock(),
- logViews: createLogViewsServiceStartMock(),
metricsExplorerViews: createMetricsExplorerViewsServiceStartMock(),
};
return infraStartMock;
diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts
index 04fea926a2083..2449293dfa3aa 100644
--- a/x-pack/plugins/infra/server/plugin.ts
+++ b/x-pack/plugins/infra/server/plugin.ts
@@ -24,7 +24,6 @@ import {
LOGS_FEATURE_ID,
METRICS_FEATURE_ID,
} from '../common/constants';
-import { defaultLogViewsStaticConfig } from '../common/log_views';
import { publicConfigKeys } from '../common/plugin_config_types';
import { configDeprecations, getInfraDeprecationsFactory } from './deprecations';
import { LOGS_FEATURE, METRICS_FEATURE } from './features';
@@ -32,7 +31,6 @@ import { initInfraServer } from './infra_server';
import { FrameworkFieldsAdapter } from './lib/adapters/fields/framework_fields_adapter';
import { InfraServerPluginSetupDeps, InfraServerPluginStartDeps } from './lib/adapters/framework';
import { KibanaFramework } from './lib/adapters/framework/kibana_framework_adapter';
-import { InfraKibanaLogEntriesAdapter } from './lib/adapters/log_entries/kibana_log_entries_adapter';
import { KibanaMetricsAdapter } from './lib/adapters/metrics/kibana_metrics_adapter';
import { InfraElasticsearchSourceStatusAdapter } from './lib/adapters/source_status';
import { registerRuleTypes } from './lib/alerting';
@@ -41,20 +39,13 @@ import {
METRICS_RULES_ALERT_CONTEXT,
} from './lib/alerting/register_rule_types';
import { InfraFieldsDomain } from './lib/domains/fields_domain';
-import { InfraLogEntriesDomain } from './lib/domains/log_entries_domain';
import { InfraMetricsDomain } from './lib/domains/metrics_domain';
import { InfraBackendLibs, InfraDomainLibs } from './lib/infra_types';
import { makeGetMetricIndices } from './lib/metrics/make_get_metric_indices';
import { infraSourceConfigurationSavedObjectType, InfraSources } from './lib/sources';
import { InfraSourceStatus } from './lib/source_status';
-import {
- inventoryViewSavedObjectType,
- logViewSavedObjectType,
- metricsExplorerViewSavedObjectType,
-} from './saved_objects';
+import { inventoryViewSavedObjectType, metricsExplorerViewSavedObjectType } from './saved_objects';
import { InventoryViewsService } from './services/inventory_views';
-import { LogEntriesService } from './services/log_entries';
-import { LogViewsService } from './services/log_views';
import { MetricsExplorerViewsService } from './services/metrics_explorer_views';
import { RulesService } from './services/rules';
import {
@@ -65,6 +56,7 @@ import {
InfraPluginStart,
} from './types';
import { UsageCollector } from './usage/usage_collector';
+import { mapSourceToLogView } from './utils/map_source_to_log_view';
export const config: PluginConfigDescriptor = {
schema: schema.object({
@@ -138,7 +130,6 @@ export class InfraServerPlugin
private logsRules: RulesService;
private metricsRules: RulesService;
private inventoryViews: InventoryViewsService;
- private logViews: LogViewsService;
private metricsExplorerViews: MetricsExplorerViewsService;
constructor(context: PluginInitializerContext