Splunk Search

How to find sum of particular fields by time?

pal_sumit1
Path Finder

We are having search which contain two fields user id and time at which user logged in.

We need to print below table

Time--------------|--------total user (no. of user logged in that hour)
00:00--1:00 am|---30
01:00--2:00 am|---40
etc..
we have to print top 10 values for current day only.
IF we are running search today it should show only today data.
and if we are running search tomorrow that it should show only tomorrow data

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try (assuming your logged in time is identified your _time of the event)

Your search which contain two fields user id and time
| timechart span=1h dc(userId) as "Total Users"
| eval Time=strftime(_time,"%H:%M")."--".strftime(_time+3600,"%H:%M")
| table Time "Total Users"

View solution in original post

somesoni2
Revered Legend

Give this a try (assuming your logged in time is identified your _time of the event)

Your search which contain two fields user id and time
| timechart span=1h dc(userId) as "Total Users"
| eval Time=strftime(_time,"%H:%M")."--".strftime(_time+3600,"%H:%M")
| table Time "Total Users"

kmaron
Motivator
(search for logins) 
| bucket _time span=1h
| stats count by _time
| sort - count limit=10

If you separate them into 1 hour buckets it will get you the per hour count then take the top 10 values.
You can either set the time picker to "today" or set earliest=@d to start at the beginning of today

David_Naylor
Path Finder

Hello,

The following should get you what your looking for

Basesearch | timechart DC(userid) span=1h

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 ...