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

[Discover] Extend Elasticsearch query rule with search source based data fetching #124534

Merged
merged 95 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
a0d6a1b
[Discover] introduce .index-threshold rule
dimaanj Feb 3, 2022
ac02e78
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Feb 8, 2022
6954568
[Discover] change filters in alert expression
dimaanj Feb 9, 2022
db9db04
[Discover] fix cursor issue
dimaanj Feb 9, 2022
98da07a
[Discover] add loading
dimaanj Feb 9, 2022
e25ab7c
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Feb 13, 2022
369144d
[Discover] separate validation params
dimaanj Feb 13, 2022
153023b
[Discover] add view alert route
dimaanj Feb 13, 2022
9582ab3
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Feb 15, 2022
37654ff
[Discover] enable "view in app" for alert created from discover
dimaanj Feb 19, 2022
7088f4b
[Discover] fix filter popover
dimaanj Feb 20, 2022
b618cce
[Discover] fix linting, unit tests
dimaanj Feb 21, 2022
67cf91c
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Feb 21, 2022
b46d24d
[Discover] fix remaining tests
dimaanj Feb 21, 2022
3ae3857
[Discover] add unit tests, add link back to stack management for es q…
dimaanj Feb 24, 2022
34cdcfc
Update src/plugins/discover/public/application/view_alert/view_alert_…
dimaanj Feb 24, 2022
1332d26
[Discover] add tool tip for data view without time field
dimaanj Feb 24, 2022
988d4bf
[Discover] add info alert about possible document difference that tri…
dimaanj Feb 24, 2022
fba6d5e
[Discover] update unit test
dimaanj Feb 24, 2022
6e7a0a3
[Discover] fix unit tests
dimaanj Feb 25, 2022
58e2563
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Feb 25, 2022
2528f2f
Update x-pack/plugins/stack_alerts/public/alert_types/es_query/expres…
dimaanj Feb 25, 2022
f8667d5
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
dimaanj Feb 25, 2022
5af2b95
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
dimaanj Feb 25, 2022
8d44282
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
dimaanj Feb 25, 2022
377f035
Update src/plugins/discover/public/application/main/components/top_na…
dimaanj Feb 25, 2022
02b6e43
Update x-pack/plugins/stack_alerts/public/alert_types/es_query/expres…
dimaanj Feb 27, 2022
1cd93a0
[Discover] fix unit tests
dimaanj Feb 28, 2022
a41aeb4
[Discover] fix security solution alerts
dimaanj Feb 28, 2022
7889c47
[Discover] fix eslint errors
dimaanj Mar 1, 2022
17b413e
[Discover] fix unit tests
dimaanj Mar 1, 2022
347252c
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
dimaanj Mar 1, 2022
bc381b6
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
dimaanj Mar 1, 2022
1819a35
[Discover] apply suggestions
dimaanj Mar 1, 2022
b020ba1
[Discover] fix tests
dimaanj Mar 1, 2022
b671155
Update x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_…
kertal Mar 2, 2022
111ae94
[Discover] remove close button in filters
dimaanj Mar 3, 2022
9113d15
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Mar 3, 2022
ad2b1b3
Improve code structure
kertal Mar 3, 2022
50f9f47
Fix missing name in fetchEsQuery
kertal Mar 4, 2022
a60d7dc
Fix messages
kertal Mar 4, 2022
8a9dcb3
Fix messages, again
kertal Mar 4, 2022
5e0066d
Merge remote-tracking branch 'upstream/main' into test-of-elastic-que…
kertal Mar 4, 2022
c65ec01
Merge main and fix conflicts
kertal Mar 4, 2022
2eb04f3
Refactor
kertal Mar 7, 2022
72698c1
Refactor, add tests + a bit more of documentation
kertal Mar 7, 2022
e49ef25
Merge main and fix conflicts
kertal Mar 7, 2022
59ff266
Merge remote-tracking branch 'upstream/main' into extend-elastic-quer…
kertal Mar 7, 2022
2fc9d06
Move size field, change text
kertal Mar 7, 2022
ae6eb60
Merge remote-tracking branch 'upstream/main' into extend-elastic-quer…
kertal Mar 7, 2022
db705eb
Implement readonly callout
kertal Mar 7, 2022
9c31f83
change icon in callout
andreadelrio Mar 7, 2022
6e2a817
add padding to popover
andreadelrio Mar 7, 2022
f902a8a
Hide query and filter UI if there are no values to display
kertal Mar 8, 2022
d23b730
Merge main and fix conflicts
kertal Mar 8, 2022
184c26d
[Discover] add unit test, improve comparator types
dimaanj Mar 10, 2022
5dddc68
[Discover] fix linting and unit test
dimaanj Mar 10, 2022
9752dbc
[Discover] add es query alert integration tests
dimaanj Mar 14, 2022
20d812f
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Mar 14, 2022
ee029f2
[Discover] fix linting
dimaanj Mar 14, 2022
07e02bf
[Discover] uncomment one expect
dimaanj Mar 14, 2022
ddeb66d
[Discover] fix latesTimestamp for searchSource type, unify test logic
dimaanj Mar 15, 2022
d29fcd5
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 15, 2022
46342d2
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 15, 2022
ae7d4bd
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Mar 16, 2022
8333c8f
Update x-pack/plugins/stack_alerts/public/alert_types/es_query/expres…
dimaanj Mar 17, 2022
6bcded6
[Discover] apply suggestions
dimaanj Mar 17, 2022
3541e65
[Discover] make searchType optional, adjust tests
dimaanj Mar 17, 2022
97a622e
[Discover] remove updated translations
dimaanj Mar 18, 2022
b6a39e9
[Discover] apply suggestions
dimaanj Mar 18, 2022
84112fc
[Discover] fix unit test
dimaanj Mar 18, 2022
da51596
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 18, 2022
63fb6b3
[Discover] close popover on alert rule creation
dimaanj Mar 18, 2022
709e4ce
Merge main and fix conflicts
kertal Mar 20, 2022
c9fe352
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 20, 2022
03a5826
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 21, 2022
4f5db31
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 21, 2022
bfc0025
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 21, 2022
14afdc6
[Discover] apply suggestions
dimaanj Mar 21, 2022
a4c23ec
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Mar 22, 2022
877748a
[Discover] add first functional test
dimaanj Mar 23, 2022
c2a7b10
[Discover] implement tests
dimaanj Mar 23, 2022
a06d37b
Move functionals x-pack since ssl is needed
kertal Mar 24, 2022
5adae74
Fix potential flakiness in functional test
kertal Mar 24, 2022
a36f5de
Fix conflicts
kertal Mar 24, 2022
e4892ea
[Discover] remove timeout waiter
dimaanj Mar 25, 2022
622703c
Fix functional test
kertal Mar 26, 2022
564417b
Merge branch 'main' of https://github.com/elastic/kibana into extend-…
dimaanj Mar 26, 2022
b48e03b
[Discover] add logger
dimaanj Mar 28, 2022
2d7360c
[Discover] add more log points
dimaanj Mar 28, 2022
048fefb
[Discover] wait for indices creation finished
dimaanj Mar 28, 2022
b6b273a
Try to fix the functional flakiness
kertal Mar 28, 2022
6365adb
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 30, 2022
f38e2e1
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 31, 2022
f0b8602
Merge branch 'main' into extend-elastic-query-rule
kibanamachine Mar 31, 2022
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
7 changes: 6 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export * from './deprecated';

export { getEsQueryConfig, FilterStateStore } from '../common';
export { FilterLabel, FilterItem } from './ui';
export { getDisplayValueFromFilter, generateFilters, extractTimeRange } from './query';
export {
getDisplayValueFromFilter,
generateFilters,
extractTimeRange,
getIndexPatternFromFilter,
} from './query';

/**
* Exporters (CSV)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@
.globalFilterItem__popoverAnchor {
display: block;
}

.globalFilterItem__readonlyPanel {
min-width: auto;
dimaanj marked this conversation as resolved.
Show resolved Hide resolved
padding: $euiSizeM;
}
2 changes: 1 addition & 1 deletion src/plugins/data/public/ui/filter_bar/filter_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { IDataPluginServices, IIndexPattern } from '../..';

import { UI_SETTINGS } from '../../../common';

interface Props {
export interface Props {
filters: Filter[];
onFiltersUpdated?: (filters: Filter[]) => void;
className: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ export interface FilterLabelProps {
filter: Filter;
valueLabel?: string;
filterLabelStatus?: FilterLabelStatus;
hideAlias?: boolean;
}

// Needed for React.lazy
// eslint-disable-next-line import/no-default-export
export default function FilterLabel({ filter, valueLabel, filterLabelStatus }: FilterLabelProps) {
export default function FilterLabel({
filter,
valueLabel,
filterLabelStatus,
hideAlias,
}: FilterLabelProps) {
const prefixText = filter.meta.negate
? ` ${i18n.translate('data.filter.filterBar.negatedFilterPrefix', {
defaultMessage: 'NOT ',
Expand All @@ -38,7 +44,7 @@ export default function FilterLabel({ filter, valueLabel, filterLabelStatus }: F
return <span className="globalFilterLabel__value">{text}</span>;
};

if (filter.meta.alias !== null) {
if (!hideAlias && filter.meta.alias !== null) {
return (
<Fragment>
{prefix}
Expand Down
67 changes: 41 additions & 26 deletions src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { EuiContextMenu, EuiPopover } from '@elastic/eui';
import { EuiContextMenu, EuiPopover, EuiPopoverProps } from '@elastic/eui';
import { InjectedIntl } from '@kbn/i18n-react';
import {
Filter,
Expand All @@ -16,7 +16,7 @@ import {
toggleFilterDisabled,
} from '@kbn/es-query';
import classNames from 'classnames';
import React, { MouseEvent, useState, useEffect } from 'react';
import React, { MouseEvent, useState, useEffect, HTMLAttributes } from 'react';
import { IUiSettingsClient } from 'src/core/public';
import { FilterEditor } from './filter_editor';
import { FilterView } from './filter_view';
Expand All @@ -37,8 +37,11 @@ export interface FilterItemProps {
uiSettings: IUiSettingsClient;
hiddenPanelOptions?: PanelOptions[];
timeRangeForSuggestionsOverride?: boolean;
readonly?: boolean;
}

type FilterPopoverProps = HTMLAttributes<HTMLDivElement> & EuiPopoverProps;

interface LabelOptions {
title: string;
status: FilterLabelStatus;
Expand Down Expand Up @@ -349,32 +352,44 @@ export function FilterItem(props: FilterItemProps) {
return null;
}

const badge = (
<FilterView
filter={filter}
valueLabel={valueLabelConfig.title}
filterLabelStatus={valueLabelConfig.status}
errorMessage={valueLabelConfig.message}
className={getClasses(filter.meta.negate ?? false, valueLabelConfig)}
iconOnClick={() => props.onRemove()}
onClick={handleBadgeClick}
data-test-subj={getDataTestSubj(valueLabelConfig)}
/>
);
const filterViewProps = {
filter,
valueLabel: valueLabelConfig.title,
dimaanj marked this conversation as resolved.
Show resolved Hide resolved
filterLabelStatus: valueLabelConfig.status,
errorMessage: valueLabelConfig.message,
className: getClasses(!!filter.meta.negate, valueLabelConfig),
iconOnClick: props.onRemove,
onClick: handleBadgeClick,
'data-test-subj': getDataTestSubj(valueLabelConfig),
readonly: props.readonly,
};

const popoverProps: FilterPopoverProps = {
id: `popoverFor_filter${id}`,
className: `globalFilterItem__popover`,
anchorClassName: `globalFilterItem__popoverAnchor`,
isOpen: isPopoverOpen,
closePopover: () => {
setIsPopoverOpen(false);
},
button: <FilterView {...filterViewProps} />,
panelPaddingSize: 'none',
};

if (props.readonly) {
return (
<EuiPopover
panelClassName="globalFilterItem__readonlyPanel"
anchorPosition="upCenter"
{...popoverProps}
>
<FilterView {...filterViewProps} hideAlias />
dimaanj marked this conversation as resolved.
Show resolved Hide resolved
</EuiPopover>
);
}

return (
<EuiPopover
id={`popoverFor_filter${id}`}
className={`globalFilterItem__popover`}
anchorClassName={`globalFilterItem__popoverAnchor`}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
}}
button={badge}
anchorPosition="downLeft"
panelPaddingSize="none"
>
<EuiPopover anchorPosition="downLeft" {...popoverProps}>
<EuiContextMenu initialPanelId={0} panels={getPanels()} />
</EuiPopover>
);
Expand Down
60 changes: 38 additions & 22 deletions src/plugins/data/public/ui/filter_bar/filter_view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { EuiBadge, useInnerText } from '@elastic/eui';
import { EuiBadge, EuiBadgeProps, useInnerText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { FC } from 'react';
import { Filter, isFilterPinned } from '@kbn/es-query';
Expand All @@ -18,6 +18,8 @@ interface Props {
valueLabel: string;
filterLabelStatus: FilterLabelStatus;
errorMessage?: string;
readonly?: boolean;
hideAlias?: boolean;
[propName: string]: any;
}

Expand All @@ -28,6 +30,8 @@ export const FilterView: FC<Props> = ({
valueLabel,
errorMessage,
filterLabelStatus,
readonly,
hideAlias,
...rest
}: Props) => {
const [ref, innerText] = useInnerText();
Expand All @@ -50,33 +54,45 @@ export const FilterView: FC<Props> = ({
})} ${title}`;
}

const badgeProps: EuiBadgeProps = readonly
? {
title,
color: 'hollow',
onClick,
onClickAriaLabel: i18n.translate('data.filter.filterBar.filterItemReadOnlyBadgeAriaLabel', {
defaultMessage: 'Filter entry',
}),
iconOnClick,
}
: {
title,
color: 'hollow',
iconType: 'cross',
iconSide: 'right',
closeButtonProps: {
// Removing tab focus on close button because the same option can be obtained through the context menu
// Also, we may want to add a `DEL` keyboard press functionality
tabIndex: -1,
},
iconOnClick,
iconOnClickAriaLabel: i18n.translate('data.filter.filterBar.filterItemBadgeIconAriaLabel', {
defaultMessage: 'Delete {filter}',
values: { filter: innerText },
}),
onClick,
onClickAriaLabel: i18n.translate('data.filter.filterBar.filterItemBadgeAriaLabel', {
defaultMessage: 'Filter actions',
}),
};

return (
<EuiBadge
title={title}
color="hollow"
iconType="cross"
iconSide="right"
closeButtonProps={{
// Removing tab focus on close button because the same option can be obtained through the context menu
// Also, we may want to add a `DEL` keyboard press functionality
tabIndex: -1,
}}
iconOnClick={iconOnClick}
iconOnClickAriaLabel={i18n.translate('data.filter.filterBar.filterItemBadgeIconAriaLabel', {
defaultMessage: 'Delete {filter}',
values: { filter: innerText },
})}
onClick={onClick}
onClickAriaLabel={i18n.translate('data.filter.filterBar.filterItemBadgeAriaLabel', {
defaultMessage: 'Filter actions',
})}
{...rest}
>
<EuiBadge {...badgeProps} {...rest}>
<span ref={ref}>
<FilterLabel
filter={filter}
valueLabel={valueLabel}
filterLabelStatus={filterLabelStatus}
hideAlias={hideAlias}
/>
</span>
</EuiBadge>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dataViewFieldEditor",
"dataViewEditor"
],
"optionalPlugins": ["home", "share", "usageCollection", "spaces"],
"optionalPlugins": ["home", "share", "usageCollection", "spaces", "triggersActionsUi"],
"requiredBundles": ["kibanaUtils", "home", "kibanaReact", "dataViews"],
"extraPublicDirs": ["common"],
"owner": {
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/discover/public/application/discover_router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SingleDocRoute } from './doc';
import { DiscoverMainRoute } from './main';
import { NotFoundRoute } from './not_found';
import { DiscoverServices } from '../build_services';
import { ViewAlertRoute } from './view_alert';

export const discoverRouter = (services: DiscoverServices, history: History) => (
<KibanaContextProvider services={services}>
Expand All @@ -36,6 +37,9 @@ export const discoverRouter = (services: DiscoverServices, history: History) =>
<Route path="/doc/:indexPatternId/:index">
<SingleDocRoute />
</Route>
<Route path="/viewAlert/:id">
<ViewAlertRoute />
</Route>
<Route path="/view/:id">
<DiscoverMainRoute />
</Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { onSaveSearch } from './on_save_search';
import { GetStateReturn } from '../../services/discover_state';
import { openOptionsPopover } from './open_options_popover';
import type { TopNavMenuData } from '../../../../../../navigation/public';
import { openAlertsPopover } from './open_alerts_popover';

/**
* Helper function to build the top nav links
Expand Down Expand Up @@ -59,6 +60,25 @@ export const getTopNavLinks = ({
testId: 'discoverOptionsButton',
};

const alerts = {
id: 'alerts',
label: i18n.translate('discover.localMenu.localMenu.alertsTitle', {
defaultMessage: 'Alerts',
}),
description: i18n.translate('discover.localMenu.alertsDescription', {
defaultMessage: 'Alerts',
}),
run: (anchorElement: HTMLElement) => {
openAlertsPopover({
I18nContext: services.core.i18n.Context,
anchorElement,
searchSource: savedSearch.searchSource,
services,
});
},
testId: 'discoverAlertsButton',
};

const newSearch = {
id: 'new',
label: i18n.translate('discover.localMenu.localMenu.newSearchTitle', {
Expand Down Expand Up @@ -162,6 +182,7 @@ export const getTopNavLinks = ({
...(services.capabilities.advancedSettings.save ? [options] : []),
newSearch,
openSearch,
...(services.triggersActionsUi ? [alerts] : []),
shareSearch,
inspectSearch,
...(services.capabilities.discover.save ? [saveSearch] : []),
Expand Down
Loading