Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs+] Implement Logs Dataset selector #159907

Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
9ab4529
feat(observability-logs): create plugin boilerplate
May 3, 2023
6bcf4f8
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 3, 2023
eeecf6f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 3, 2023
eea7560
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine May 3, 2023
1a6fb0b
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine May 3, 2023
d2a76bb
feat(observability-logs): try discover customization
May 3, 2023
559bc9c
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine May 3, 2023
c775f49
feat(observability-logs): update profileId
May 4, 2023
5d957b5
feat(observability-logs): add lazy loading and wip component
May 5, 2023
b68f33b
feat(observability-logs): add story for data stream selector
May 8, 2023
826cb03
feat(observability-logs): create nested panels
May 8, 2023
7ed6317
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 8, 2023
4d2d8cd
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 8, 2023
6660674
feat(observability-logs): apply customization to hide discover controls
May 9, 2023
c2bd77e
feat(observability-logs): add integration types
May 9, 2023
80b4dc2
feat(observability-logs): update integrations tree
May 9, 2023
cc23a2a
refactor(observability-logs): remove temporary index icon from data v…
May 9, 2023
d102bdb
feat(observability-logs): create integrations state machine folder
May 9, 2023
60436ed
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 9, 2023
bc227c2
refactor(observability-log): allow ad-hoc data view creation with specs
May 10, 2023
ee42d87
chore(observability-log): fix jest config
May 10, 2023
dd530db
chore(observability-log): add optimizer bundle limit
May 10, 2023
ec969ef
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 10, 2023
b39b901
feat(observability-log): draft integrations state machine
May 10, 2023
2220c29
feat(observability-log): adding integrations service
May 10, 2023
dd77c92
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 10, 2023
b3cb323
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 10, 2023
790df31
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 10, 2023
c47afcc
feat(observability-log): use integration service
May 12, 2023
01fb593
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 12, 2023
99fbea3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 12, 2023
5cf58f4
refactor(observability-log): rename integrations to data streams service
May 15, 2023
8391f03
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 15, 2023
fc535df
refactor(observability-log): move state machine actions
May 15, 2023
e549917
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 15, 2023
0ad11d1
refactor(observability-log): load more feature
May 15, 2023
0b8fdc7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 15, 2023
75f92c9
feat(infra): handle integrations search and load more guard
May 16, 2023
a5feafd
feat(infra): update url creator
May 16, 2023
9d050fb
feat(observability_logs): add search and cache
May 17, 2023
8a14ec7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 17, 2023
0d31cc6
refactor(observability_logs): handle missing uncategorized streams
May 17, 2023
d5e10df
feat(observability_logs): add data stream fetching and rendering logic
May 18, 2023
7aef4ca
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 18, 2023
02bd234
feat(observability_logs): implement dynamic and lazy load content
May 18, 2023
a00b747
feat(observability_logs): update local search
May 22, 2023
eca8902
feat(observability_logs): renames
May 22, 2023
3131c30
feat(observability_logs): update DataStreamSelector story
May 23, 2023
c8036c6
refactor(observability_logs): reorganize code
May 23, 2023
4bf3fa5
refactor(observability_logs): update search strategy
May 24, 2023
9d862ab
refactor(observability_logs): store initial search in cache
May 24, 2023
48ceaae
refactor(observability_logs): integrations status
May 24, 2023
e0b61ac
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 24, 2023
d8e3a31
refactor(observability_logs): improve typestates
May 25, 2023
9aee3b1
refactor(observability_logs): begin data stream selector state refactor
May 25, 2023
fc44fb6
refactor(observability_logs): wip on selector state machine
May 25, 2023
6a586a9
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 25, 2023
9ac5732
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 25, 2023
7211653
refactor(observability_logs): create internal state machine and split…
May 26, 2023
2b4f3e5
refactor(observability_logs): remove conflicting code
May 26, 2023
126ea3b
refactor(observability_logs): update data streams machine
May 26, 2023
474098e
refactor(observability_logs): update state machine restore search
May 29, 2023
e7e36e4
refactor(observability_logs): update storybook
May 29, 2023
bc0a6a2
refactor(observability_logs): small adjustments
May 29, 2023
8e884f0
refactor(observability_logs): minor changes
May 30, 2023
2a1495d
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 30, 2023
1e61e77
refactor(discover-log-explorer): rename plugin
Jun 7, 2023
7ef8c35
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 7, 2023
9654ba1
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 19, 2023
3bda2aa
refactor(discover-log-explorer): update missing renaming
Jun 19, 2023
bf1a324
refactor(discover-log-explorer): remove merge leftover
Jun 19, 2023
59a68f7
refactor(discover-log-explorer): remove server files
Jun 19, 2023
5e7a431
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 19, 2023
106e3a9
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 19, 2023
b498853
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Jun 19, 2023
073d301
refactor(discover-log-explorer): update exports
Jun 19, 2023
7a713e3
refactor(discover-log-explorer): track plugin i18n
Jun 19, 2023
c4fd397
refactor(discover-log-explorer): fix linting errors
Jun 19, 2023
e70e44c
refactor(discover-log-explorer): renaming to dataset
Jun 19, 2023
14614ee
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 19, 2023
5228ce2
refactor(discover-log-explorer): updat comment
Jun 19, 2023
3e0b492
refactor(discover-log-explorer): update limits
Jun 19, 2023
04fa5a9
refactor(discover-log-explorer): update types issues
Jun 19, 2023
906e7cd
refactor(discover-log-explorer): fix local search value
Jun 19, 2023
4054fc6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 19, 2023
f10030e
refactor(discover-log-explorer): fix missing test
Jun 20, 2023
ad5b2d5
Merge branch '2655-implement-log-data-stream-selector-rebased' of git…
Jun 20, 2023
b6b654b
refactor(discover-log-explorer): add fake test
Jun 20, 2023
32e8580
refactor(discover-log-explorer): remove fake test
Jun 20, 2023
1cc0d05
refactor(discover-log-explorer): reduce exports
Jun 20, 2023
3aebf92
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 20, 2023
4b98e27
refactor(discover-log-explorer): apply first changes
Jun 21, 2023
8109cc0
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
stratoula Jun 21, 2023
6f87200
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 21, 2023
b39f91c
fix(discover-log-explorer): routes usage
Jun 21, 2023
0818d3f
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 21, 2023
19e9be2
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 21, 2023
9caebee
docs(discover-log-explorer): update readme with quick introduction
Jun 21, 2023
8a5e765
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 22, 2023
20f4363
refactor(discover-log-explorer): reduce by ~80% initial plugin page l…
Jun 22, 2023
5c2b3c8
refactor(discover-log-explorer): abstract Integration and Dataset log…
Jun 22, 2023
3a06731
refactor(discover-log-explorer): remove mock data
Jun 22, 2023
f2aa421
refactor(discover-log-explorer): remove title name prefix
Jun 22, 2023
d2a4431
refactor(discover-log-explorer): minor changes
Jun 23, 2023
93d3537
refactor(discover-log-explorer): encode type for http request
Jun 23, 2023
cf48f3c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 23, 2023
aedf1bb
refactor(kbn-io-ts-utils): remove redundant type
Jun 23, 2023
007b64b
Merge branch '2655-implement-log-data-stream-selector-rebased' of git…
Jun 23, 2023
4462f41
refactor(discover-log-explorer): remove unused type
Jun 23, 2023
e950984
refactor(discover-log-explorer): use dataset id
Jun 23, 2023
645f3af
refactor(discover-log-explorer): update toSpec method signature
Jun 23, 2023
d4df21d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 23, 2023
51db3a1
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 23, 2023
455e53f
refactor(discover-log-explorer): change requests
Jun 26, 2023
bfaa5bc
refactor(discover-log-explorer): rename dataStreams for consistency
Jun 26, 2023
6c8b461
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 26, 2023
fa90bff
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 26, 2023
3c0acf7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 26, 2023
0a0d34a
refactor(discover-log-explorer): remove unused import
Jun 26, 2023
1351408
Merge branch '2655-implement-log-data-stream-selector-rebased' of git…
Jun 26, 2023
48bdc91
refactor(discover-log-explorer): fix missing encoding
Jun 26, 2023
ee0eeed
refactor(discover-log-explorer): update change requests
Jun 26, 2023
549cea8
refactor(discover-log-explorer): update params conversion
Jun 26, 2023
57aee54
refactor(discover-log-explorer): move dynamic to public/utils folder
Jun 26, 2023
eafd4b9
refactor(discover-log-explorer): update cache with LRU and hashObject
Jun 26, 2023
294602b
refactor(discover-log-explorer): update cache name
Jun 26, 2023
2bc90cd
refactor(discover-log-explorer): apply suggestion for entity list
Jun 26, 2023
e583a6f
refactor(discover-log-explorer): rename cache file
Jun 26, 2023
d8ff061
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 26, 2023
cfc5019
Update x-pack/plugins/discover_log_explorer/public/state_machines/int…
tonyghiani Jun 27, 2023
7a4dcd7
refactor(discover-log-explorer): update DoneEvent type
Jun 27, 2023
29f0d7b
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 27, 2023
e8ec06e
test(discover-log-explorer): add basic test to assert customizations …
Jun 27, 2023
edcb90e
refactor(discover-log-explorer): switch to pure action for maybeResto…
Jun 27, 2023
0ffdf0a
refactor(discover-log-explorer): move spyRef into buildIntegrationsTr…
Jun 27, 2023
389c097
refactor(discover-log-explorer): remove import
Jun 27, 2023
7d605a7
refactor(discover-log-explorer): add explicit close action
Jun 27, 2023
8184fb9
Update x-pack/test/functional/apps/discover_log_explorer/customizatio…
tonyghiani Jun 27, 2023
cbba119
refactor(discover-log-explorer): add copies changes ans move conditional
Jun 27, 2023
b214654
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 28, 2023
033af2d
refactor(discover-log-explorer): add storybook alias to buildkite
Jun 28, 2023
2893978
Merge branch 'main' into 2655-implement-log-data-stream-selector-rebased
tonyghiani Jun 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ packages/kbn-dev-utils @elastic/kibana-operations
examples/developer_examples @elastic/appex-sharedux
examples/discover_customization_examples @elastic/kibana-data-discovery
x-pack/plugins/discover_enhanced @elastic/kibana-data-discovery
x-pack/plugins/discover_log_explorer @elastic/infra-monitoring-ui
src/plugins/discover @elastic/kibana-data-discovery
packages/kbn-doc-links @elastic/kibana-docs
packages/kbn-docs-utils @elastic/kibana-operations
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ Plugin server-side only. Plugin has three main functions:
|Contains the enhancements to the OSS discover app.


