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

[Fleet] Add view agents button to activity flyout #152555

Merged
merged 20 commits into from
Mar 13, 2023

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Mar 2, 2023

Part of #141206

Summary

Server side:

  • Create a new API that returns Agents by actions Ids:
POST kbn:/api/fleet/agents 
{
	actionIds: [
    	'action1',
        'action2'
    ]
}

UI:

Add "view agents" button to activity flyout; when clicking on it, the button will take the user to the agent list and display only the subset of agents affected by the action.

Screenshot 2023-03-09 at 16 27 41

Also addiing a "clear filters" on top of the header to be able to remove the applied filter after the button is selected

I also did some refactoring of the AgentListPage component, mostly extracted some small components and the kueryBuilder function, that became its own function and it's also been tested.

Checklist

@criamico criamico self-assigned this Mar 2, 2023
@criamico
Copy link
Contributor Author

criamico commented Mar 9, 2023

@elasticmachine merge upstream

@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Mar 9, 2023
@criamico criamico added v8.8.0 release_note:skip Skip the PR/issue when compiling release notes labels Mar 9, 2023
@criamico
Copy link
Contributor Author

criamico commented Mar 9, 2023

I'm opening the PR even though there are still some issues that I need to fix before merging, but I would like to have some early reviews .

In local testing I'm having cases where the agents parameter in the action has some ids, but when I search those ids they are not found, so the filtering doesn't really work. This happened for instance with the update tags actions. @juliaElastic do you know if there is some special case to handle there?

Also the "clear filters" button added on top of the table is almost always visible, as it's tied to the existing isUsingFilter parameter, I'd like to have some feedback on that as well.

@criamico criamico marked this pull request as ready for review March 9, 2023 16:42
@criamico criamico requested a review from a team as a code owner March 9, 2023 16:42
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic
Copy link
Contributor

juliaElastic commented Mar 10, 2023

In local testing I'm having cases where the agents parameter in the action has some ids, but when I search those ids they are not found, so the filtering doesn't really work. This happened for instance with the update tags actions. @juliaElastic do you know if there is some special case to handle there?

Yes, update tags action doesn't have real agent ids, see the end of this comment: #141206 (comment)

We might want to hide the View agents button for update tags at first.


import { getKuery } from './get_kuery';

describe('getKuery', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

great refactor with tests!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! :D

@juliaElastic
Copy link
Contributor

Tested locally and works well.
Noticed one thing, the default filters exclude the Inactive and Unenrolled agents, so when I click on View agents of a force unenroll action, there are no matches. Maybe we could remove all status filters so that e.g. Unenrolled agents are also returned by the search.

image

image

@criamico
Copy link
Contributor Author

criamico commented Mar 10, 2023

Yes, update tags action doesn't have real agent ids, see the end of this comment: #141206 (comment)

So should we even display the "view agents" button in this case? I could hide it in the case of tag updating. -edit I re-read and realised that you already answered :)

Also, do you know if we have other cases similar to this where the action doesn't hold the correct agent ids? Since the agent activity covers all type of actions we need to be sure that it work properly in all those cases.

@criamico
Copy link
Contributor Author

Noticed one thing, the default filters exclude the Inactive and Unenrolled agents, so when I click on View agents of a force unenroll action, there are no matches. Maybe we could remove all status filters so that e.g. Unenrolled agents are also returned by the search.

Yes I noticed it as well. I'll remove all the filters when clicking the button and this will solve also the weird behaviour of the "clear filters" link.

@criamico
Copy link
Contributor Author

@juliaElastic do you think that passing the kuery instead of the agent ids will be enough to handle the bulk actions case? you were suggesting to do this ticket in two passes but maybe this will be enough?

@juliaElastic
Copy link
Contributor

@juliaElastic do you think that passing the kuery instead of the agent ids will be enough to handle the bulk actions case? you were suggesting to do this ticket in two passes but maybe this will be enough?

Passing the query would work in most cases, though there are some edge cases where it wouldn't e.g. if agent version was included in the filter, and the agents were upgraded, or if status:online agents were actioned and the agents are no longer online. We could add an explanation on the UI or try to include both in the filter e.g. (agentIds:1,2,3 OR kuery)

setSearch(kuery);
}
if (action?.type === 'UNENROLL' || action?.type === 'FORCE_UNENROLL') {
setSelectedStatus(['unenrolled', 'inactive']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it mean that only unenrolled and inactive statuses are visible or all statuses? I'll try it locally. Ideally it should be all statuses, so agents are visible if unenroll is in progress. For simple unenroll, agents will move to Offline at first.

Copy link
Contributor Author

@criamico criamico Mar 10, 2023

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, I probably need to add all of them. I'm not sure if I need to add them in all cases or only for unenrolled agents.

Copy link
Contributor

Choose a reason for hiding this comment

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

It could be for all cases. Does the Clear filters button reset to default filters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That applies the clearFIlters function here:

const clearFilters = useCallback(() => {
setDraftKuery('');
setSearch('');
setSelectedAgentPolicies([]);
setSelectedStatus([]);
setSelectedTags([]);
setShowUpgradeable(false);
}, [setSearch, setDraftKuery, setSelectedAgentPolicies, setSelectedStatus, setShowUpgradeable]);

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 changed so that it makes all possible statuses visible for all cases. I think I had misunderstood how this filtering works.

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM, tested locally

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 795 796 +1

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
fleet 990 991 +1

Async chunks

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

id before after diff
fleet 937.2KB 939.1KB +1.9KB

Page load bundle

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

id before after diff
fleet 125.3KB 125.6KB +248.0B
Unknown metric groups

API count

id before after diff
fleet 1095 1096 +1

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

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

cc @criamico

@criamico criamico merged commit eb60253 into elastic:main Mar 13, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Mar 13, 2023
nkhristinin pushed a commit that referenced this pull request Mar 22, 2023
Part of #141206

## Summary

### Server side:
- Create a new API that returns Agents by actions Ids:
```
POST kbn:/api/fleet/agents 
{
	actionIds: [
    	'action1',
        'action2'
    ]
}
```

### UI:
Add "view agents" button to activity flyout; when clicking on it, the
button will take the user to the agent list and display only the subset
of agents affected by the action.

<img width="1100" alt="Screenshot 2023-03-09 at 16 27 41"
src="https://user-images.githubusercontent.com/16084106/224072551-bf7b6cf3-9f32-4a79-8e61-d7dc35f4db54.png">

Also addiing a "clear filters" on top of the header to be able to remove
the applied filter after the button is selected

I also did some refactoring of the `AgentListPage` component, mostly
extracted some small components and the `kueryBuilder` function, that
became its own function and it's also been tested.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants