Skip to content

[OnWeek][Discover] Allow to change current sample size and save it with a saved search#157269

Merged
jughosta merged 49 commits intoelastic:mainfrom
jughosta:onweek-configurable-sample-size
Oct 19, 2023
Merged

[OnWeek][Discover] Allow to change current sample size and save it with a saved search#157269
jughosta merged 49 commits intoelastic:mainfrom
jughosta:onweek-configurable-sample-size

Conversation

@jughosta
Copy link
Contributor

@jughosta jughosta commented May 10, 2023

Summary

This PR allows to change current sample size right from Discover page, no need to modify the global default value.

Saved search panels on Dashboard will also use the saved value to fetch only the requested sample size. This customisation was requested by many customers as it will allow to load Dashboards faster.

Current range for the slider: from 10 to 1000 (with a step 10).

Screenshot 2023-10-09 at 11 10 52

Checklist

@jughosta jughosta changed the title [Discover] Allow to change current sample size and save it with a saved search [OnWeek][Discover] Allow to change current sample size and save it with a saved search May 10, 2023
@jughosta jughosta self-assigned this May 11, 2023
@jughosta jughosta added release_note:enhancement Feature:Discover Discover Application backport:skip This PR does not require backporting Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// labels May 11, 2023
@jughosta
Copy link
Contributor Author

@andreadelrio What do you think about this UI/UX addition (settings icon + a slider)? What else could fit here to enable this functionality for users?

@andreadelrio
Copy link
Contributor

@andreadelrio What do you think about this UI/UX addition (settings icon + a slider)? What else could fit here to enable this functionality for users?

@jughosta I think what you have works. However, if you wanted to have higher discoverability you could place this on the left side instead like so:

Frame 1

@jughosta
Copy link
Contributor Author

@andreadelrio Thanks! I pushed the updates. What was the name of the icon you used? The closest one I could find is visTable.

Discover page:
Screenshot 2023-05-22 at 19 27 01

Dashboard view:
Screenshot 2023-05-22 at 19 27 52

@andreadelrio
Copy link
Contributor

@andreadelrio Thanks! I pushed the updates. What was the name of the icon you used? The closest one I could find is visTable.

Discover page: Screenshot 2023-05-22 at 19 27 01

Dashboard view: Screenshot 2023-05-22 at 19 27 52

@jughosta the icon name is editorTable.

@andreadelrio
Copy link
Contributor

@andreadelrio What do you think about this UI/UX addition (settings icon + a slider)? What else could fit here to enable this functionality for users?

@jughosta I think what you have works. However, if you wanted to have higher discoverability you could place this on the left side instead like so:

Frame 1

@gchaps can you let us know if this label is ok for a button? in particular shortening "maximum" to "max". Thanks

@gchaps
Copy link
Contributor

gchaps commented May 24, 2023

Yes, using 'max' works.

jughosta added 3 commits June 8, 2023 10:53
…-sample-size

# Conflicts:
#	src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts
@jughosta jughosta marked this pull request as ready for review October 6, 2023 15:36
@jughosta jughosta requested review from a team as code owners October 6, 2023 15:36
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

compressed
fullWidth
min={1}
max={MAX_ALLOWED_SAMPLE_SIZE}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, I'm wondering if the current input might give the impression that it can accept really big numbers for sample size:

image

And since there is this limit, what about changing to EuiSlider as was previously suggested? Keeping the validations of the onChangeActiveSampleSize method, as EuiSlider doesn't handle that.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@opauloh Thanks for your feedback! The slider was not really helpful when having a step of 1, so an input would work better. But there is another option: to have a slider with a step 10 starting from 10. Updated the PR via 7feb2ae

Screenshot 2023-10-09 at 11 10 52

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

Thanks for updating it @jughosta ! I liked how it's visually clear now that it can go up to the max limit, and that the default selection is in between!

Agree on changing the steps, a step of 10 makes way more sense for this purpose and improves the usability!

Copy link
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

CloudSecurityDataTable changes LGTM

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

LGTM regarding updates to the SO

const hideAnnouncements = useMemo(() => uiSettings.get(HIDE_ANNOUNCEMENTS), [uiSettings]);
const isLegacy = useMemo(() => uiSettings.get(DOC_TABLE_LEGACY), [uiSettings]);
const sampleSize = useMemo(() => uiSettings.get(SAMPLE_SIZE_SETTING), [uiSettings]);
const defaultSampleSize = useMemo(() => uiSettings.get(SAMPLE_SIZE_SETTING), [uiSettings]);
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 max limit? If there isn't, we need to have one set. Users often don't know the effects of loading too many documents.

  • What's the default for sample size? One test uses 70, is that it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @TinaHeiligers,

Is there a max limit? If there isn't, we need to have one set. Users often don't know the effects of loading too many documents.

Yes, currently it's between 10 and 1000. Users can now also press "Load more" for loading next pages (PR).

What's the default for sample size? One test uses 70, is that it?

It's 500 by default.

import { MigrateFunctionsObject } from '@kbn/kibana-utils-plugin/common';
import { VIEW_MODE } from '../../common';
import { getAllMigrations } from './search_migrations';
import { SCHEMA_SEARCH_V8_8_0, SCHEMA_SEARCH_V8_12_0 } from './schema';
Copy link
Contributor

Choose a reason for hiding this comment

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

😄

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Awesome work! Code looks good, and it worked well during testing 👍

The only thing I feel could be improved is that when I set the default sample size to a value greater than 1000, then change the sample size to a custom one, I'm unable to get the default sample size back unless I click the "New" button:
sample

A couple of options I think are worth considering:

  • Make it so that clearing the sample size input resets it to the default.
  • Dynamically set the max sample size based on the greater of the default value or 1000.

Wdyt?

}

if (onUpdateSampleSize) {
options.allowResetButton = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we set this to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davismcphee Since we have issues with the button #131130 and now we introduce additional settings which are not handled by eui code, we better hide the button. Originally suggested by @kertal

Copy link
Member

Choose a reason for hiding this comment

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

yes, it did not work as expected, and introducing new settings, wouldn't make it better, so I suggested to remove it (not having a good way to handle it, at least back in the days)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, makes sense to remove it for now if it wasn't working as intended. Might be worth figuring out if we can fix it and add it back in later though. It would be convenient to be able to reset the sample size back to the saved search default after changing it on a dashboard and saving, which persists the updated value with the dashboard.

import { i18n } from '@kbn/i18n';
import { debounce } from 'lodash';

export const MAX_ALLOWED_SAMPLE_SIZE = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we set to 500, which is the default in Advanced settings, and limit the max to discover:sampleSize? We now have the option to load more anyway. I've configured 2000 for this setting, still was was 1000. So I think taking discover:sampleSize into consideration makes sense, also it should be used e.g. when an admin decides to go back from 1000 to 500 , the user configured 990, it could make sense to limit the request to 500 in this case, wdyt?
This is what came to my mind while testing it. Apart from that: 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kertal That's a good idea! The only issues is that if we base the max size on discover:sampleSize then we can't set it for the schema validation. Also users can even now update it in the URL and request more than the configured discover:sampleSize, would you limit that too?

Copy link
Contributor Author

@jughosta jughosta Oct 13, 2023

Choose a reason for hiding this comment

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

We could define 10_000 limit for the schema and in UI use min of 10_000 and discover:sampleSize as max limit.

Copy link
Member

Choose a reason for hiding this comment

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

A hard limit of 10000 could be a good idea for the schema ... however we should make sure the number requested from ES should be limited by the sampleSize. Because in the end, this it was matters in terms of traffic and performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kertal I pushed changes for it 9766615

Could you please check if it's close to what you meant?

Copy link
Member

Choose a reason for hiding this comment

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

i will, thx!

Copy link
Member

Choose a reason for hiding this comment

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

Tested and it's exactly what I meant! Thx 🙏 !

@jughosta
Copy link
Contributor Author

@davismcphee

The only thing I feel could be improved is that when I set the default sample size to a value greater than 1000, then change the sample size to a custom one, I'm unable to get the default sample size back unless I click the "New" button

When a too large number is entered, we show a validation error. It's not applied to the state. Closing the settings popover will take you back. Yes, we don't provide a way to go to a default value if user moves the slider after that, is it an issue? With the latest changes, the default value becomes the slider's max value.

@kibana-ci
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloudSecurityPosture 379 380 +1
discover 675 677 +2
logExplorer 454 455 +1
total +4

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
@kbn/unified-data-table 43 44 +1
savedSearch 71 74 +3
total +4

Async chunks

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

id before after diff
cloudSecurityPosture 399.5KB 400.4KB +977.0B
discover 575.0KB 577.4KB +2.4KB
total +3.3KB

Page load bundle

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

id before after diff
discover 30.9KB 31.1KB +141.0B
savedSearch 10.9KB 11.1KB +252.0B
total +393.0B
Unknown metric groups

API count

id before after diff
@kbn/unified-data-table 100 103 +3
discover 118 119 +1
savedSearch 72 75 +3
total +7

History

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

cc @jughosta

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

The latest changes look good, and I tested again and it's working great. Thanks for the work on this, another useful new feature! 🎉

Yes, we don't provide a way to go to a default value if user moves the slider after that, is it an issue? With the latest changes, the default value becomes the slider's max value.

I left a comment explaining why the reset functionality would be useful, but I think it's ok for now. Otherwise the change to make the default value the max addresses my concern 👍

}

if (onUpdateSampleSize) {
options.allowResetButton = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, makes sense to remove it for now if it wasn't working as intended. Might be worth figuring out if we can fix it and add it back in later though. It would be convenient to be able to reset the sample size back to the saved search default after changing it on a dashboard and saving, which persists the updated value with the dashboard.

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 Feature:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.12.0

Projects

None yet

10 participants