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

[Security Solution] [Endpoint] Allow filtering activity log with date range #104085

Merged
merged 20 commits into from Jul 9, 2021
Merged

[Security Solution] [Endpoint] Allow filtering activity log with date range #104085

merged 20 commits into from Jul 9, 2021

Conversation

ashokaditya
Copy link
Member

@ashokaditya ashokaditya commented Jul 1, 2021

Summary

Allow users to fetch activity logs where actions and responses have a timestamp >= start date, <= end date or with a date range where start and end dates are included.

Changes:
Frontend

  • Added date range filter within the activity log flyout tab
  • The date range picker sticks to the bottom of the flyout header
  • Asks for data whenever a start date, end date or both is selected
  • Ignores data fetch when end date is older than start date, i.e, if the date towards the end of the range is not greater than that in the start of the range. We call this invalid date ranges. Also doesn't make API request if paging is disabled.
  • Pagination is reset when dates are selected and progresses on scroll.
  • Pagination is not reset if date ranges are invalid.
  • Activity log shows nothing (not empty state) if date filters result in an empty list of actions and responses.
  • The date ranges are stored in the redux store under activityLog.paging

Backend

  • assumes that either start_date or end_date are present in the request query.
  • If start_date or end_date are present in the request query then elasticsearch query uses { range: { '@timestamp': { gte: startDate } } } and { range: { '@timestamp': { lte: endDate } } } respectively to query with those params.
  • The response returns the queried startDate, endDate or both, that is used to update the redux store in the frontend.

Clip
date-range

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

@ashokaditya ashokaditya added auto-backport Deprecated: Automatically backport this PR after it's merged release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.14.0 v7.15.0 v8.0.0 labels Jul 1, 2021
@kevinlog kevinlog removed the v7.14.0 label Jul 1, 2021
@kevinlog
Copy link
Contributor

kevinlog commented Jul 1, 2021

@ashokaditya - looks great! Since this is a new feature that isn't budgeted in the test plan, we'll delay it to 7.15. I just removed the 7.14 label.

@ashokaditya ashokaditya marked this pull request as ready for review July 6, 2021 11:53
@ashokaditya ashokaditya requested a review from a team as a code owner July 6, 2021 11:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

Copy link
Contributor

@dasansol92 dasansol92 left a comment

Choose a reason for hiding this comment

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

That looks awesome!! A few comments added but it looks like a very good job so far! 🔥

import moment, { Moment } from 'moment';
import { EuiFlexGroup, EuiFlexItem, EuiDatePicker, EuiDatePickerRange } from '@elastic/eui';

import * as i18 from '../../translations';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you using all the translations there? Otherwise you should import just the needed ones

Copy link
Member Author

Choose a reason for hiding this comment

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

it's just the two translations, but they are deep nested within the export object.

@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

@ashokaditya ashokaditya self-assigned this Jul 7, 2021
@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Contributor

@dasansol92 dasansol92 left a comment

Choose a reason for hiding this comment

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

Few more comments added after the changes but in any case, this is looking 🔥

@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

@dasansol92
Copy link
Contributor

One last thing. I checked it locally and seems the date range inside the input is a little bit covered by the clear button.

Apart from that, when the search doesn't return any result the Nothing more to show text is outside the windows view and I've to scroll a bit to see that, so for a user perspective seems there is something wrong till it scroll down a bit:

timeline by date

@ashokaditya
Copy link
Member Author

One last thing. I checked it locally and seems the date range inside the input is a little bit covered by the clear button.

Can't do much about that except create a ticket in the Eui repo for it. It's how the date picker works.

Apart from that, when the search doesn't return any result the Nothing more to show text is outside the windows view and I've to scroll a bit to see that, so for a user perspective seems there is something wrong till it scroll down a bit:

I see your point but I think this is okay. I'll make a tiny fix anyway so that we show this message right below the dates. Although I think it is okay as it is, and follows the same pattern when there's a small list of actions/responses then users have to scroll down to see that there's nothing more to see. I guess we can improve the UX or make it consistent later.

@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

@dasansol92
Copy link
Contributor

One last thing. I checked it locally and seems the date range inside the input is a little bit covered by the clear button.

Can't do much about that except create a ticket in the Eui repo for it. It's how the date picker works.

Apart from that, when the search doesn't return any result the Nothing more to show text is outside the windows view and I've to scroll a bit to see that, so for a user perspective seems there is something wrong till it scroll down a bit:

I see your point but I think this is okay. I'll make a tiny fix anyway so that we show this message right below the dates. Although I think it is okay as it is, and follows the same pattern when there's a small list of actions/responses then users have to scroll down to see that there's nothing more to see. I guess we can improve the UX or make it consistent later.

  • Yeah, I think that make sense when there are few results and you have to scroll a bit, but when there is no results it feels weird having a full blank page and when you scroll then the message appears.

@ashokaditya
Copy link
Member Author

One last thing. I checked it locally and seems the date range inside the input is a little bit covered by the clear button.

Can't do much about that except create a ticket in the Eui repo for it. It's how the date picker works.

set fullWidth={true} for the date range component will allow it to take the full width of the container. Let's do that.

@ashokaditya
Copy link
Member Author

ashokaditya commented Jul 9, 2021

done @dasansol92

large screen
Screenshot 2021-07-09 at 15 49 54

small screen
Screenshot 2021-07-09 at 15 49 44

Copy link
Contributor

@dasansol92 dasansol92 left a comment

Choose a reason for hiding this comment

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

This looks awesome! Shiiiip this! 🔥 🚢 🥳
PD: About full width input, I found this mockups in figma with a full width input -> https://www.figma.com/file/BeTJy7bpHRPtHiNJtWU7Pj/OLM-7.12%2B?node-id=4835%3A558081

@ashokaditya
Copy link
Member Author

This looks awesome! Shiiiip this! 🔥 🚢 🥳
PD: About full width input, I found this mockups in figma with a full width input -> https://www.figma.com/file/BeTJy7bpHRPtHiNJtWU7Pj/OLM-7.12%2B?node-id=4835%3A558081

Nice. I somehow missed that mock. 😅 I was looking at the earlier version where there's also a search bar.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2205 2206 +1

Async chunks

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

id before after diff
securitySolution 6.3MB 6.3MB +6.0KB

History

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

cc @ashokaditya

@ashokaditya ashokaditya merged commit 81f09a8 into elastic:master Jul 9, 2021
@ashokaditya ashokaditya deleted the feature/olm-allow_date_range_filtereting_actions_log-1137 branch July 9, 2021 16:24
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jul 9, 2021
… range (elastic#104085)

* use date range in search query

fixes elastic/security-team/issues/1137

* make any date selection fetch matching log

fixes elastic/security-team/issues/1137

* use a single action for updating paging info and fetching data

fixes elastic/security-team/issues/1137

* use consistent types

for some reason TS was complaining earlier with `undefined`

* reset date picker on tab load

fixes elastic/security-team/issues/1137

* refactor date pickers into a component

refs elastic/security-team/issues/1137

* clear dates on change of endpoint

fixes elastic/security-team/issues/1137

* do not show empty state if date filtering results return empty data

fixes elastic/security-team/issues/1137

* add tests

fixes elastic/security-team/issues/1137

* review changes

* update comment

refs f551b67

* store invalidDateRange on redux store and decouple logic from the component

review changes

* fix test

* fix lint

* review changes

* expand date picker to use the full width of the flyout

review changes

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jul 9, 2021
… range (#104085) (#105093)

* use date range in search query

fixes elastic/security-team/issues/1137

* make any date selection fetch matching log

fixes elastic/security-team/issues/1137

* use a single action for updating paging info and fetching data

fixes elastic/security-team/issues/1137

* use consistent types

for some reason TS was complaining earlier with `undefined`

* reset date picker on tab load

fixes elastic/security-team/issues/1137

* refactor date pickers into a component

refs elastic/security-team/issues/1137

* clear dates on change of endpoint

fixes elastic/security-team/issues/1137

* do not show empty state if date filtering results return empty data

fixes elastic/security-team/issues/1137

* add tests

fixes elastic/security-team/issues/1137

* review changes

* update comment

refs f551b67

* store invalidDateRange on redux store and decouple logic from the component

review changes

* fix test

* fix lint

* review changes

* expand date picker to use the full width of the flyout

review changes

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Ashokaditya <am.struktr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated: Automatically backport this PR after it's merged release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants