Skip to content

[Fleet] Add support for select type in integrations#152550

Merged
jillguyonnet merged 14 commits intoelastic:mainfrom
jillguyonnet:jillguyonnet/fleet-add-select-integrations
Mar 9, 2023
Merged

[Fleet] Add support for select type in integrations#152550
jillguyonnet merged 14 commits intoelastic:mainfrom
jillguyonnet:jillguyonnet/fleet-add-select-integrations

Conversation

@jillguyonnet
Copy link
Contributor

@jillguyonnet jillguyonnet commented Mar 2, 2023

Summary

This PR adds support for the new select var type in integrations.

Context and discussion in related issue: elastic/package-spec#453
Related package-spec PR: elastic/package-spec#486

Screenshots

Before

Current Scope advanced option in the Elasticsearch metrics settings (free text field):
Screenshot 2023-03-08 at 09 37 30

After

Same option with a select instead:
Screenshot 2023-03-08 at 09 36 25
Screenshot 2023-03-08 at 09 36 31

Checklist

  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests 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)
  • Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)
  • This was checked for cross-browser compatibility

For maintainers

@jillguyonnet jillguyonnet force-pushed the jillguyonnet/fleet-add-select-integrations branch from df2075e to 3c9e055 Compare March 7, 2023 15:04
@jillguyonnet jillguyonnet marked this pull request as ready for review March 7, 2023 15:05
@jillguyonnet jillguyonnet requested a review from a team as a code owner March 7, 2023 15:05
@jillguyonnet jillguyonnet added the Team:Fleet Team label for Observability Data Collection Fleet team label Mar 7, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@jillguyonnet
Copy link
Contributor Author

Hey @elastic/fleet , not sure which kind of release note this qualifies for, any suggestion?

@kpollich
Copy link
Member

kpollich commented Mar 7, 2023

@jillguyonnet - This can probably use release_note:enhancement 🙂

@nchaulet
Copy link
Member

nchaulet commented Mar 7, 2023

This is great I am wondering if can add this to the package policy validation https://github.com/nchaulet/kibana/blob/290cb9497c34e73c498c58f2270834406cfa295c/x-pack/plugins/fleet/common/services/validate_package_policy.ts#L318-L339 and reject values that are not a select option.

isEditPage,
isInvalid,
fieldLabel,
options,
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 was suspicious about memoizing an array since it would be compared by reference, but I'm not sure at all if that could be an issue in this case. I didn't see any strangeness with local testing. Does anyone know?

}

