Splunk Search

Use TimePicker to average on a specific field

pwilly
Explorer

I have a dashboard with several inputs to include a timepicker, one of my panels charts the sums of specific fields over the time picked. I would like to add another column that acts upon one of those sums and get the avg per minute.

For example time picked is 4 hours
Column 1 = 480

The new column would then need to take that result and divide it by the number of minutes specified in the time picker
480/240minutes = 2 per minute

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this. The eval on 2nd last line will add a field called Minutes, containing number of minutes in the selected timerange. You can use that for your 'per min' calculation.

index=Foo MGR_NAME=$Manager$ NAME=$Name$ AND $Params$ | eval TotalThroughput=(MSG_1_COUNT)+(MSG_2_COUNT)| chart sum(MSG_1_COUNT) AS In sum(MSG_2_COUNT) AS Out max(HIGH_MSG_DEPTH) as HighMSGDepth sum(TotalThroughput) AS TotalThroughput by NAME | eval NAME=substr(NAME,1,48) | sort - TotalThroughput 
| eval Minutes=[| gentimes start=-1 | addinfo | eval search=round((info_max_time-info_min_time)/60) | table search] 
| eval MSG_1_COUNT_PerMin=MSG_1_COUNT/Minutes | fields - Minutes

View solution in original post

DalJeanis
Legend

It's going to look something like

| eval PerMinute = 60*MSG_1_COUNT / ($timerange.latest$ - $timerange.earliest$)

somesoni2
Revered Legend

Try this. The eval on 2nd last line will add a field called Minutes, containing number of minutes in the selected timerange. You can use that for your 'per min' calculation.

index=Foo MGR_NAME=$Manager$ NAME=$Name$ AND $Params$ | eval TotalThroughput=(MSG_1_COUNT)+(MSG_2_COUNT)| chart sum(MSG_1_COUNT) AS In sum(MSG_2_COUNT) AS Out max(HIGH_MSG_DEPTH) as HighMSGDepth sum(TotalThroughput) AS TotalThroughput by NAME | eval NAME=substr(NAME,1,48) | sort - TotalThroughput 
| eval Minutes=[| gentimes start=-1 | addinfo | eval search=round((info_max_time-info_min_time)/60) | table search] 
| eval MSG_1_COUNT_PerMin=MSG_1_COUNT/Minutes | fields - Minutes

DalJeanis
Legend

cute. I hadn't thought of using addinfo instead of pulling it off the interface.

0 Karma

rjthibod
Champion

The community can best help you if you share part or whole of your search query. That way we can more efficiently help by targeting the specific fields and commands you are using.

pwilly
Explorer

My search looks like the following
index=Foo MGR_NAME=$Manager$ NAME=$Name$ AND $Params$ | eval TotalThroughput=(MSG_1_COUNT)+(MSG_2_COUNT)| chart sum(MSG_1_COUNT) AS In sum(MSG_2_COUNT) AS Out max(HIGH_MSG_DEPTH) as HighMSGDepth sum(TotalThroughput) AS TotalThroughput by NAME | eval NAME=substr(NAME,1,48) | sort - TotalThroughput

I would like an additional column that per NAME looks at the sum of MSG_1_COUNT for that NAME and divides it by the number of minutes that will be specified in the timepicker input so I can get average MSG_1_COUNT per Minute
Thanks

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...