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

[TSVB] Add Positive Rate to Aggregations #59843

Merged
merged 16 commits into from
Apr 9, 2020

Conversation

simianhacker
Copy link
Member

@simianhacker simianhacker commented Mar 10, 2020

Summary

This PR add positive_rate as a new aggregation to TSVB. This is essentially a shortcut for creating rates in TSVB. Instead of the user having to select max of a field, then derivative of the max, then positive_only they can now just select rate and choose the field.

Before

image

After

image

Checklist

Delete any items that are not applicable to this PR.

@simianhacker simianhacker added Feature:TSVB TSVB (Time Series Visual Builder) v7.7.0 v8.0.0 release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Mar 10, 2020
@elasticmachine
Copy link
Contributor

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

@simianhacker simianhacker marked this pull request as ready for review March 11, 2020 21:34
@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@timroes
Copy link
Contributor

timroes commented Mar 31, 2020

Just FYI: We still have that on our review list, thanks a lot for creating this PR, we're just working through the more urgent bug fixes right now for the upcoming release, before we'll get to this.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

LGTM with one minor comment (about translation ids).

Tested in Chrome and couldn't find a situation where rate would return something else than positive only of derivative of max of the same field (tested all visualizations, grouping by various things, overriding index pattern, adding filters, with rollup index).

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Code LGTM.
Tested locally, everything seems to work in the exact way as with using the max-derivative-positive-only method. Saving/reloading works fine.
I've just one small doubt: is it allowed to use unit multiples like 2s 5m 3w?

@simianhacker
Copy link
Member Author

@markov00 Yes, you can put anything in there that is supported by the underlying derivative function which is a date math expression, it will just use math to scale it from the "actual buckets" to the unit you specified. If the buckets in date_histogram are set to 10s and you set 5m for the unit, with a value of 1024 you would end up with 1024 / 10 * 300 = 30720 for the normalized_value. Here is a visual example:

image

Keep in mind that 2w won't work because weeks are not supported by the derivative pipeline aggregation.

@simianhacker
Copy link
Member Author

@wylieconlon The goal is to create an aggregation that's a shortcut for the max-derivative-positive-only combination that has become the standard in the "metrics" use case. We've seen a lot of people (externally/internally) use derivative incorrectly and we are trying to guide them towards something more sensible. Maybe Positive Only Rate would be a better name or your suggestion Max Positive Change.

Another approach would be to add "positive only" flag as an option for rate, enabled by default.

@sorantis Thoughts?

@wylieconlon
Copy link
Contributor

@simianhacker Can you explain why this is the standard? I understand that you're trying to take a best practice that works for your specific use case, but I'm trying to think about how this applies to any dataset.

@simianhacker
Copy link
Member Author

simianhacker commented Apr 2, 2020

Can you explain why this is the standard? I understand that you're trying to take a best practice that works for your specific use case, but I'm trying to think about how this applies to any dataset.

@wylieconlon With regards to metrics in general, we (Elastic Stack) kind of have a bigger problem because we don't have an reliable way to distinguish the field (metric) type, either gauge or counter. This makes it difficult to guide our users to the right aggregations.

If they choose a field that's a counter and then ask for a rate, we should automatically apply max first thenderivate (and most likely positive_only too since counters have to reset at the upper bounds of their type). At that point, the intent of the user is to create a histogram of the positive changes over time; counters grow at different rates.

For gauge types, "rate" takes on a different meaning because at that point, the question is "Is the value increasing or decreasing?" With counters, that question isn't really important because it's always increasing. BUT we can still ask that question once the counter is converted to a rate, you just need to take a second derivative. Context matters when it comes to "rates".

The problem is we have no idea which context we are dealing with, we are stuck trying to come up with names that might guide the user in the right direction. In the "gauge" context, rate in this PR is usually going to be wrong; for the "counter" context it's right. Most of the time, users are confronted with this when they are working with Metricbeat data like system.network.out.bytes. But as we expand into more general metrics use cases, this will keep coming up.

I think this is mostly a naming issue and we need to come up with something that describes the result. I'm starting to think maybe "Growth Rate" is a better name since that's really what we are doing.

Side note: We also have an issue with metrics like system.network.out.bytes because when they are reported there are other important attributes like system.network.interface that must be considered when aggregating. If you want to know the "total" outbound traffic on a host, then you need to calculate the rate for ALL the interfaces (individually) and then add them together. Unless you filter the metric down to system.network.interface, using max on system.network.out.bytes will give you the rate for the interface who's seen the most traffic. Systems like Prometheus avoid these types of pitfalls because the default behavior is to split by ALL attributes.

@wylieconlon
Copy link
Contributor

Discussed a bit offline, and I think we clarified this a lot. The new function is not meant to be used for all rates, the derivative function is still useful for those. This function should only be used for numbers that are monotonically increasing, such as disk IO. The "positive only" part of this aggregation is used when the increasing number resets to 0, such as when it hits the max integer.

Based on this, I think we need to change the name and add a line of help text explaining what problem this is solving.

@simianhacker simianhacker changed the title [TSVB] Add Rate to Aggregations [TSVB] Add Growth Rate to Aggregations Apr 2, 2020
@timroes
Copy link
Contributor

timroes commented Apr 6, 2020

Adding to Marko's question here with time units. While you can do that technically, is there any reasonable use-case why a user would want to use something except 1 as a unit for those? I am thinking in terms of replacing that freeform text input (which otherwise would need some validation that you can't input invalid ES intervals), into a selectbox that just allows you to select "per second", "per minute", "per hour", etc.

I currently don't see any use-cases where users would want to have it on an "non 1" unit. If there are some I'd interested in hearing them, also if we keep the input box, we def want to add validation on it using the isValidEsInterval utility from the data plugin.

@simianhacker
Copy link
Member Author

simianhacker commented Apr 6, 2020

@timroes I changed "units" to "scale" and changed the text field to a select box. If the user needs a custom interval, they can always use "the advance way" (max, derivative, positive_only) and scale it via the derivative aggregation. Down the road, if we get enough push back from users that they want that field to be "free form", we can always switch it back since the values are going to be the same.

@simianhacker simianhacker changed the title [TSVB] Add Growth Rate to Aggregations [TSVB] Add Positive Rate to Aggregations Apr 8, 2020
@simianhacker
Copy link
Member Author

After some offline discussions, I've decided to rename this to "positive rate" since "growth rate" is a little misleading; growth rates are usually presented as percents.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

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.

The name and behavior are working as expected! I did not review the code of this.

@simianhacker simianhacker merged commit 087df82 into elastic:master Apr 9, 2020
simianhacker added a commit to simianhacker/kibana that referenced this pull request Apr 9, 2020
* [TSVB] Add Rate to Aggregations

* Fixing i18n labels

* Changing from rate to growth_rate; adding message to aggregation form;

* Change units to scale; change free text to combobox

* Fixing placeholder

* Fixing i18n label

* Changing from Growth Rate to Positive Rate

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added backport missing Added to PRs automatically when the are determined to be missing a backport. and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 13, 2020
simianhacker added a commit that referenced this pull request Apr 13, 2020
* [TSVB] Add Rate to Aggregations

* Fixing i18n labels

* Changing from rate to growth_rate; adding message to aggregation form;

* Change units to scale; change free text to combobox

* Fixing placeholder

* Fixing i18n label

* Changing from Growth Rate to Positive Rate

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@simianhacker simianhacker deleted the tsvb-rate-aggregation branch April 17, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:TSVB TSVB (Time Series Visual Builder) release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants