Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
afffcdb
progress
shahzad31 Mar 24, 2025
9c364ec
update types
shahzad31 Mar 24, 2025
7f6b28a
handle openc ase
shahzad31 Mar 24, 2025
76e89e4
handle context
shahzad31 Mar 25, 2025
835fb7a
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 25, 2025
3fa36d1
wip
shahzad31 Mar 25, 2025
397c40a
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 25, 2025
c36cc91
handle table
shahzad31 Mar 25, 2025
43d9cf8
fix types
shahzad31 Mar 25, 2025
55366c2
revert
shahzad31 Mar 25, 2025
791786a
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 25, 2025
db8c604
revert
shahzad31 Mar 25, 2025
d581f06
handle types
shahzad31 Mar 25, 2025
f27c5d2
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine Mar 25, 2025
a7763a1
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 26, 2025
b478b59
remove unused
shahzad31 Mar 26, 2025
ab3c789
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 26, 2025
ba24dd7
fix jest tests
shahzad31 Mar 26, 2025
bcd3383
fix more jest tests
shahzad31 Mar 26, 2025
0890214
fix more jest tests
shahzad31 Mar 26, 2025
afedc39
Merge branch 'main' of https://github.com/elastic/kibana into related…
shahzad31 Mar 27, 2025
b20da11
fix tests
shahzad31 Mar 27, 2025
4690950
fix tests
shahzad31 Mar 27, 2025
a211f95
PR feedback
shahzad31 Mar 28, 2025
626923e
Merge branch 'main' into related-alerts
shahzad31 Mar 28, 2025
de7946d
Merge branch 'main' into related-alerts
shahzad31 Mar 28, 2025
ea56aca
Merge branch 'main' into related-alerts
dominiqueclarke Mar 31, 2025
4f36da8
add unit test
dominiqueclarke Apr 1, 2025
a0c45c6
add integration test
dominiqueclarke Apr 1, 2025
1c3de19
adjust types
dominiqueclarke Apr 2, 2025
a647a90
Merge branch 'main' into related-alerts
dominiqueclarke Apr 2, 2025
a559fc1
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 3, 2025
4ad695c
remove sort fields control
dominiqueclarke Apr 3, 2025
d303220
Merge branch 'related-alerts' of https://github.com/shahzad31/kibana …
dominiqueclarke Apr 3, 2025
fa11357
adjust sort order
dominiqueclarke Apr 3, 2025
c447232
add ability to track scores when using field sorts
dominiqueclarke Apr 7, 2025
32ec62b
adjust copy
dominiqueclarke Apr 7, 2025
5103880
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 7, 2025
1723ed3
Ensure individual score results is greater than 0
kdelemme Apr 8, 2025
831b9e7
adjust trackScores and add a test
dominiqueclarke Apr 9, 2025
d341b70
adjust sizing of actions column and prevent sorting actions on indivi…
dominiqueclarke Apr 9, 2025
f27601b
adjust types
dominiqueclarke Apr 9, 2025
ea688d6
Merge branch 'main' into related-alerts
dominiqueclarke Apr 9, 2025
e0f6dab
adjust types
dominiqueclarke Apr 9, 2025
22c4f92
Merge branch 'main' into related-alerts
dominiqueclarke Apr 10, 2025
e53e193
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 10, 2025
0641f85
adjust css for alert actions
dominiqueclarke Apr 10, 2025
0a427a2
Merge branch 'related-alerts' of https://github.com/shahzad31/kibana …
dominiqueclarke Apr 10, 2025
eb1a31e
Merge branch 'main' into related-alerts
dominiqueclarke Apr 10, 2025
aecab6b
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 10, 2025
75b403c
adjust types
dominiqueclarke Apr 10, 2025
624623c
Merge branch 'related-alerts' of https://github.com/shahzad31/kibana …
dominiqueclarke Apr 10, 2025
14cc8a0
Remove newline at end of kibana.jsonc file
dominiqueclarke Apr 10, 2025
5bc4667
remove whitespace
dominiqueclarke Apr 10, 2025
0e98a91
handle number type in cell renders
dominiqueclarke Apr 10, 2025
b6f1c86
add unit test
dominiqueclarke Apr 13, 2025
3e795d0
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 13, 2025
001a597
Merge branch 'main' of https://github.com/elastic/kibana into pr/shah…
dominiqueclarke Apr 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { JsonValue } from '@kbn/utility-types';
export interface MetaAlertFields {
_id: string;
_index: string;
_score?: number;
}

