elasticsearchkibana-5timelion

Daily unique count, weekly unique count in the same Timelion chart


I want to visualize the unique count for a field aggregated daily and weekly per day in the same sheet. But timelion aggregation affects the entire sheet instead of just a single chart.

The expression I am using to get the daily unique count is

.es(metric='cardinality:userId').bars().title('Unique users over time')

If I change the bucket range on the right to 1d, I get the correct chart. How do I create the weekly aggregation?


Solution

  • There is a possibility to specify the interval used for timelion expressions by specifying interval as 1d or respectively 1w in the es() function. For details, please see the docs here.

    In your case this should work with the following expression:

    .es(metric='cardinality:userId',interval=1w).bars().title('Unique users per week')
    

    Be aware of the comment inside the docs, stating that this should not be used in favor of working with the interval picker. But probably this is a use case where it is okay to do it like this...