if (varDef.type === 'select') {
if (!varDef.options) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we validate that the value is one of the options instead? That service validate user provided value not the package structure.

Copy link
Contributor Author

@jillguyonnet jillguyonnet Mar 8, 2023

Choose a reason for hiding this comment

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

Hey @nchaulet - Thanks for your input! Ah right, I suppose that will be handled by the package linter. Ok, so we can check that the value is either undefined or one the options' value.
Edit: I'm not sure in what scenario the value would be something else though?

Copy link
Member

Choose a reason for hiding this comment

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

Edit: I'm not sure in what scenario the value would be something else though?

For a package policy created via an API call user can provide any value they want

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I amended the validation, let me know.

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@kibana-ci
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #50 / discover/group1 discover accessibility should give focus to the data view switch link when Tab is pressed

Metrics [docs]

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 989 990 +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.1KB 937.2KB +113.0B

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.1KB 125.3KB +262.0B
Unknown metric groups

API count

id before after diff
fleet 1094 1095 +1

ESLint disabled line counts

id before after diff
securitySolution 428 430 +2

Total ESLint disabled count

id before after diff
securitySolution 505 507 +2

History

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

@jillguyonnet jillguyonnet merged commit 9eb1c50 into elastic:main Mar 9, 2023
@jillguyonnet jillguyonnet deleted the jillguyonnet/fleet-add-select-integrations branch March 9, 2023 14:42
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Mar 9, 2023
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
## Summary

This PR adds support for the new `select` var type in integrations.

Context and discussion in related issue:
elastic/package-spec#453
Related package-spec PR:
elastic/package-spec#486

### Screenshots

#### Before
Current `Scope` advanced option in the Elasticsearch metrics settings
(free text field):
<img width="777" alt="Screenshot 2023-03-08 at 09 37 30"
src="https://user-images.githubusercontent.com/23701614/223664474-a5cc5c2b-43c3-451f-9678-30e8c661bfcf.png">

#### After
Same option with a select instead:
<img width="777" alt="Screenshot 2023-03-08 at 09 36 25"
src="https://user-images.githubusercontent.com/23701614/223664552-37c56bff-d6c9-4035-af4c-3a27e355beed.png">
<img width="777" alt="Screenshot 2023-03-08 at 09 36 31"
src="https://user-images.githubusercontent.com/23701614/223664581-9e92abfa-6202-433e-b4de-2740fc7c96bc.png">

### Checklist

- [ ]
[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/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
jillguyonnet added a commit that referenced this pull request Mar 30, 2023
## Summary

This PR is a followup fix to
#152550.

As discovered in
elastic/integrations#5451 (comment),
there is currently an issue where the select is invalid upon first
render because no default `value` exists, yet the first option appears
to be selected.

The fix introduced in this PR replaces the EUISelect with a more
flexible EUIComboBox component, with a placeholder with text `Select an
option` when no value is selected. In addition, this new component
allows the selection to be cleared, which can be useful for non required
variables.

If the package specifies a default value, it should be selected by
default. Otherwise, the placeholder will render. Note that the field
will not be valid upon first render if the variable is required and no
default value is provided.

<img width="1728" alt="Screenshot 2023-03-29 at 17 47 28"
src="https://user-images.githubusercontent.com/23701614/228596370-d6b14c03-4a09-4f68-a137-95bb7ca7e78f.png">
<img width="1728" alt="Screenshot 2023-03-29 at 17 47 35"
src="https://user-images.githubusercontent.com/23701614/228596387-dc99e4b2-5d9d-4218-baf1-010bf527b028.png">
<img width="1728" alt="Screenshot 2023-03-29 at 17 47 44"
src="https://user-images.githubusercontent.com/23701614/228596415-9f1f73af-a9f5-4a88-a700-999213500c4e.png">

### Repro steps

1. Run package-registry with version 1.5.0 of Elasticsearch integration
from elastic/integrations#5451:
1. In integrations repo, check out the branch in
elastic/integrations#5451
2. In `packages/elasticsearch/changelog.yml`, change `version:
1.5.0-next` to `version: 1.5.0`
3. In `packages/elasticsearch/manifest.yml`, change the version to 1.5.0
4. In the shell, `cd packages/elasticsearch` if not there already and
`elastic-package build -v`
5. Run the package registry: `elastic-package stack up -v -d --services
package-registry`
6. Check that it is running correctly and that you can see version 1.5.0
of Elasticsearch at https://localhost:8080/search?package=elasticsearch
2. Run Kibana in dev on this branch:
1. In your `kibana.dev.yml`, add `xpack.fleet.registryUrl:
https://localhost:8080` if not there (⚠️ https, not http)
2. Before running `yarn start`, run `export
NODE_EXTRA_CA_CERTS=$HOME/.elastic-package/profiles/default/certs/kibana/ca-cert.pem`
in the same shell. This is to set up the certificate needed to access
EPR with https.
3. In Kibana, add the Elasticsearch integration (should be version
1.5.0). Check that the `Scope` setting is controlled by a select. Note:
in the latest version, this integration now provides a default value,
which should be set to `node`.

### 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)
- [ ] [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/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
@jen-huang jen-huang added the QA:Ready for Testing Code is merged and ready for QA to validate label Apr 6, 2023
@jen-huang
Copy link
Contributor

Great work completing this @jillguyonnet. Can you leave a comment with testing instructions for the QA team (probably using the new version of the Elasticsearch integration)? (@amolnater-qasource @dikshachauhan-qasource)

@jillguyonnet
Copy link
Contributor Author

@jen-huang @amolnater-qasource @dikshachauhan-qasource
Certainly! Here is a guide for testing this feature. Please let me know of any issues.

@dikshachauhan-qasource
Copy link

dikshachauhan-qasource commented Apr 11, 2023

Hi @jillguyonnet

Thanks for sharing the guide. Further, we have validated the changes as mentioned are currently available on Cloud 8.8 Snapshot build and found them working fine.

Build details:

VERSION: 8.8.0
BUILD: 62018
COMMIT: caf4ef815627e3dae29d8d752567cede886c10f4

Observations:

  • Elasticsearch Integration version available is 1.6.1
  • Dropdown is available at Scope field with two values "Node" and "Cluster".
  • On de-selection or using cross option, user is unable to save the changes and validation messgae is displayed.

Further, when we are using Preview API request option to validate the changes, we observed improper validation message is displayed.

cc @jen-huang

Screenshot:
image

Please let us know if this is expected and if we missed any other validation.

Thanks
QAS

@jillguyonnet
Copy link
Contributor Author

jillguyonnet commented Apr 12, 2023

Hi @dikshachauhan-qasource

Thank you for your report!

Elasticsearch Integration version available is 1.6.1
Dropdown is available at Scope field with two values "Node" and "Cluster".
On de-selection or using cross option, user is unable to save the changes and validation messgae is displayed.

These are expected 👍

Further, when we are using Preview API request option to validate the changes, we observed improper validation message is displayed.

I can reproduce this as well with version 1.5.0 of Elasticsearch. We should perhaps investigate whether this issue is related to this change, I am having a look.
Edit: I can reproduce this issue on Kibana 8.6.1 and Elasticsearch 1.3.0. I would say this is not related to this change. cc @jen-huang

@jen-huang
Copy link
Contributor

@jillguyonnet I agree it is not related to this change. @dikshachauhan-qasource could you file a separate issue with that finding? I think the policy_id field should not be present on that request in Preview API.

@jen-huang
Copy link
Contributor

@jillguyonnet My mistake, the policy_id field should be present, but I guess it is not filled in automatically.

@dikshachauhan-qasource This is expected behavior. The Preview API content expects you to replace <agent_policy_id> with the id field from the first request.

@dikshachauhan-qasource
Copy link

dikshachauhan-qasource commented Apr 13, 2023

Hi @jen-huang

Thanks for addressing above query and sharing your feedback. Further, as mentioned we have re-tried to validate above scenario using Preview API request and have following observations:

Working fine:

  • Scope field having Value "Node" in console, User is able to add integration successfully.

As per our understanding, Not Working Fine:

Screenshots:
image
image

  • Integration getting added to policy using API request:

image

Please let us know if we still are missing anything here.

Thanks
QAS

@jen-huang
Copy link
Contributor

Removed the scope variable from API request, still user able to add the integration successfully.

@dikshachauhan-qasource This one is expected since this has a default value that will be filled in automatically if it is excluded: https://github.com/elastic/integrations/blob/main/packages/elasticsearch/manifest.yml#L73

Provided null value in scope, here again user is able to add the integration successfully

Will follow up on this in #154905.

@dikshachauhan-qasource
Copy link

This one is expected since this has a default value that will be filled in automatically if it is excluded: https://github.com/elastic/integrations/blob/main/packages/elasticsearch/manifest.yml#L73

Thank you @jen-huang for feedback on above mentioned scenario.

@amolnater-qasource amolnater-qasource removed the QA:Ready for Testing Code is merged and ready for QA to validate label Feb 23, 2024
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:enhancement 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.

10 participants