export interface LegacyField {
Expand All @@ -29,7 +30,7 @@ export type KnownAlertFields = {
[Property in TechnicalRuleDataFieldName]?: JsonValue[];
};

export type UnknownAlertFields = Record<string, string | JsonValue[]>;
export type UnknownAlertFields = Record<string, string | number | JsonValue[]>;

/**
* Alert document type as returned by alerts search requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export type RuleRegistrySearchRequest = IEsSearchRequest & {
sort?: SortCombinations[];
pagination?: RuleRegistrySearchRequestPagination;
runtimeMappings?: MappingRuntimeFields;
minScore?: number;
trackScores?: boolean;
};

export interface RuleRegistrySearchRequestPagination {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const parsedAlerts = {
{
_index: '.internal.alerts-security.alerts-default-000001',
_id: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
_score: 1,
'@timestamp': ['2022-03-22T16:48:07.518Z'],
'host.name': ['Host-4dbzugdlqd'],
'kibana.alert.reason': [
Expand All @@ -99,6 +100,7 @@ const parsedAlerts = {
{
_index: '.internal.alerts-security.alerts-default-000001',
_id: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
_score: 1,
'@timestamp': ['2022-03-22T16:17:50.769Z'],
'host.name': ['Host-4dbzugdlqd'],
'kibana.alert.reason': [
Expand Down Expand Up @@ -130,6 +132,7 @@ const parsedAlerts = {
host: { name: ['Host-4dbzugdlqd'] },
_id: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
_index: '.internal.alerts-security.alerts-default-000001',
_score: 1,
},
{
kibana: {
Expand All @@ -148,6 +151,7 @@ const parsedAlerts = {
host: { name: ['Host-4dbzugdlqd'] },
_id: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
_index: '.internal.alerts-security.alerts-default-000001',
_score: 1,
},
],
oldAlertsData: [
Expand All @@ -169,6 +173,10 @@ const parsedAlerts = {
field: '_id',
value: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
},
{
field: '_score',
value: 1,
},
{ field: '_index', value: '.internal.alerts-security.alerts-default-000001' },
],
[
Expand All @@ -189,6 +197,10 @@ const parsedAlerts = {
field: '_id',
value: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
},
{
field: '_score',
value: 1,
},
{ field: '_index', value: '.internal.alerts-security.alerts-default-000001' },
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { catchError, filter, lastValueFrom, map, of } from 'rxjs';
import type {
MappingRuntimeFields,
QueryDslFieldAndFormat,
QueryDslQueryContainer,
SortCombinations,
} from '@elastic/elasticsearch/lib/api/types';
import type {
Alert,
EsQuerySnapshot,
LegacyField,
RuleRegistrySearchRequest,
RuleRegistrySearchResponse,
} from '@kbn/alerting-types';
import { set } from '@kbn/safer-lodash-set';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type {
MappingRuntimeFields,
QueryDslFieldAndFormat,
QueryDslQueryContainer,
SortCombinations,
} from '@elastic/elasticsearch/lib/api/types';
import { set } from '@kbn/safer-lodash-set';
import { catchError, filter, lastValueFrom, map, of } from 'rxjs';

export interface SearchAlertsParams {
// Dependencies
Expand Down Expand Up @@ -68,6 +68,14 @@ export interface SearchAlertsParams {
* The page size to fetch
*/
pageSize: number;
/**
* The minimum score to apply to the query
*/
minScore?: number;
/**
* Whether to track the score of the query
*/
trackScores?: boolean;
}

