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] FR: Scripted Fields / Scripted Aggregations #13928

Closed
hetzer-fastec opened this issue Sep 11, 2017 · 33 comments
Closed

[TSVB] FR: Scripted Fields / Scripted Aggregations #13928

hetzer-fastec opened this issue Sep 11, 2017 · 33 comments
Labels
Feature:TSVB TSVB (Time Series Visual Builder) release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@hetzer-fastec
Copy link

Feature Request
I am suggesting to include support for scripted aggregations (such as a scripted sum aggregation as described in the official documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html) and/or scripted fields in the time series visual builder. Currently only the bucket script aggregation seems to be implemented (see #4707).

Right now, one can neither select a scripted field as the target of an aggregation nor supply a custom script in combination with a special aggregation in the time series visual builder, which is a drastic limitation, in my opinion.

I have a use case where I need to compute several bucket script aggregations over simple aggregations, which themselves are scripted / work on scripted fields. For example: I need to compute a sum of the form sum(f(x)), where f(x) = x, if y = 0 and f(x) = 0 else (x, y are document fields). Unfortunately I am not in a situation to alter the type in order to include an according precomputed field.

There seems to be no way, I can visualize these computations right now in Kibana although I can generally compute them.

@alexfrancoeur alexfrancoeur added Feature:TSVB TSVB (Time Series Visual Builder) Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement labels Sep 11, 2017
@alexfrancoeur
Copy link

Thanks for filing @hetzer-fastec! I think the new Math aggregation we are working on #13681 will help with your use case. Would you mind reviewing the description to see if the functionality fully fits your use case. I believe it will.

cc: @simianhacker

@hetzer-fastec
Copy link
Author

Thanks for your quick answer, @alexfrancoeur! I already saw #13681, but as far as I can see that one does not really solve my use case, it only partially helps.

The main problem I am having is that I cannot create a scripted aggregation, e.g. a scripted sum aggregation in the TSVB.

For example, suppose we have a type car, which has a state "s", and two numeric values "a" and "b". Now we want to have a scripted sum aggregation, which basically selects "a" as a summand if the state has a certain feature and "b" as a summand it this is not the case. Let's call this sum "L". Let's now consider that our car type has two other numerical fields "c" and "d", which are summed as well based on some condition regarding the state. Let's call this sum "P".

Now at the end we want to compute the result of "L" / "P", which we can do by a bucket-script aggregation.

While I can theoretically create two sums in the TSVB using the sum aggregation, I cannot create them in the way I described it as the sum aggregation does not allow to define a script, which the summation is based on.

While I really like the idea of the math aggregation, it does not solve my problem, as far as I understood the issue. Please correct me if I am wrong - I am more than happy to learn that my issue is resolved with the help of the math aggregation :).

@hetzer-fastec
Copy link
Author

@alexfrancoeur Any news on this ? :)

@hetzer-fastec
Copy link
Author

At least another reply would be great!

@alexfrancoeur
Copy link

@hetzer-fastec apologies, somehow I missed your comments from earlier. Thank you for your patience. I agree and do not believe that Math.js may not be able to handle the state-like logic you are looking for. @simianhacker, this is a pretty interesting use case. Any idea's how @hetzer-fastec can accomplish this? If TSVB natively supported scripted fields would this be possible?

@simianhacker
Copy link
Member

At some point I'm going to integrate TSVB with Kibana Index Patterns (and scripted fields). There are no timelines (due to other forces of nature on my time :D)

@hetzer-fastec
Copy link
Author

@simianhacker @alexfrancoeur Thanks for the update! I guess, I have to wait until its implemented then :).

@timroes timroes added Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed Feature:Visualizations Generic visualization features (in case no more specific feature label is available) labels Sep 16, 2018
@ebalmeida
Copy link

+1

@jehutywong
Copy link

+1

3 similar comments
@Jerome2606
Copy link

+1

@inner-outer-space
Copy link

+1

@vinodradhakrishnaiyer
Copy link

+1

@ever4Kenny
Copy link

ever4Kenny commented Jul 10, 2019

vote for this issue

@akamzin
Copy link

akamzin commented Jul 12, 2019

+1 I believe this is a serious limitation. Other tools have it but do not have bucket script.

@Paul-de-Barbeyrac
Copy link

+1

7 similar comments
@cpiment
Copy link

cpiment commented Dec 19, 2019

+1

@linyaru
Copy link

linyaru commented Dec 22, 2019

+1

@ghost
Copy link

ghost commented Jan 3, 2020

+1

@mvsousa
Copy link

mvsousa commented Jan 24, 2020

+1

@iferreiro-ml
Copy link

+1

@sethyes
Copy link

sethyes commented Feb 27, 2020

+1

@ModestinoAndre
Copy link

+1

@amita-r
Copy link

amita-r commented Apr 10, 2020

+1
Any ETA on when the scripted fields would become available in TSVB?

@markwheal
Copy link

Scripted Fields support for TSVB would be a great new feature. +1

@sgrodzicki sgrodzicki added this to To do in [INACTIVE] Metrics / Red Team Backlog via automation May 26, 2020
@sgrodzicki sgrodzicki added this to the Metrics UI 7.9 milestone May 26, 2020
@rjso
Copy link

rjso commented Jun 3, 2020

+1

@simianhacker simianhacker self-assigned this Jun 3, 2020
@simianhacker
Copy link
Member

Quick update on this issue, we've added this to the Metrics UI roadmap for 7.9. The goal is to allow users to define scripted fields ad hoc since there isn't a hard requirement for Kibana Saved Index Patterns in TSVB. I'm still working out what the best way to do this is. My initial approach will be to allow users to define scripted fields under the panel options so they can use them throughout the TSVB UI (via basic aggs and percentiles).

@simianhacker
Copy link
Member

After playing around with this a bit today, instead of adding scripted fields under Panel Options I think a better approach will be to do something like this:

image

I've added a field named "Script" to all the field dropdowns, when this is selected it will display a text area for a script. Once you've entered a script, everything will just work like a normal field. The screen shot above is WIP and you should see a PR for this in the next couple of days.

@jasonrhodes jasonrhodes moved this from To do to In progress in [INACTIVE] Metrics / Red Team Backlog Jun 8, 2020
@sgrodzicki sgrodzicki removed this from the Metrics UI 7.9 milestone Jul 6, 2020
@sgrodzicki sgrodzicki moved this from In progress to Currently Blocked in [INACTIVE] Metrics / Red Team Backlog Jul 30, 2020
@sgrodzicki sgrodzicki removed this from Currently Blocked in [INACTIVE] Metrics / Red Team Backlog Jul 30, 2020
@ihdavids
Copy link

I like the ability to run arbitrary scripts AND it would be nice to have support for scripted fields.
IMHO the ability to run arbitrary scripts here is a very powerful timesaver when searching for a problem using your data.

@ihdavids
Copy link

ihdavids commented Oct 9, 2020

Any progress on this?

@Alsheh
Copy link

Alsheh commented Oct 15, 2020

@simianhacker thanks for working on the scripted field feature in TSVB! 7.9 is already out and I'm wondering if we should still continue to expect this to be released in some 7.x version?

@simianhacker
Copy link
Member

@Alsheh The PR was closed and this comment explains why:

#68332 (comment)

@ghost
Copy link

ghost commented Jan 12, 2021

+1

@rayafratkina
Copy link
Contributor

With #82438 TSVB can use runtime fields in Visualizations. I believe this closes this request.

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.