Splunk Search

How to calculate the total in a time range based on it own time stamp?

suntianze
New Member

alt text

I want a table that looks like this. Where the first column UserID is the identity. The second column is the earliest timestamp when the ID appears. The sum of the viewing time of the third column relative to the 3 days after the ID appeared. I don't know how to set the time range, because the time is three days after the earliest time stamp. And it is different for each ID.

Tags (1)
0 Karma

to4kawa
Ultra Champion
index=yours event_extra_userInfo_userId=* 
| bin _time span=1d
| stats earliest(timesatmp) as first_appear count as day_count by _time event_extra_userInfo_userId
| eventstats min(first_appear) as firstTime by event_extra_userInfo_userId
| eventstats sum(eval(if(_time <= relative_time(firstTime,"+3d@d") , day_count, NULL))) as total by event_extra_userInfo_userId

Where the first column UserID is the identity
There is not UserID in your sample pic.

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...