Skip to content

[ResponseOps] Execution log - data grid component, date picker, and status filter#128183

Merged
JiaweiWu merged 20 commits intoelastic:mainfrom
JiaweiWu:issue-126841-event-log-data-grid
Mar 28, 2022
Merged

[ResponseOps] Execution log - data grid component, date picker, and status filter#128183
JiaweiWu merged 20 commits intoelastic:mainfrom
JiaweiWu:issue-126841-event-log-data-grid

Conversation

@JiaweiWu
Copy link
Contributor

@JiaweiWu JiaweiWu commented Mar 21, 2022

Summary

Resolves the following issues:
#126841
#126842

Implements the execution log list component inside the rules summary page. Uses the new aggregation API and supports sorting/filtering/pagination via the data grid component.

We're using the super date picker to allow filtering on dates.

Currently the filtering is only on the event outcome status (success, failure, or 'unknown`). In the future we will implement a KQL query bar to support filtering on more fields.

Sorting is limited to the following fields:

timestamp
execution_duration
total_search_duration
es_search_duration
schedule_delay
num_triggered_actions

This PR has a dependency on #128179, so it contains changes from there as well.

rule_execution_pr

@JiaweiWu JiaweiWu added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.2.0 labels Mar 21, 2022
@JiaweiWu JiaweiWu requested a review from a team as a code owner March 21, 2022 17:00
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@JiaweiWu JiaweiWu changed the title Execution log data grid Execution log - data grid component and date picker Mar 21, 2022
@JiaweiWu JiaweiWu marked this pull request as draft March 21, 2022 17:01
@JiaweiWu JiaweiWu force-pushed the issue-126841-event-log-data-grid branch from 901bde0 to 344a0fa Compare March 23, 2022 20:14
@JiaweiWu JiaweiWu changed the title Execution log - data grid component and date picker [ResponseOps] Execution log - data grid component, date picker, and status filter Mar 23, 2022
@JiaweiWu JiaweiWu marked this pull request as ready for review March 23, 2022 22:12
Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

LGTM! Left some minor comments and questions but verified that the exec log table shows up on the rule details view :)

.sort((leftAlert, rightAlert) => leftAlert.sortPriority - rightAlert.sortPriority);

const pageOfAlerts = getPage(alerts, pagination);
const pageOfAlerts = getPage<AlertListItem>(alerts, pagination);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to keep the alert table pagination in this component instead of moving it into <RuleAlertList?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll move it to the alert list component

];

const renderTabs = () => {
const isEnabled = getIsExperimentalFeatureEnabled('rulesListDatagrid');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be rulesDetailLogs instead of rulesListDatagrid?

return date;
};

const SORTABLE_COLUMNS = [
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this const and also SortFields in x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/load_execution_log_aggregations.ts. Can we collapse to just one definition to make sure we're keeping them in sync?

Something like

const SortableColumns =[
  'timestamp',
  'execution_duration',
  'total_search_duration',
  'es_search_duration',
  'schedule_delay',
  'num_triggered_actions',
] as const;
type SortFields = typeof SortableColumns[number];

});

// Date related states
const [isLoading, setIsLoading] = useState<boolean>(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some sort of loading indicator for the EuiDataGrid that we can set? I added a delay to the API response for testing and I just see a table with an empty header while waiting for the response. Would be nice to have some sort of loading indicator.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't find one inherently while working on the alerts table, but I found that adding a <EuiProgress> on the top of the grid worked well. See what I did here

It also made it much easier to functionally test, as I could properly wait for server requests to finish

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea right now the only indication is the refresh button, but yes I can add what chris did to the execution log list

@ymao1
Copy link
Contributor

ymao1 commented Mar 24, 2022

I just remembered we were planning to show something similar to Discover if the total returned in the API response was greater than 1000. I did not see that included in this PR. Will that be a followup?

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

Looking great so far! Made a first pass and had some questions/comments

{
id: ALERT_LIST_TAB,
name: i18n.translate('xpack.triggersActionsUI.sections.ruleDetails.rule.alertsTabText', {
defaultMessage: 'Alerts',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an attempt to normalize the terminology here? We aren't technically showing alerts, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this tab is where the previous alert list in the rule summary would go, it technically would be alerts here

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea I'm just saying we aren't querying alerts-as-data indices here, but rather getting this information from the event log I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right, these alerts come from the rule summary, which queries event logs

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea I'm not sure if it's a big deal or not, cc @XavierM

];

const renderTabs = () => {
const isEnabled = getIsExperimentalFeatureEnabled('rulesListDatagrid');
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you run into this bug while developing this? Or maybe not because it's on by default?

Copy link
Contributor Author

@JiaweiWu JiaweiWu Mar 24, 2022

Choose a reason for hiding this comment

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

It's on by default, I recently noticed the issue when poking at the config values for integration testing

Copy link
Contributor

Choose a reason for hiding this comment

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

I should merge the fix by EOD so don't worry about fixing it yourself

const columns = [
{
id: 'id',
displayAsText: i18n.translate(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the initialWidth property to make the default columns more user friendly? We can easily shrink the Status column while making the Message column wider

});

// Date related states
const [isLoading, setIsLoading] = useState<boolean>(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't find one inherently while working on the alerts table, but I found that adding a <EuiProgress> on the top of the grid worked well. See what I did here

It also made it much easier to functionally test, as I could properly wait for server requests to finish

// Main cell renderer, renders durations, statuses, etc.
const renderCell = ({ rowIndex, columnId }: EuiDataGridCellValueElementProps) => {
const { pageIndex, pageSize } = pagination;
const pagedRowIndex = rowIndex - pageIndex * pageSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

I found a visibleRowIndex property available to use instead of needing to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately I think theres a bug with this. visibleRowIndex doesn't seem to exist when its in the "popover" mode. It becomes undefined :(

return null;
}

if (columnId === 'status') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to use an enum or something here? Seems brittle that if the column id changes, this will silently fail

| 'schedule_delay'
| 'num_triggered_actions';

export type SortOrder = 'asc' | 'desc';
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need to explicitly define this - maybe we can use estypes.SortOrder?

date_end: dateEnd,
filter: getFilter(filter),
per_page: perPage,
page: page + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth adding a comment explaining why we have to add 1 - honestly, I don't know why the API works this way when it just subtracts 1 from the page variable later. I'd add something here to remind us about this.

@JiaweiWu
Copy link
Contributor Author

I just remembered we were planning to show something similar to Discover if the total returned in the API response was greater than 1000. I did not see that included in this PR. Will that be a followup?

@ymao1 I wasn't aware of this, do you have more context for what it looks like or where I can find an example of its usage? I don't mind adding it with this PR

@ymao1
Copy link
Contributor

ymao1 commented Mar 24, 2022

@ymao1 I wasn't aware of this, do you have more context for what it looks like or where I can find an example of its usage? I don't mind adding it with this PR

I thought it was in meta issue but it turns out it's in a discussion thread on my API PR. Sorry! Here is the link: #127339 (comment)

Copy link
Contributor

@mdefazio mdefazio left a comment

Choose a reason for hiding this comment

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

Awesome to see this in place! Some comments on the UI:

Move controls to the left: I know this will have a search bar in the future, but in the meantime, lets' just keep these left-aligned

No flex-grow on the inputs: Again, just to clean things up some more until the search bar is in.

Styling of EuiSuperDatePicker: Let's make the width set to auto and then change the refresh button to only be an icon and remove the fill on it as well.

Screenshot of these changes:
image

Duration should include milliseconds: I know we don't show milliseconds on the rule list page, but for these logs I feel it makes sense, particularly since its right next to a timestamp with milliseconds. Perhaps theres another opinion about this, but it felt odd to show timestamp with milliseconds and not the duration.

Right align columns with numbers: Columns where we are comparing numbers across rows, these should be right-aligned.

Filter popover Looks like there's extra padding getting applied to the filter popover. Not sure if the EuiSelectable is being used here. While the docs say a 'long list' is best to use EuiSelectable, I think it's worth considering so we can have this appear consistent next to other upcoming filters that may have longer lists (though we can omit the search for this filter group). The issue currently is the padding, but something to consider.

image


const RULE_EVENT_LOG_LIST_STORAGE_KEY = 'xpack.triggersActionsUI.ruleEventLogList.initialColumns';

export const DEFAULT_INITIAL_VISIBLE_COLUMNS = [
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a good list of columns to start with! Once this is live, we'll probably have a better sense if there's more we need.

@JiaweiWu
Copy link
Contributor Author

@elasticmachine merge upstream

@JiaweiWu
Copy link
Contributor Author

Right align columns with numbers: Columns where we are comparing numbers across rows, these should be right-aligned.

@mdefazio So it seems like the data grid should automatically format numeric values to be right aligned, I can't seem to achieve this functionality despite boiling it down to the simplest case possible (renderCellValue returns a static number). If you don't think this is a blocker I can open a bug after this is merge and dig deeper.

Filter popover Looks like there's extra padding getting applied to the filter popover

I'm currently using a div that wraps multiple EuiFilterSelectItems. The goal was to match the filter that exists in the rules page, the padding seems to be there by default, making space for the checkmark

rule_filter_checked

@JiaweiWu
Copy link
Contributor Author

@elasticmachine merge upstream

@JiaweiWu
Copy link
Contributor Author

@elasticmachine merge upstream

@JiaweiWu JiaweiWu requested a review from a team as a code owner March 28, 2022 14:58
Copy link
Contributor

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

limits.yml LGTM

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

Looking really good! I commented about a few visual things but I think what we have is great!

defaultMessage: 'Timestamp',
}
),
isSortable: getIsColumnSortable('timestamp'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Try adding initialWidth: 250,

defaultMessage: 'Duration',
}
),
isSortable: getIsColumnSortable('execution_duration'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Try adding initialWidth: 100,

}
),
isSortable: getIsColumnSortable('message'),
initialWidth: 400,
Copy link
Contributor

Choose a reason for hiding this comment

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

Try removing this so the message takes up the rest of the available space

<EuiFlexItem grow={false}>
<RuleEventLogListStatusFilter selectedOptions={filter} onChange={onFilterChange} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe grow={true} so it expands?

@JiaweiWu JiaweiWu dismissed mdefazio’s stale review March 28, 2022 20:06

Addressed Michael's comments but he is OOO

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alerting 25 26 +1
triggersActionsUi 338 345 +7
total +8

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
alerting 294 315 +21

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
triggersActionsUi 674.2KB 685.2KB +11.0KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
alerting 38.2KB 38.4KB +183.0B
triggersActionsUi 97.2KB 98.1KB +1001.0B
total +1.2KB
Unknown metric groups

API count

id before after diff
alerting 302 323 +21

async chunk count

id before after diff
triggersActionsUi 69 71 +2

ESLint disabled in files

id before after diff
triggersActionsUi 5 6 +1

ESLint disabled line counts

id before after diff
triggersActionsUi 155 158 +3

Total ESLint disabled count

id before after diff
triggersActionsUi 160 164 +4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@JiaweiWu JiaweiWu merged commit 4235f81 into elastic:main Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.2.0

Projects

None yet

9 participants