Skip to content

Add auto interval to histogram AggConfig #75438

@timroes

Description

@timroes

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.

The following steps need to be made:

  • Allow auto as an allowed interval option (this shoul not require any changes by itself)
  • Add an option autoIntervalTarget to the histogram AggConfig and the corresponding expression function, that takes a number or undefined. This parameter should default if not specified to the histogram:barTarget advanced setting.
  • Adjust the logic of how the actual interval is calculated (see below)
  • Add lots of tests

I think the way those parameters (interval, intervalBase, autoIntervalTarget) are playing together should be the following:

  • If interval has a value !== auto everything should behave as beforehand:
    • If using that value would create too many buckets (higher than histogram:maxBars), increase the interval.
    • Always make sure if intervalBase is set, that the used interval is a multiple of intervalBase (this is required for rollups).
    • autoIntervalTarget has no effect if it's set as long as interval !== 'auto'
  • If interval is set to auto do the following:
    • Use the max/min value (if they couldn't be loaded this request should fail altogether).
    • Check which interval we need to reach autoIntervalTarget buckets AND have a multiple of intervalBase (if set) AND be a more or less roundish value (so we're not ending up with intervals of 146.12). cc @wylieconlon @lukeelmers interested to hear your opinion on what reasonable roundings could be here. We have similar code for the maxInterval check, not sure if that's the logic we want to keep.
    • Make the actual request with that interval.

One question for me would be: What happens if the autoIntervalTarget is larger than the histogram:maxBars defined in advanced settings? I see two solutions:

  • Either set autoIntervalTarget to histogram:maxBars if it exceeds it, or
  • ignore histogram:maxBars in this case, since the "consumer" (e.g. the editor like Lens) explicitly set a higher value, but then again it would kind of render the histogram:maxBars useless, if it's not really limiting max bars.

Would also be curious about your thoughts on that?

Metadata

Metadata

Assignees

Labels

Feature:AggregationsAggregation infrastructure (AggConfig, esaggs, ...)enhancementNew value added to drive a business result

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions