-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Lens] Add support for decimals in percentiles #165703
Conversation
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
This works great, I just feel that the notification needs some refinement. @MichaelMarcialis @amyjtechwriter can you help us here? This notification appears in the following scenario. I have a percentile with an integer value and a top values dimension with rank by the metric(percentiles) and then go back to the metric and change the percentile from an integer to a decima value. At this point we want to notify the users that we changed automatically the rank by to alphabetical (ES limitation elastic/elasticsearch#66677) |
export function isValidNumber( | ||
inputValue: string | number | null | undefined, | ||
integer?: boolean, | ||
upperBound?: number, | ||
lowerBound?: number | ||
lowerBound?: number, | ||
digits: number = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we limiting it to 2 decimals? I could imagine an SRE wanting up to 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with that comment, do we need a limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. It's a simple constant change, so I'll update.
Yes I agree with that comment, do we need a limit?
Unfortunately yes. I've asked to add the support to any
but it is not coming in Range components: elastic/eui#5703
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
defaultMessage: 'Top values ranking reset', | ||
}), | ||
text: i18n.translate('xpack.lens.uiInfo.rankingResetToAlphabetical', { | ||
defaultMessage: 'The use of decimals for this function is not supported for ranking.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like "Ranking reset to alphabetical rank. Please only use whole numbers to rank by percentile."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with latest suggestions by @gchaps
This message could also use some help. Can we override the text here to say something closer to "Please limit to 2 decimal places" |
Here are some suggestions for the two messages. Suggestions for the ranking message
Suggestions for the decimal place meesage:
|
@dej611: Rather than showing the input as invalid (and asking that the user manually fix the problem themselves), would it be better for us to round to the nearest valid decimal on blur for the user? For example, if user enters
@dej611, @stratoula, @timductive: Are we absolutely certain we want to automatically change the top value dimension ranking when the user attempts to enter a decimal value for the metric percentile? I'm not an expert on these more advanced aggregations, but to my mind that feels backwards. I think it may make more sense and be less destructive to simply not allow users to enter a percentile with a decimal value if/when a top value dimension ranking is set to rank by metric. Per my comment above, could we not simply round any decimal entered to the nearest whole number automatically on blur (as well as conditionally add help text below the form element when it is detected that a top value dimension is ranked by metric and indicate to users that decimals are not supported)? In that case, we wouldn't need this toast at all. |
Not sure how it will work on blur because if I am not mistaken the request will be sent in ES and it will fail. Except from that we could not allow decimals if a top values breakdown rank by metric is detected. The problem I see in this approach is that the users need to go then to top values, fix the ranking and then change the decimals. With the current approach we do it automatically. Decimals are important in percentiles and percentiles ranks. If a user wants 99.9 they are not going to be happy with 99. We are already doing this in percentile ranks btw and we didn't have any complain afaik. |
Latest changes raised the limit to 4 decimals. (Note while testing inline: there's currently an EUI bug with integer check and 8 digits: elastic/eui#7180 )
|
Also the other way around (decimals => integer) will automagically update the ranking logic (this has always been like that in Lens). |
π Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this works great! I tested the new changes in Chrome, I really like the new message!
@stratoula: Are we completely unable to intercept and check the value before it is sent to ES?
@stratoula: I can understand that desire to make the process as automated as possible. But personally, I'd rather be notified of what needs to change in this case rather than having that ranking change forced upon me. I don't believe use of a decimal percentile is a valid indicator that the user also wishes to change their top value ranking. I think it's more likely that the user simply isn't aware of the limitation that they can't use decimal percentiles in that specific scenario. |
Absolutely, you are def right here. I guess it depends on the user and what they want to do after all. We are using this kind of automations on other places too. We can go with the current experience as is the same with the one we have on percentile ranks and if we get any complains we can adjust. @timductive @ninoslavmiskovic wdyt ? |
I like the automated approach and believe this would be sufficient for the user. The granularity is important in this case and I'm not sure the user would take the round trip based on a toast, if we prompt the user, but rather be unsatisfied. So I am ++ on automation and nice with the 4 digits. |
Summary
Fixes #98853
This PR adds support for decimals (2 digits) in percentile operation.
Features:
isValidNumber
to support digits check and added unit tests for itconvert to Lens
featureAdded both unit and functional tests.
When trying to add more digits than what is supported then it will show the input as invalid:
Also it works now as custom ranking column:
Notes: need to specify exact digits in percentile (2) because the
any
step is not supported and need to specify a number. I guess alternatives here are to either extend it to 4 digits or make it a configurable thing.Checklist
Delete any items that are not applicable to this PR.