# How can I show average by 2 month from TSVB?

Hello , I am ELK rookie
I have a small question wanna ask here
How can I show average by 2 month from TSVB ?
Here is sample data like this :

``````  date                Execution Time                Job Name
20200102                 22                           Job 1
20200102                 33                           Job 2
20200202                 11                           Job 1
20200205                 45                           Job 3
20200210                100                           Job 5
20200311                 10                           Job 6
20200320                  1                           Job 9
20200417                 55                           Job 10
``````

I want to show :

In X axis show every day
and Y axis show average by 2 month like this :

20200102 ----> (22+33) / 2 (Different Job Count by every day : Job1 and 2)
Time range is from 20200102 to 20191102

2020202-----> (11 + 22 + 33) / 3 (Different Job Count by every day : Job1 ,2 and Job 1 from 0202 )
Time range is from 20200202 to 20191202

20200203 to 20200204 are no data , so is same as 20200202

20200205 -----> ( 45 + 11 + 22 + 33 ) / 4
Time range is from 20200205 to 20191205

20200210 -----> ( 100 + 45 + 11 + 22 + 33 ) / 5
Time range is from 20200210 to 20191210

20200311 -----> (10 + 100 + 45 + 11 ) / 3
Time range is from 20200311 to 20200111
....

It sounds like you want to use TSVB. Here's how I would set this up:

• Time interval is 1 month
• Time range is anything greater than 1 month, such as 6 months

For your series, I would define:

Sum of Execution time
Unique count of Job Name
Math:
params.sum / params.count

This should get you the math you were looking for, if I understood it.

I successful show on TSVB
I use Moving Average to fix time range problem, window size is 60 (2 month)
I can't find Unique count from TSVB , so I use count and add Filter from option
finally use Bucket Script sol the problem :
params.moving_sum / params.moving_count

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