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!

Your Feedback. Our Roadmap. Visit the PX Feedback Booth at .conf26

You use Splunk every day, come and help shape what's next.  Save Your Seat: Product-Focused Sessions at ...

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

Watch Now Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas     Do you ever feel ...