export interface SearchAlertsResult {
Expand All @@ -92,6 +100,8 @@ export const searchAlerts = ({
runtimeMappings,
pageIndex,
pageSize,
minScore,
trackScores,
}: SearchAlertsParams): Promise<SearchAlertsResult> =>
lastValueFrom(
data.search
Expand All @@ -104,6 +114,8 @@ export const searchAlerts = ({
pagination: { pageIndex, pageSize },
sort,
runtimeMappings,
minScore,
trackScores,
},
{
strategy: 'privateRuleRegistryAlertsSearchStrategy',
Expand Down Expand Up @@ -167,6 +179,7 @@ const parseAlerts = (rawResponse: RuleRegistrySearchResponse['rawResponse']) =>
acc.push({
...hit.fields,
_id: hit._id,
_score: hit._score,
_index: hit._index,
} as Alert);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('useSearchAlertsQuery', () => {
{
_index: '.internal.alerts-security.alerts-default-000001',
_id: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
_score: 1,
'@timestamp': ['2022-03-22T16:48:07.518Z'],
'host.name': ['Host-4dbzugdlqd'],
'kibana.alert.reason': [
Expand All @@ -180,6 +181,7 @@ describe('useSearchAlertsQuery', () => {
{
_index: '.internal.alerts-security.alerts-default-000001',
_id: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
_score: 1,
'@timestamp': ['2022-03-22T16:17:50.769Z'],
'host.name': ['Host-4dbzugdlqd'],
'kibana.alert.reason': [
Expand Down Expand Up @@ -211,6 +213,7 @@ describe('useSearchAlertsQuery', () => {
host: { name: ['Host-4dbzugdlqd'] },
_id: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
_index: '.internal.alerts-security.alerts-default-000001',
_score: 1,
},
{
kibana: {
Expand All @@ -229,6 +232,7 @@ describe('useSearchAlertsQuery', () => {
host: { name: ['Host-4dbzugdlqd'] },
_id: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
_index: '.internal.alerts-security.alerts-default-000001',
_score: 1,
},
],
oldAlertsData: [
Expand All @@ -250,6 +254,10 @@ describe('useSearchAlertsQuery', () => {
field: '_id',
value: '38dd308706a127696cc63b8f142e8e4d66f8f79bc7d491dd79a42ea4ead62dd1',
},
{
field: '_score',
value: 1,
},
{ field: '_index', value: '.internal.alerts-security.alerts-default-000001' },
],
[
Expand All @@ -270,6 +278,10 @@ describe('useSearchAlertsQuery', () => {
field: '_id',
value: '8361363c0db6f30ca2dfb4aeb4835e7d6ec57bc195b96d9ee5a4ead1bb9f8b86',
},
{
field: '_score',
value: 1,
},
{ field: '_index', value: '.internal.alerts-security.alerts-default-000001' },
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const useSearchAlertsQuery = ({ data, ...params }: UseSearchAlertsQueryPa
runtimeMappings,
pageIndex = 0,
pageSize = DEFAULT_ALERTS_PAGE_SIZE,
minScore,
trackScores,
} = params;
return useQuery({
queryKey: queryKeyPrefix.concat(JSON.stringify(params)),
Expand All @@ -58,6 +60,8 @@ export const useSearchAlertsQuery = ({ data, ...params }: UseSearchAlertsQueryPa
runtimeMappings,
pageIndex,
pageSize,
minScore,
trackScores,
}),
refetchOnWindowFocus: false,
context: AlertsQueryContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ const AlertsTableContent = typedForwardRef(
ruleTypeIds,
consumers,
query,
minScore,
trackScores = false,
initialSort = DEFAULT_SORT,
initialPageSize = DEFAULT_ALERTS_PAGE_SIZE,
leadingControlColumns = DEFAULT_LEADING_CONTROL_COLUMNS,
Expand Down Expand Up @@ -277,6 +279,8 @@ const AlertsTableContent = typedForwardRef(
runtimeMappings,
pageIndex: 0,
pageSize: initialPageSize,
minScore,
trackScores,
});

useEffect(() => {
Expand All @@ -287,6 +291,8 @@ const AlertsTableContent = typedForwardRef(
query,
sort,
runtimeMappings,
minScore,
trackScores,
// Go back to the first page if the query changes
pageIndex: !deepEqual(prevQueryParams, {
ruleTypeIds,
Expand All @@ -300,7 +306,7 @@ const AlertsTableContent = typedForwardRef(
: oldPageIndex,
pageSize: oldPageSize,
}));
}, [ruleTypeIds, fields, query, runtimeMappings, sort, consumers]);
}, [ruleTypeIds, fields, query, runtimeMappings, sort, consumers, minScore, trackScores]);

const {
data: alertsData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EuiDescriptionList, EuiPanel, EuiTabbedContentTab, EuiTitle } from '@el
import { ALERT_RULE_NAME } from '@kbn/rule-data-utils';
import { i18n } from '@kbn/i18n';
import { ScrollableFlyoutTabbedContent, AlertFieldsTable } from '@kbn/alerts-ui-shared';
import { JsonValue } from '@kbn/utility-types';
import { AdditionalContext, FlyoutSectionProps } from '../types';
import { defaultAlertsTableColumns } from '../configuration';
import { DefaultCellValue } from './default_cell_value';
Expand Down Expand Up @@ -43,7 +44,7 @@ export const DefaultAlertsFlyoutBody = <AC extends AdditionalContext>(
<EuiPanel hasShadow={false} data-test-subj="overviewTabPanel">
<EuiDescriptionList
listItems={(columns ?? defaultAlertsTableColumns).map((column) => {
const value = alert[column.id]?.[0];
const value = (alert[column.id] as JsonValue[])?.[0];

return {
title: (column.displayAsText as string) ?? column.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const DefaultCellValue = ({
/**
* Extracts the value from the raw json ES field
*/
const extractFieldValue = (rawValue: string | JsonValue[]) => {
const extractFieldValue = (rawValue: string | number | JsonValue[]) => {
const value = Array.isArray(rawValue) ? rawValue.join() : rawValue;

if (!isEmpty(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ export interface PublicAlertsDataGridProps
| 'columns'
> {
ruleTypeIds: string[];
minScore?: number;
trackScores?: boolean;
consumers?: string[];
/**
* If true, shows a button in the table toolbar to inspect the search alerts request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32435,8 +32435,6 @@
"xpack.observability.pages.alertDetails.pageTitle.ruleName": "Règle",
"xpack.observability.pages.alertDetails.pageTitle.title": "{ruleCategory} {ruleCategory, select, Anomaly {détectée} Inventory {seuil dépassé} other {dépassés}}",
"xpack.observability.pages.alertDetails.pageTitle.triggered": "Déclenché",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.description": "En raison d'une erreur inattendue, aucune alerte associée ne peut être trouvée.",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.title": "Problème de chargement des alertes associées",
"xpack.observability.profilingAWSCostDiscountRateUiSettingDescription": "Si vous êtes inscrits au programme de réduction AWS Enterprise Discount Program (EDP), entrez votre taux de réduction pour mettre à jour le calcul des coûts de profilage.",
"xpack.observability.profilingAWSCostDiscountRateUiSettingName": "Taux de réduction AWS EDP (%)",
"xpack.observability.profilingAzureCostDiscountRateUiSettingDescription": "Si vous avez un accord Azure Enterprise avec Microsoft, saisissez votre taux de réduction pour mettre à jour le calcul du coût de profilage.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32415,8 +32415,6 @@
"xpack.observability.pages.alertDetails.pageTitle.ruleName": "ルール",
"xpack.observability.pages.alertDetails.pageTitle.title": "{ruleCategory} {ruleCategory, select, Anomaly {検出されました} Inventory {しきい値に違反しました} other {違反しました}}",
"xpack.observability.pages.alertDetails.pageTitle.triggered": "実行済み",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.description": "予期しないエラーのため、関連するアラートが見つかりません。",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.title": "関連するアラートの読み込みエラー",
"xpack.observability.profilingAWSCostDiscountRateUiSettingDescription": "AWS Enterprise Discount Program(EDP)に加入している場合は、割引率を入力してプロファイリング費用の計算を更新します。",
"xpack.observability.profilingAWSCostDiscountRateUiSettingName": "AWS EDP割引率(%)",
"xpack.observability.profilingAzureCostDiscountRateUiSettingDescription": "MicrosoftとのAzureエンタープライズ契約がある場合は、割引率を入力して、プロファイリングコスト計算を更新してください。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32470,8 +32470,6 @@
"xpack.observability.pages.alertDetails.pageTitle.ruleName": "规则",
"xpack.observability.pages.alertDetails.pageTitle.title": "{ruleCategory} {ruleCategory, select, Anomaly {已检测到} Inventory {超出阈值} other {已超出}}",
"xpack.observability.pages.alertDetails.pageTitle.triggered": "已触发",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.description": "由于出现意外错误,找不到相关告警。",
"xpack.observability.pages.alertDetails.relatedAlerts.empty.title": "加载相关告警时出现问题",
"xpack.observability.profilingAWSCostDiscountRateUiSettingDescription": "如果已加入 AWS 企业折扣计划 (EDP),请输入您的折扣率以更新分析成本计算。",
"xpack.observability.profilingAWSCostDiscountRateUiSettingName": "AWS EDP 折扣率 (%)",
"xpack.observability.profilingAzureCostDiscountRateUiSettingDescription": "如果与 Microsoft 签署了 Azure 企业协议,请输入您的折扣率以更新分析成本计算。",
Expand Down
Loading