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

[APM] Handle other values popup when correlated value is not in top 10 #118069

Merged
merged 15 commits into from
Dec 7, 2021

Conversation

qn895
Copy link
Member

@qn895 qn895 commented Nov 9, 2021

Summary

This PR shows the percentage/stats for the the selected item in addition to the top 10 values. If the value is not in the top 10 values, an additional query is made to calculate the percentage for the field name/field value.

Screen Shot 2021-11-10 at 16 37 27

It also removes the percentiles agg in the numeric fields because we don't need it.

Screen.Recording.2021-12-06.at.09.46.04.mov

Checklist

Delete any items that are not applicable to this PR.

@qn895 qn895 marked this pull request as ready for review November 10, 2021 00:50
@qn895 qn895 requested a review from a team as a code owner November 10, 2021 00:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Nov 10, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

)}

{topValueStats.topValuesSampleSize !== undefined && (
<Fragment>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just use <>. You only need to import Fragment if you'll need to give it a key.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here 58d8bcc

<EuiHorizontalRule margin="s" />
<EuiSpacer size="s" />
<EuiText size="xs">
<FormattedMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

Most places in APM we just use i18n.translate directly instead of using the FormattedMessage component.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here 58d8bcc

@qn895 qn895 requested a review from formgeist November 10, 2021 23:26
@walterra
Copy link
Contributor

Noticed the following:

image

I'm not sure if the results here are correct. The field/value shows up in the table, that's lets me assume there must be some data, there's also a corresponding histogram in the chart, see the tooltip. Nonetheless, the query for the tooltip doesn't find any results. To reproduce, this happens with the antifraud data set, servicename frontend, transaction type createOrder.

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Just added a few small suggestions for the code. It would be really great if we could already add an API integration test for the additional API endpoint as part of this PR.

@@ -184,6 +184,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
body: {
...getOptions(),
fieldsToSample: [...fieldsToSample],
samplerShardSize: 5000,
Copy link
Contributor

Choose a reason for hiding this comment

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

This uses a different size than the runtime code. Should we change this to 10000 and also use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@@ -195,6 +195,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
body: {
...getOptions(),
fieldsToSample: [...fieldsToSample],
samplerShardSize: 5000,
Copy link
Contributor

Choose a reason for hiding this comment

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

This uses a different size than the runtime code. Should we change this to 10000 and also use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@@ -20,7 +20,7 @@ const params = {
includeFrozen: false,
environment: ENVIRONMENT_ALL.value,
kuery: '',
samplerShardSize: 5000,
samplerShardSize: 10000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@@ -76,7 +69,7 @@ describe('field_stats', () => {
},
},
},
sampler: { shard_size: 5000 },
sampler: { shard_size: 10000 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@@ -88,7 +81,7 @@ describe('field_stats', () => {

const expectedAggs = {
sample: {
sampler: { shard_size: 5000 },
sampler: { shard_size: 10000 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@@ -105,7 +98,7 @@ describe('field_stats', () => {

const expectedAggs = {
sample: {
sampler: { shard_size: 5000 },
sampler: { shard_size: 10000 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use SAMPLER_SHARD_SIZE from x-pack/plugins/apm/common/correlations/constants.ts?

@formgeist
Copy link
Contributor

@qn895 This might be a later enhancement, but I wonder if the popover should show a loading spinner if the results are still waiting to be completed. Right now, the top 10 list is loaded, but the selected term might come in after because it's outside the top 10. Here's an example of that behavior;

CleanShot 2021-11-11 at 12 32 29

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Added a small comment about possibly adding a loading state to the popover to indicate when it's still fetching results once the top 10 is loaded. And a smaller suggestion on changing the text color of the "outside top 10" message.

{Array.isArray(fieldValueStats?.topValues) && (
<>
<EuiHorizontalRule margin="s" />
<EuiText size="xs">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<EuiText size="xs">
<EuiText size="xs" color="subdued">

Lowering the contrast of this message since it's just a help text label for the result.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or looking at the EUI 41.0.0 upgrade PR, should color="text" be used rather than subdued?

Copy link
Contributor

Choose a reason for hiding this comment

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

text is darker contrast than subdued - what's the EUI upgrade change you're referring to?

CleanShot 2021-11-11 at 15 36 24@2x

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry - you're right @formgeist, the EUI 41.0.0 upgrade only changes it to text for EuiButtonIcon.

@peteharverson
Copy link
Contributor

As commented by @walterra in #118069 (comment), if the calculations / queries are correct for this sort of situation, we should adjust the text in the popover.

Maybe here the top label should say Top value, and the bottom one could say something like Selected term not found in sample of 20000 documents:

image

@peteharverson
Copy link
Contributor

Is the rounding causing this? Is it really 99.7% for 200?

image

@formgeist
Copy link
Contributor

As commented by @walterra in #118069 (comment), if the calculations / queries are correct for this sort of situation, we should adjust the text in the popover.

Maybe here the top label should say Top value, and the bottom one could say something like Selected term not found in sample of 20000 documents:

image

I thought that was described by the "Calculated from sample of x documents", so we don't have to also describe it, but perhaps we really need to repeat it just to make sure it's understood.

@elastic elastic deleted a comment from kibanamachine Dec 5, 2021
@qn895 qn895 force-pushed the apm-popover-not-top-10 branch from 41ccdf0 to e5e0650 Compare December 6, 2021 05:13
Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM

@qn895
Copy link
Member Author

qn895 commented Dec 7, 2021

@elasticmachine merge upstream

@qn895
Copy link
Member Author

qn895 commented Dec 7, 2021

@elasticmachine merge upstream

@qn895 qn895 enabled auto-merge (squash) December 7, 2021 19:24
@qn895 qn895 added the auto-backport Deprecated - use backport:version if exact versions are needed label Dec 7, 2021
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
apm 2.8MB 2.8MB +1.3KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
apm 46 47 +1

History

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

cc @qn895

@qn895 qn895 merged commit f5141e4 into elastic:main Dec 7, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Dec 7, 2021
elastic#118069)

* [ML] Add stats for field value not in top 10

* [ML] Fix tests

* [ML] Add message

* [ML] Reverse label, remove Fragment, switch to i18n

* Fix sample shard size import, subdued text

* Fix sample shard size import, subdued text

* Move routes after refactor

* Add loading spinner

* Fix sampler shard size

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Dec 7, 2021
#118069) (#120680)

* [ML] Add stats for field value not in top 10

* [ML] Fix tests

* [ML] Add message

* [ML] Reverse label, remove Fragment, switch to i18n

* Fix sample shard size import, subdued text

* Fix sample shard size import, subdued text

* Move routes after refactor

* Add loading spinner

* Fix sampler shard size

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Quynh Nguyen <[email protected]>
@qn895 qn895 deleted the apm-popover-not-top-10 branch December 8, 2021 21:58
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
elastic#118069)

* [ML] Add stats for field value not in top 10

* [ML] Fix tests

* [ML] Add message

* [ML] Reverse label, remove Fragment, switch to i18n

* Fix sample shard size import, subdued text

* Fix sample shard size import, subdued text

* Move routes after refactor

* Add loading spinner

* Fix sampler shard size

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:correlations auto-backport Deprecated - use backport:version if exact versions are needed :ml release_note:enhancement Team:APM All issues that need APM UI Team support v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants