Requirement : Objective is to include a script which can be equivalent to SQL function COUNT (CASE WHEN X == ‘1’ THEN 1 ELSE NULL), SUM (CASE WHEN Y == ‘A’ THEN 1 ELSE 0). Precisely known as Conditional Aggregation where each metric can have its own filter
(Example - https://stackoverflow.com/questions/29020065/sql-count-if-columns).
While visualizing, the Advanced option which takes JSON format input is really useful which allows us to dynamically manipulate the data unlike scripted fields. But, an extension of the same would be much more beneficial to use.
Working of Advanced JSON script explained:
When we pass a JSON script to Advanced, this gets reflected in the Request made by Kibana. The default template for the Kibana Visualization Request includes the following modules:
While checking the Request script on Inspect , the JSON script available under Advanced in the Metric allows to add a custom value for the “aggs”. The below is an example.
Other modules are not bound to this script. It would be very useful to have the possibility of manipulating those modules.
Can anyone confirm the possibility of such computation and if yes, the method to do it. If it is not possible, is it possible to include this in future.
Suggestion: It could be possible if we could replicate the template with all 7 modules for each Metric. The shortcoming could be that it might take away the advantage of fetching all the aggregation results in one request and it is the trade off between customization and performance. May be, there exists a way still to send the customized request at once.
Thanks for your time!
PS: I have checked a few topics related to this where everything concluded that it is not possible. Yet, I am asking this as those were closed for discussion. This is related to my another topic Binding Controls