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

Add auto interval to histogram AggConfig #76001

Merged
merged 21 commits into from
Sep 1, 2020
Merged

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Aug 26, 2020

Closes: #75438

Summary

What was done it that PR:

  • Since the histogram aggConfig does already do a preflight request to determine min and max to later make sure we're not running over the histogram:maxBars setting, we can use that min/max information to easily allow an auto interval option.

  • Add support for intervals which less than 1. Based on Add auto interval to histogram AggConfig #75438 (comment)
    image

  • Set Auto mode as a default for new aggregations in Vis Editor

Before:
image

After:
image

image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@wylieconlon
Copy link
Contributor

I have reviewed the code and submitted a PR to you to change the layout and defaults to what makes sense to me: https://github.com/alexwizp/kibana/pull/4/files

The main changes are:

  • Auto is default
  • The max bars defaults to the max allowed by Kibana
  • When switching to a fixed interval, 0 is no longer valid

@alexwizp
Copy link
Contributor Author

@wylieconlon I've reviewed your changes but if I don't understand the benefits of adding one more configuration property. I'm about useAuto. Date Histogram in default editor, TSVB and I think other places use interval field for that. I see probably only one reason, we can do it for saving value between switching isAuto. But for consistency I prefer to keep current approach.

@alexwizp alexwizp self-assigned this Aug 27, 2020
@alexwizp alexwizp added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Aug 27, 2020
@alexwizp alexwizp marked this pull request as ready for review August 27, 2020 19:21
@alexwizp alexwizp requested a review from a team August 27, 2020 19:21
@alexwizp alexwizp requested a review from a team as a code owner August 27, 2020 19:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@sulemanof sulemanof left a comment

Choose a reason for hiding this comment

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

LGTM
Checked locally in Chrome, works fine

@alexwizp
Copy link
Contributor Author

alexwizp commented Sep 1, 2020

@elasticmachine merge upstream

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Please don't merge yet, the algorithm for selecting intervals doesn't look right.

return interval;
};

const calculateAutoInterval = (
Copy link
Contributor

Choose a reason for hiding this comment

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

These functions are not behaving the way I expected, as described here: #75438 (comment)

I'll comment separately with tweaks.

@wylieconlon
Copy link
Contributor

@elasticmachine merge upstream

@wylieconlon
Copy link
Contributor

@alexwizp There are several differences between the algorithm you've implemented here and the one that I was expecting. The main one is that I'm optimizing to pick "simple" intervals which are multiples of 10, 2 or 5, while yours is not. So with your bucketing, CPU values are bucketed into intervals of 0.3:

Screen Shot 2020-09-01 at 12 46 42 PM

While mine is choosing 0.2:

Screen Shot 2020-09-01 at 12 44 15 PM

I'm also not having any special cases for integers vs floats, they should be treated identically from my perspective.

alexwizp#5

@alexwizp
Copy link
Contributor Author

alexwizp commented Sep 1, 2020

@wylieconlon Honestly I don't understand why we should pick "simple" intervals which are multiples of 10, 2 or 5. it's just one of the possible variant. If we are talking about an example above for me 0.3 and 0.2 both valid values for auto mode.

@lukeelmers could you please have a look?

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

If we are talking about an example above for me 0.3 and 0.2 both valid values for auto mode.

It makes sense to me that we'd make some attempt at providing "pretty" intervals when somebody selects auto. IMO it's easier for someone to visually digest multiples of 10 (or 2, 5, 10) than another arbitrary interval.

Overall the code here LGTM & the math makes sense, however as @wylieconlon points out this isn't exactly the algorithm that he proposed in the issue... so if we want to deviate from that proposal I think we'd need to discuss further to make sure everyone is on the same page.

Otherwise, I'm comfortable with merging once this aligns with the original plan and we add a few more clarifying comments in the code.

src/plugins/data/common/search/aggs/buckets/histogram.ts Outdated Show resolved Hide resolved
return roundInterval(diff / bars);
};