|{kib-repo}blob/{branch}/x-pack/plugins/discover_log_explorer/README.md[discoverLogExplorer]
|This plugin exposes and registers Logs+ features.


|{kib-repo}blob/{branch}/x-pack/plugins/ecs_data_quality_dashboard/README.md[ecsDataQualityDashboard]
|This plugin implements (server) APIs used to render the content of the Data Quality dashboard.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
"@kbn/developer-examples-plugin": "link:examples/developer_examples",
"@kbn/discover-customization-examples-plugin": "link:examples/discover_customization_examples",
"@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced",
"@kbn/discover-log-explorer-plugin": "link:x-pack/plugins/discover_log_explorer",
"@kbn/discover-plugin": "link:src/plugins/discover",
"@kbn/doc-links": "link:packages/kbn-doc-links",
"@kbn/dom-drag-drop": "link:packages/kbn-dom-drag-drop",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pageLoadAssetSize:
devTools: 38637
discover: 99999
discoverEnhanced: 42730
discoverLogExplorer: 39045
embeddable: 87309
embeddableEnhanced: 22107
enterpriseSearch: 50858
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const storybookAliases = {
dashboard: 'src/plugins/dashboard/.storybook',
data: 'src/plugins/data/.storybook',
discover: 'src/plugins/discover/.storybook',
discover_log_explorer: 'x-pack/plugins/discover_log_explorer/.storybook',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add it to .buildkite/scripts/steps/storybooks/build_and_upload.ts as recently documented in #160473?

embeddable: 'src/plugins/embeddable/.storybook',
es_ui_shared: 'src/plugins/es_ui_shared/.storybook',
expression_error: 'src/plugins/expression_error/.storybook',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ describe('Test discover state actions', () => {
const { state } = await getState('/', savedSearchMock);
await state.actions.loadSavedSearch({ savedSearchId: savedSearchMock.id });
const unsubscribe = state.actions.initializeAndSync();
await state.actions.onCreateDefaultAdHocDataView('ad-hoc-test');
await state.actions.onCreateDefaultAdHocDataView({ title: 'ad-hoc-test' });
expect(state.appState.getState().index).toBe('ad-hoc-id');
expect(state.internalState.getState().adHocDataViews[0].id).toBe('ad-hoc-id');
unsubscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface DiscoverStateContainer {
* Used by the Data View Picker
* @param pattern
*/
onCreateDefaultAdHocDataView: (pattern: string) => Promise<void>;
onCreateDefaultAdHocDataView: (dataViewSpec: DataViewSpec) => Promise<void>;
/**
* Triggered when a new data view is created
* @param dataView
Expand Down Expand Up @@ -388,10 +388,8 @@ export function getDiscoverStateContainer({
};
};

const onCreateDefaultAdHocDataView = async (pattern: string) => {
const newDataView = await services.dataViews.create({
title: pattern,
});
const onCreateDefaultAdHocDataView = async (dataViewSpec: DataViewSpec) => {
const newDataView = await services.dataViews.create(dataViewSpec);
if (newDataView.fields.getByName('@timestamp')?.type === 'date') {
newDataView.timeFieldName = '@timestamp';
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/discover/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export function plugin(initializerContext: PluginInitializerContext) {
}

export type { ISearchEmbeddable, SearchInput } from './embeddable';
export type { DiscoverStateContainer } from './application/main/services/discover_state';
export { SEARCH_EMBEDDABLE_TYPE } from './embeddable';
export { loadSharingDataHelpers } from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import type { EuiButtonProps, EuiSelectableProps } from '@elastic/eui';
import type { DataView, DataViewListItem } from '@kbn/data-views-plugin/public';
import type { DataView, DataViewListItem, DataViewSpec } from '@kbn/data-views-plugin/public';
import type { AggregateQuery, Query } from '@kbn/es-query';
import { ChangeDataView } from './change_dataview';

Expand Down Expand Up @@ -73,7 +73,7 @@ export interface DataViewPickerProps {
*/
onDataViewCreated?: () => void;

onCreateDefaultAdHocDataView?: (pattern: string) => void;
onCreateDefaultAdHocDataView?: (dataViewSpec: DataViewSpec) => void;
/**
* List of the supported text based languages (SQL, ESQL) etc.
* Defined per application, if not provided, no text based languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { Fragment, useEffect, useRef, useState } from 'react';
import type { EuiSelectableProps } from '@elastic/eui';
import type { DataViewListItem } from '@kbn/data-views-plugin/public';
import type { DataViewListItem, DataViewSpec } from '@kbn/data-views-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { DataViewsList } from './dataview_list';
import { IUnifiedSearchPluginServices } from '../types';
Expand All @@ -22,7 +22,7 @@ export interface DataViewSelectorProps {
isTextBasedLangSelected: boolean;
setPopoverIsOpen: (isOpen: boolean) => void;
onChangeDataView: (dataViewId: string) => void;
onCreateDefaultAdHocDataView?: (pattern: string) => void;
onCreateDefaultAdHocDataView?: (dataViewSpec: DataViewSpec) => void;
}

export const DataViewSelector = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import React from 'react';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiSpacer, useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import { i18n } from '@kbn/i18n';
import { DataViewSpec } from '@kbn/data-views-plugin/common';

interface ExploreMatchingButtonProps {
noDataViewMatches: boolean;
indexMatches: number;
dataViewSearchString: string;
onCreateDefaultAdHocDataView?: (pattern: string) => void;
onCreateDefaultAdHocDataView?: (dataViewSpec: DataViewSpec) => void;
setPopoverIsOpen: (isOpen: boolean) => void;
}

Expand Down Expand Up @@ -47,7 +48,7 @@ export const ExploreMatchingButton = ({
data-test-subj="explore-matching-indices-button"
onClick={() => {
setPopoverIsOpen(false);
onCreateDefaultAdHocDataView(dataViewSearchString);
onCreateDefaultAdHocDataView({ title: dataViewSearchString });
}}
>
{i18n.translate('unifiedSearch.query.queryBar.indexPattern.createForMatchingIndices', {
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@
"@kbn/discover-customization-examples-plugin/*": ["examples/discover_customization_examples/*"],
"@kbn/discover-enhanced-plugin": ["x-pack/plugins/discover_enhanced"],
"@kbn/discover-enhanced-plugin/*": ["x-pack/plugins/discover_enhanced/*"],
"@kbn/discover-log-explorer-plugin": ["x-pack/plugins/discover_log_explorer"],
"@kbn/discover-log-explorer-plugin/*": ["x-pack/plugins/discover_log_explorer/*"],
"@kbn/discover-plugin": ["src/plugins/discover"],
"@kbn/discover-plugin/*": ["src/plugins/discover/*"],
"@kbn/doc-links": ["packages/kbn-doc-links"],
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"xpack.customBranding": "plugins/custom_branding",
"xpack.dashboard": "plugins/dashboard_enhanced",
"xpack.discover": "plugins/discover_enhanced",
"xpack.discoverLogExplorer": "plugins/discover_log_explorer",
"xpack.crossClusterReplication": "plugins/cross_cluster_replication",
"xpack.elasticAssistant": "packages/kbn-elastic-assistant",
"xpack.embeddableEnhanced": "plugins/embeddable_enhanced",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 React from 'react';
import { EuiIcon } from '@elastic/eui';

// Export mock package icon that doesn't trigger http requests
export const PackageIcon = () => <EuiIcon type="package" style={{ marginRight: 8 }} />;
22 changes: 22 additions & 0 deletions x-pack/plugins/discover_log_explorer/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -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.
*/

const defaultConfig = require('@kbn/storybook').defaultConfig;

module.exports = {
...defaultConfig,
stories: ['../**/*.stories.mdx', ...defaultConfig.stories],
webpackFinal: async (config) => {
const originalConfig = await defaultConfig.webpackFinal(config);

// Mock fleet plugin for PackageIcon component
originalConfig.resolve.alias['@kbn/fleet-plugin/public'] = require.resolve(
'./__mocks__/package_icon'
);
return originalConfig;
},
};
13 changes: 13 additions & 0 deletions x-pack/plugins/discover_log_explorer/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 const parameters = {
docs: {
source: {
type: 'code', // without this, stories in mdx documents freeze the browser
},
},
};
3 changes: 3 additions & 0 deletions x-pack/plugins/discover_log_explorer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Discover Log Explorer

This plugin exposes and registers Logs+ features.
weltenwort marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions x-pack/plugins/discover_log_explorer/common/constants.ts
Original file line number Diff line number Diff line change
@@ -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 const DISCOVER_LOG_EXPLORER_PROFILE_ID = 'discover-log-explorer';
weltenwort marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 24 additions & 0 deletions x-pack/plugins/discover_log_explorer/common/datasets/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

/* eslint-disable max-classes-per-file */

export class FindIntegrationsError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, new.target.prototype);
this.name = 'FindIntegrationsError';
}
}

export class FindDatasetsError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, new.target.prototype);
this.name = 'FindDatasetsError';
}
}
8 changes: 8 additions & 0 deletions x-pack/plugins/discover_log_explorer/common/datasets/index.ts
Original file line number Diff line number Diff line change
@@ -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';
36 changes: 36 additions & 0 deletions x-pack/plugins/discover_log_explorer/common/datasets/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 { indexPatternRt } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';

export const datasetRT = rt.exact(
rt.intersection([
rt.type({
name: indexPatternRt,
weltenwort marked this conversation as resolved.
Show resolved Hide resolved
}),
rt.partial({
title: rt.string,
}),
])
);

const integrationStatusRT = rt.union([
rt.literal('installed'),
rt.literal('installing'),
rt.literal('install_failed'),
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The io-ts docs recommend using rt.keyof() for unions of string literals:

Suggested change
const integrationStatusRT = rt.union([
rt.literal('installed'),
rt.literal('installing'),
rt.literal('install_failed'),
]);
const integrationStatusRT = rt.keyof({
installed: null,
installing: null,
install_failed: null,
});


export const integrationRT = rt.type({
name: rt.string,
status: integrationStatusRT,
version: rt.string,
dataStreams: rt.array(datasetRT),
});

export type Dataset = rt.TypeOf<typeof datasetRT>;
export type Integration = rt.TypeOf<typeof integrationRT>;
47 changes: 47 additions & 0 deletions x-pack/plugins/discover_log_explorer/common/datasets/v1/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import * as rt from 'io-ts';
import { isEmpty, mapValues, omitBy } from 'lodash';
import { Integration } from '../types';
import { FindDatasetsRequestQuery } from './find_datasets';
import { FindIntegrationsRequestQuery } from './find_integrations';

/**
* Constants
*/
export const DATASETS_URL = '/api/fleet/epm/datasets';
export const INTEGRATIONS_URL = '/api/fleet/epm/packages/installed';

/**
* Common types
*/
export const sortOrderRT = rt.union([rt.literal('asc'), rt.literal('desc')]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, how about following the official recommendation about unions of string literals?

export type SortOrder = rt.TypeOf<typeof sortOrderRT>;
export type IntegrationId = `integration-${string}-${string}`;
weltenwort marked this conversation as resolved.
Show resolved Hide resolved

/**
* Getters
*/
export const getIntegrationId = (integration: Integration): IntegrationId =>
`integration-${integration.name}-${integration.version}`;

/**
* Utils
*/
function stringifyByProp(
obj: FindIntegrationsRequestQuery | FindDatasetsRequestQuery,
props: string[]
) {
return mapValues(obj, (val, key) => (props.includes(key) ? JSON.stringify(val) : val));
}

/**
* Format the integrations and data streams search request into the required API format
*/
export const formatSearch = (search: FindIntegrationsRequestQuery | FindDatasetsRequestQuery) => {
return stringifyByProp(omitBy(search, isEmpty), ['searchAfter']);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 * as rt from 'io-ts';
import { datasetRT } from '../types';
import { sortOrderRT } from './common';

export const findDatasetsResponseRT = rt.type({
items: rt.array(datasetRT),
});

export const findDatasetsRequestQueryRT = rt.exact(
rt.partial({
datasetQuery: rt.string,
type: rt.literal('logs'),
sortOrder: sortOrderRT,
uncategorisedOnly: rt.boolean,
})
);

export type FindDatasetsRequestQuery = rt.TypeOf<typeof findDatasetsRequestQueryRT>;
export type FindDatasetsResponse = rt.TypeOf<typeof findDatasetsResponseRT>;
Loading