Splunk Search

Combining Fields from Two Different Seaches

jason_hotchkiss
Communicator

I have two searches:

Search A
index=my_idx sourcetype=my_st Name=conference Message= joined
| stats count by _time Paticipant Conference Display Name Location Protocol

Search B
index=my_idx sourcetype=my_st Name=conference Message= disconnected
| stats count by _time Participant Conference Duration  DisplayName Location Protocol

I would like create a table that combines the Duration field with all the fields from Search A.  I would then like to include a column for the join time and the disconnect time that correlates to the value of Duration.

The output would look like this:

Seach C Out Come

Participant Conference Join_Time Disconnect_Time Duration DisplayName Location Protocol

Thank you,
Jason H.

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index=my_idx sourcetype=my_st Name=conference (Message=joined OR Message=disconnected)
| eval joined_time=if(Message="joined",_time,null())
| eval disconnected_time=if(Message="disconnected",_time,null())
| stats values(Duration) as Duration values(joined_time) as joined_time values(disconnected_time) as disconnected_time by Participant Conference  DisplayName Location Protocol

View solution in original post

Tags (1)

ITWhisperer
SplunkTrust
SplunkTrust
index=my_idx sourcetype=my_st Name=conference (Message=joined OR Message=disconnected)
| eval joined_time=if(Message="joined",_time,null())
| eval disconnected_time=if(Message="disconnected",_time,null())
| stats values(Duration) as Duration values(joined_time) as joined_time values(disconnected_time) as disconnected_time by Participant Conference  DisplayName Location Protocol
Tags (1)

jason_hotchkiss
Communicator

@ITWhisperer This is great, thank you!

The Duration field display the duration as a value such as 3402.578  I believe this is to be in seconds and miliseconds.  How would I change this to hh:mm:ss?

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

| eval Duration=tostring(Duration,"duration")
Tags (1)

jason_hotchkiss
Communicator

@ITWhisperer 

I did try this: | eval Duration = strptime(Duration, "%H:%M:%S")
But the out come is like 19:00:10, which doesn't seem possible me.

But your solution did the trick.  I didn't know you could use tostring like that.  

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...