export const calculateHistogramInterval = ({
Copy link
Member

Choose a reason for hiding this comment

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

This is the type of code that can be really hard to maintain if you have to read through the math without any background and grok what's going on.

For future reference & to make maintenance easier, it would be great if we could add some detailed comments to each of the functions in this file, explaining the algorithm at a high level, what each function does, and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I've added a textual description of @wylieconlon 's original algorithm 11f6ec8

@alexwizp
Copy link
Contributor Author

alexwizp commented Sep 1, 2020

Algorithm of @wylieconlon works better for some cases. I think we should choose it. Thank you again.
PR was updated

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

I'm good with these changes once we get a green build, but please wait for a final LGTM from Wylie before merging.

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Changes LGTM!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
charts 269 +1 268
data 545 +1 544
regionMap 252 +1 251
tileMap 258 +1 257
visTypeMarkdown 259 +1 258
visTypeMetric 261 +1 260
visTypeTable 278 +1 277
visTypeTagcloud 262 +1 261
visTypeTimelion 281 +1 280
visTypeVega 312 +1 311
visTypeVislib 508 +1 507
visualize 316 +1 315
total +12

async chunks size

id value diff baseline
visualize 697.6KB +3.9KB 693.8KB

page load bundle size

id value diff baseline
charts 877.5KB +3.9KB 873.6KB
data 1.4MB +3.2KB 1.4MB
regionMap 836.3KB +3.9KB 832.4KB
tileMap 847.9KB +3.9KB 844.1KB
visTypeMarkdown 560.0KB +3.9KB 556.1KB
visTypeMetric 584.7KB +3.9KB 580.9KB
visTypeTable 608.8KB +3.9KB 604.9KB
visTypeTagcloud 841.2KB +3.9KB 837.3KB
visTypeTimelion 716.0KB +3.9KB 712.1KB
visTypeVega 665.5KB +3.9KB 661.7KB
visTypeVislib 1.3MB +3.9KB 1.3MB
total +41.8KB

oss distributable file count

id value diff baseline
total 27307 +1 27306

distributable file count

id value diff baseline
total 45470 +1 45469

History

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

@alexwizp alexwizp merged commit 7d82e27 into elastic:master Sep 1, 2020
alexwizp added a commit to alexwizp/kibana that referenced this pull request Sep 1, 2020
* Add `auto` interval to histogram AggConfig

Closes: elastic#75438

* fix JEST

* update UI

* add tests

* some changes

* small changes

* cleanup code

* fix PR comment

* fix PR comments

* fix PR comment

* Update src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.test.ts

Co-authored-by: Wylie Conlon <[email protected]>

* Change algorithm for auto interval

* Update src/plugins/data/common/search/aggs/buckets/histogram.ts

Co-authored-by: Luke Elmers <[email protected]>

* added some comments

* Update src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts

Co-authored-by: Wylie Conlon <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Wylie Conlon <[email protected]>
Co-authored-by: Luke Elmers <[email protected]>
alexwizp added a commit that referenced this pull request Sep 2, 2020
* Add `auto` interval to histogram AggConfig

Closes: #75438

* fix JEST

* update UI

* add tests

* some changes

* small changes

* cleanup code

* fix PR comment

* fix PR comments

* fix PR comment

* Update src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.test.ts

Co-authored-by: Wylie Conlon <[email protected]>

* Change algorithm for auto interval

* Update src/plugins/data/common/search/aggs/buckets/histogram.ts

Co-authored-by: Luke Elmers <[email protected]>

* added some comments

* Update src/plugins/data/common/search/aggs/buckets/lib/histogram_calculate_interval.ts

Co-authored-by: Wylie Conlon <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Wylie Conlon <[email protected]>
Co-authored-by: Luke Elmers <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Wylie Conlon <[email protected]>
Co-authored-by: Luke Elmers <[email protected]>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Sep 2, 2020
* master: (223 commits)
  skip flaky suite (elastic#75724)
  [Reporting] Add functional test for Reports in non-default spaces (elastic#76053)
  [Enterprise Search] Fix various icons in dark mode (elastic#76430)
  skip flaky suite (elastic#76245)
  Add `auto` interval to histogram AggConfig (elastic#76001)
  [Resolver] generator uses setup_node_env (elastic#76422)
  [Ingest Manager] Support both zip & tar archives from Registry (elastic#76197)
  [Ingest Manager] Improve agent vs kibana version checks (elastic#76238)
  Manually building `KueryNode` for Fleet's routes (elastic#75693)
  remove dupe tinymath section (elastic#76093)
  Create APM issue template (elastic#76362)
  Delete unused file. (elastic#76386)
  [SECURITY_SOLUTION][ENDPOINT] Trusted Apps Create API (elastic#76178)
  [Detections Engine] Add Alert actions to the Timeline (elastic#73228)
  [Dashboard First] Library Notification (elastic#76122)
  [Maps] Add mvt support for ES doc sources  (elastic#75698)
  Add setHeaderActionMenu API to AppMountParameters (elastic#75422)
  [ML] Remove "Are you sure" from data frame analytics jobs (elastic#76214)
  [yarn] remove typings-tester, use @ts-expect-error (elastic#76341)
  [Reporting/CSV] Do not fail the job if scroll ID can not be cleared (elastic#76014)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Vis Editor Visualization editor issues release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add auto interval to histogram AggConfig
7 participants