I'm starting to develop a plugin that adds a feature in table vis: a comparable percentage of a metric value based on a time offset. The idea, basically, is show the difference between two time ranges (e.g.: today vs yesterday, today vs last week, etc). To clarify, this is what the table would look like:
In the example above, the second column is the sum of the
metric1 for a specific time range (e.g.: today) and the percentage is the difference based on a specific time offset (e.g.: yesterday). So, in the first row, today's value increased 23% from yesterday. Both time range and offset would be configured by form parameters (something similar to
date_range aggregation form).
About the plugin development itself: I started studying some examples from tutorials and source code, but I still have some questions:
- Firstly, should I develop a hack plugin or a new vis plugin?
- For the request, I'm considering "injecting" an
date_rangeaggregation in the query, but I couldn't find any example of this approach. What would be the best way to do this "injection"?
- For the response - considering that I'll use the
date_rangeaggregation - I wrote a basic
ResponseHandlerthat extracts the comparable metric value (yesterday), calculates the difference, inserts it in the original time range value line (today) and deletes the
date_rangeaggregation. Finally, I use the
aggResponse.tabifyto build a table response for the visualization. I was able test this solution adding the
date_rangeaggregation manually. Is this the best place to modify the response? Should I implement this in the
- In the visualization side, I simply added a "comparable" value in the table cell rendering function.
So, basically I'm thinking about injecting a
date_range aggregation in query and handle this in response, it shouldn't be visible to the user but it should be configured from custom form parameters. I'm currently changing the source code to test the solution above, but the idea is to turn it into a kibana plugin later.
Any ideas on how I could implement this functionality?