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

Expose agg usage in Feature Usage API #53746

Closed
polyfractal opened this issue Mar 18, 2020 · 6 comments · Fixed by #55732
Closed

Expose agg usage in Feature Usage API #53746

polyfractal opened this issue Mar 18, 2020 · 6 comments · Fixed by #55732

Comments

@polyfractal
Copy link
Contributor

After the ValuesSource refactor lands, all aggregation usage will flow through the new registry. This gives us an opportunity to easily count usage of the aggs and expose on the Nodes feature usage API.

The API is helpful for single-purpose endpoints, but endpoints like Search have a huge number of disparate actions which are all lumped together. Searches, aggregations, highlighting, suggestions, scrolling, composite, etc etc all show up under the Search endpoint.

There are many times an administrator would like to see more granular data about what's flowing through their Search endpoint, without enabling slow logs and picking through the firehose. Since queries and aggregations are among the more expensive operations, we should provide more granular feedback on these activities. With a relatively small change to the VS registry we can record how often agg builders are parsed and give an administrator a high-level overview of usage.

It would also make opt-in telemetry simpler and less invasive to collect for XPack features.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@imotov
Copy link
Contributor

imotov commented Apr 22, 2020

We have two ways of implementing this feature: incrementing the usage counter on the parser invocation and by incrementing the counter on ValuesSourceRegistry access.

In case of parser, we can count high level invocations. Basically for each search that contains one aggregation of a certain type we will count it as one use. Unfortunately, on this level we will not have information about value type the aggregation is executed one. So for example if a percentiles was executed we will not know if it was executed on histogram data type or not.

In case of ValuesSourceRegistry access counters, we will now the type, but we will count each shard access as a separate invocation. So, if we execute a single search with a single aggregation on 2 indices with 5 shards each, we will count his as 10 invocation. We can do some tricks like counting it only on shard 0. In this case it will be counted as 2 invocations.

@polyfractal
Copy link
Contributor Author

I'm tentatively leaning towards the second option. I think it'd be more useful to know the complete list of aggs being used, as well as which field types they are being used against... even if it means they are "over-counted" by doing it per-shard. My feeling is that the absolute numbers don't matter as much as relative numbers?

E.g. as an administrator I think I'd care that an expensive scripted-metric might be running two orders of magnitude more than all the other aggs, but not necessarily care about the exact numbers. So it's all relative and doesn't really rely on precise once-per-query counting.

@giladgal
Copy link
Contributor

I agree between these two the second option seems better.

@imotov
Copy link
Contributor

imotov commented Apr 22, 2020

Thanks! I am going with the second option then.

@imotov
Copy link
Contributor

imotov commented Apr 24, 2020

At the end of the day @not-napoleon found a good place to make a single call per parsing while having values source type in hand.

imotov added a commit to imotov/elasticsearch that referenced this issue Apr 24, 2020
Counts usage of the aggs and exposes them on the _nodes/usage/.

Closes elastic#53746
imotov added a commit that referenced this issue Apr 30, 2020
* Expose agg usage in Feature Usage API

Counts usage of the aggs and exposes them on the _nodes/usage/.

Closes #53746

* Refactor to include non value sources aggregations

* Fix reported values source type for parent and children aggs

* Refactor SearchModule constructor

* Fix subtype in TTest and IPRanges

* Fix more subtypes in aggs that don't register themselves

* Fix doc tests

* Fix docs

* Fix ScriptedMetricAggregatorTests

* Fix compilation issues after merge

* Fix merge fallout

* This gets stale quickly...

* Address review comments

* Fix tests that were missing proper agg registration in the search module

* Fix ScriptedMetricAggregatorTests

* Address review comments

Co-authored-by: Elastic Machine <[email protected]>
imotov added a commit to imotov/elasticsearch that referenced this issue Apr 30, 2020
Counts usage of the aggs and exposes them on the _nodes/usage/.

Closes elastic#53746
imotov added a commit that referenced this issue Apr 30, 2020
Counts usage of the aggs and exposes them on the _nodes/usage/.

Closes #53746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants