Display data as metric percentage of document count

Hi,
I want to display the increment between the counts of document in the same index with, of course, different period. So for example I want to calculate the increment between the total count of the last month and the previous month. Following this article I was able to get that working on a visualization with the filter ratio. I have two main problems. I have to put in the query string the fixed date, so every month or every period I have to manually change all that filter, which is not good. Is there any way to use the "now" variable and making operations with that, in the query string?
The other problem is to use this filter ratio (or something similar) in the canvas. I didn't find anything.
It seems that I was struggling too much with a so simple problem. A division between two counts of the same index. It seems I'm going in the wrong direction.
Do you have any suggestion? Thanks.

In the blog post you mentioned, I also wrote instructions on how to do month over month calculations. It sounds like you are interested in doing the same?

Thanks for your reply.
I tried to apply also the changes during time, but I get a wrong result.
I set the Data timerange mode to LAST VALUE, the time field on my date and the interval to 1d.
Then I did a count aggregation, applied a serial difference on the count metric with lag to 1 (I'm trying to find the increment/decrement between today and yesterday). At least I applied the bucket script as describe. I got the value of -4%, but the count of today is greater than the count of yesterday, so I expect a positive number. But even if I take the absolute value I got a wrong percentage.
In particular the diff seems to be wrong, so I think that the problem is somewhere in the serial difference. Any suggestions?
Is there any way to apply this also to the canvas?
Thanks.

From the post I read that setting the interval to 1d will get the value of today (vs 7 days ago, the lag).
If in the bucket script I output the total i get the count of the day before today. It seems strange.
Even in the time series I got as the last day yesterday.

There is an option to "drop the most recent bucket", which you probably have enabled.

Setting drop last bucket to "no" I got a really strange behaviour. If I print the total from the bucket script when I set an interval of 5 days I got more results than when I set an interval of 7 days, which is impossibile.
The 1d interval means the current day or the last 24 hours?

The main reason the last bucket is usually dropped is because it contains incomplete data: so 1d refers to an interval starting at midnight in the Kibana timezone. 24h would use an interval based on the time you make the request.

Well this makes sense. Buy why I get this strange behaviour incrementing the interval? I miss something?

I think I find out my problem simlpy executing the same aggregation directly to ealsticsearch and watching what happen. It seems all the data is correct, but I'll have to better analyze it in the next few days.
Thank for your suggestions.
Last thing: any to do this in canvas? Using elasticsearch SQL I'm not sure I can get the increment or using a post script. Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.