Splunk Search

Getting the number of parallel intervals in timechart from start and end event

shacharz
Explorer

I have an event for a user that joins the system and an even for a user that leaves that system.
I want to create a timechart that will show how many users I had in my system along a time window.
This is for example how I timechart the join events:
sourcetype="tracker logs" join = join | timechart dc(peerId)
and similiarly for leave: sourcetype="tracker logs" join = leave | timechart dc(peerId)
But how do I substract those who leave from those who joined?

Tags (3)
0 Karma

somesoni2
Revered Legend

Try something like this

sourcetype="tracker logs" join="join" OR join="leave" | eval users=if(join="join",1,-1) | accum users| timechart max(users) 

shacharz
Explorer

Looks like this works:
sourcetype="tracker logs" join=join OR join=leave | eval users=if(match(join,"join"),1,-1) | accum users| timechart max(users)

0 Karma

shacharz
Explorer

Getting closer, I fixed your statement to:
sourcetype="tracker logs" join=join OR join=leave | eval users=if(join=="join",1,-1) | accum users| timechart max(users)

but looks like it doesn't match the join field to the value join
the values that the join field gets are either "join":true or "leave":true

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...