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

[RAM] Add error logs in rule details page #128925

Merged
merged 30 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
da19ca4
add error log on details page + snooze
XavierM Mar 30, 2022
d691af1
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Mar 30, 2022
00f49cb
refresh table in details page
XavierM Mar 30, 2022
9c74430
fix type
XavierM Mar 30, 2022
766d261
add + fix jest test
XavierM Mar 31, 2022
36949d7
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Mar 31, 2022
a8a1939
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Mar 31, 2022
055e1e7
add test for error log
XavierM Mar 31, 2022
4e9442f
remove console
XavierM Mar 31, 2022
abeeecc
update functional test + delete flaky jest test + fix i18n
XavierM Apr 1, 2022
74113f9
review I
XavierM Apr 1, 2022
740180a
remove skip
XavierM Apr 1, 2022
fa7e451
review II
XavierM Apr 1, 2022
776006c
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Apr 1, 2022
2703231
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Apr 1, 2022
1367fa5
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Apr 1, 2022
326d1d4
remove disable panel
XavierM Apr 1, 2022
0a8559c
clean up design
XavierM Apr 1, 2022
39f1a20
fix check
XavierM Apr 1, 2022
69b4b6b
fix types
XavierM Apr 1, 2022
8676edd
Design tweaks to header, status dropdown, mobile
ryankeairns Apr 1, 2022
76cc235
remove dead code
XavierM Apr 1, 2022
9b5a393
Merge pull request #10 from ryankeairns/rule-error-logs
XavierM Apr 2, 2022
e751e57
jest test
XavierM Apr 2, 2022
7072a06
Merge branch 'rule-error-logs' of github.com:XavierM/kibana into rule…
XavierM Apr 2, 2022
bd29c61
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Apr 2, 2022
f71b13c
fix actions layout
XavierM Apr 2, 2022
ab671cf
review III
XavierM Apr 2, 2022
8e70a4b
use mount instead fo shallow
XavierM Apr 2, 2022
90d4cc6
Merge branch 'main' of github.com:elastic/kibana into rule-error-logs
XavierM Apr 2, 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
9 changes: 9 additions & 0 deletions x-pack/plugins/alerting/common/execution_log_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ export interface IExecutionLog {
timed_out: boolean;
}

export interface IErrorLog {
id: string;
timestamp: string;
type: string;
message: string;
}

export interface IExecutionLogResult {
XavierM marked this conversation as resolved.
Show resolved Hide resolved
total: number;
totalErrors: number;
data: IExecutionLog[];
errors: IErrorLog[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ describe('formatExecutionLogResult', () => {
expect(formatExecutionLogResult({ aggregations: undefined })).toEqual({
total: 0,
data: [],
errors: [],
XavierM marked this conversation as resolved.
Show resolved Hide resolved
totalErrors: 0,
});
});
test('should format results correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const Millis2Nanos = 1000 * 1000;

export const EMPTY_EXECUTION_LOG_RESULT = {
total: 0,
totalErrors: 0,
XavierM marked this conversation as resolved.
Show resolved Hide resolved
data: [],
errors: [],
};

interface IAlertCounts extends estypes.AggregationsMultiBucketAggregateBase {
Expand Down Expand Up @@ -277,7 +279,7 @@ function formatExecutionLogAggBucket(bucket: IExecutionUuidAggBucket): IExecutio

export function formatExecutionLogResult(
results: AggregateEventsBySavedObjectResult
): IExecutionLogResult {
): Pick<IExecutionLogResult, 'total' | 'data'> {
XavierM marked this conversation as resolved.
Show resolved Hide resolved
const { aggregations } = results;

if (!aggregations) {
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -27781,11 +27781,6 @@
"xpack.triggersActionsUI.sections.ruleDetails.ruleDetailsTitle": "{ruleName}",
"xpack.triggersActionsUI.sections.ruleDetails.alertInstances.disabledRule": "このルールは無効になっていて再表示できません。",
"xpack.triggersActionsUI.sections.ruleDetails.alertInstances.disabledRuleTitle": "無効なルール",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.enableLoadingTitle": "有効にする",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.enableTitle": "有効にする",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.muteLoadingTitle": "ミュート",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.muteTitle": "ミュート",
"xpack.triggersActionsUI.sections.ruleDetails.dismissButtonTitle": "閉じる",
"xpack.triggersActionsUI.sections.ruleDetails.editRuleButtonLabel": "編集",
"xpack.triggersActionsUI.sections.ruleDetails.manageLicensePlanBannerLinkTitle": "ライセンスの管理",
"xpack.triggersActionsUI.sections.ruleDetails.redirectObjectNoun": "ルール",
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -27810,11 +27810,6 @@
"xpack.triggersActionsUI.sections.ruleDetails.ruleDetailsTitle": "{ruleName}",
"xpack.triggersActionsUI.sections.ruleDetails.alertInstances.disabledRule": "此规则已禁用,无法显示。",
"xpack.triggersActionsUI.sections.ruleDetails.alertInstances.disabledRuleTitle": "已禁用规则",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.enableLoadingTitle": "启用",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.enableTitle": "启用",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.muteLoadingTitle": "静音",
"xpack.triggersActionsUI.sections.ruleDetails.collapsedItemActons.muteTitle": "静音",
"xpack.triggersActionsUI.sections.ruleDetails.dismissButtonTitle": "关闭",
"xpack.triggersActionsUI.sections.ruleDetails.editRuleButtonLabel": "编辑",
"xpack.triggersActionsUI.sections.ruleDetails.manageLicensePlanBannerLinkTitle": "管理许可证",
"xpack.triggersActionsUI.sections.ruleDetails.redirectObjectNoun": "规则",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ const getRenamedLog = (data: IExecutionLog) => {
};
};

const rewriteBodyRes: RewriteRequestCase<IExecutionLogResult> = ({ data, total }: any) => ({
const rewriteBodyRes: RewriteRequestCase<IExecutionLogResult> = ({
data,
errors,
XavierM marked this conversation as resolved.
Show resolved Hide resolved
total,
totalErrors,
}: any) => ({
data: data.map((log: IExecutionLog) => getRenamedLog(log)),
errors,
total,
totalErrors,
});

const getFilter = (filter: string[] | undefined) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
resolveRule,
loadExecutionLogAggregations,
LoadExecutionLogAggregationsProps,
snoozeRule,
unsnoozeRule,
} from '../../../lib/rule_api';
import { IExecutionLogResult } from '../../../../../../alerting/common';
import { useKibana } from '../../../../common/lib/kibana';
Expand Down Expand Up @@ -67,6 +69,8 @@ export interface ComponentOpts {
) => Promise<IExecutionLogResult>;
getHealth: () => Promise<AlertingFrameworkHealth>;
resolveRule: (id: Rule['id']) => Promise<ResolvedRule>;
snoozeRule: (rule: Rule, snoozeEndTime: string | -1) => Promise<void>;
unsnoozeRule: (rule: Rule) => Promise<void>;
}

export type PropsWithOptionalApiHandlers<T> = Omit<T, keyof ComponentOpts> & Partial<ComponentOpts>;
Expand Down Expand Up @@ -145,6 +149,12 @@ export function withBulkRuleOperations<T>(
}
resolveRule={async (ruleId: Rule['id']) => resolveRule({ http, ruleId })}
getHealth={async () => alertingFrameworkHealth({ http })}
snoozeRule={async (rule: Rule, snoozeEndTime: string | -1) => {
return await snoozeRule({ http, id: rule.id, snoozeEndTime });
}}
unsnoozeRule={async (rule: Rule) => {
return await unsnoozeRule({ http, id: rule.id });
}}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { getIsExperimentalFeatureEnabled } from '../../../../common/get_experime
import { suspendedComponentWithProps } from '../../../lib/suspended_component_with_props';

const RuleEventLogListWithApi = lazy(() => import('./rule_event_log_list'));
const RuleErrorLogWithApi = lazy(() => import('./rule_error_log'));

const RuleAlertList = lazy(() => import('./rule_alert_list'));

Expand All @@ -56,6 +57,7 @@ type RuleProps = {
readOnly: boolean;
ruleSummary: RuleSummary;
requestRefresh: () => Promise<void>;
refreshToken?: number;
numberOfExecutions: number;
onChangeDuration: (length: number) => void;
durationEpoch?: number;
Expand All @@ -64,6 +66,7 @@ type RuleProps = {

const EVENT_LOG_LIST_TAB = 'rule_event_log_list';
const ALERT_LIST_TAB = 'rule_alert_list';
const EVENT_ERROR_LOG_TAB = 'rule_error_log_list';

export function RuleComponent({
rule,
Expand All @@ -73,6 +76,7 @@ export function RuleComponent({
muteAlertInstance,
unmuteAlertInstance,
requestRefresh,
refreshToken,
numberOfExecutions,
onChangeDuration,
durationEpoch = Date.now(),
Expand Down Expand Up @@ -116,10 +120,13 @@ export function RuleComponent({
{
id: EVENT_LOG_LIST_TAB,
name: i18n.translate('xpack.triggersActionsUI.sections.ruleDetails.rule.eventLogTabText', {
defaultMessage: 'Execution History',
defaultMessage: 'Execution history',
}),
'data-test-subj': 'eventLogListTab',
content: suspendedComponentWithProps(RuleEventLogListWithApi, 'xl')({ rule }),
content: suspendedComponentWithProps(
RuleEventLogListWithApi,
'xl'
)({ requestRefresh, rule, refreshToken }),
},
{
id: ALERT_LIST_TAB,
Expand All @@ -129,6 +136,17 @@ export function RuleComponent({
'data-test-subj': 'ruleAlertListTab',
content: renderRuleAlertList(),
},
{
id: EVENT_ERROR_LOG_TAB,
name: i18n.translate('xpack.triggersActionsUI.sections.ruleDetails.rule.errorLogTabText', {
defaultMessage: 'Error log',
}),
'data-test-subj': 'errorLogTab',
content: suspendedComponentWithProps(
RuleErrorLogWithApi,
'xl'
)({ requestRefresh, rule, refreshToken }),
},
];

const renderTabs = () => {
Expand Down
Loading