Splunk Search

Search String but retain values

tb5821
Communicator

new to splunk so go easy on me

I can currently run two different searches and get the the results I'm looking for but the problem is that its two different searches 🙂

The only field which they have in common is task_id how can I run both of these searches together still get the lines with the strings I'm interested in? Also within each search I'm renaming some of my fields ie ... | rename tt AS "Encode Time" and my other search is ... | rename tt AS "Copy Time"

Tags (1)
0 Karma
1 Solution

Damien_Dallimor
Ultra Champion

Try the transaction search command to stitch events together based on the common field :

... | transaction task_id

Not sure about the field renaming without seeing more concise examples of the events.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

try this:

(sourcetype=A "encode") OR (sourcetype=B copying) | eval encode_time=if(searchmatch("encode"),tt,null()) | eval copy_time=if(searchmatch("copying"),tt,null())

Also, depending what you're doing the ... | stats ... by task_id command may be better than transaction task_id

0 Karma

tb582
Explorer

does it matter that my source types are both the same?

0 Karma

Damien_Dallimor
Ultra Champion

Try the transaction search command to stitch events together based on the common field :

... | transaction task_id

Not sure about the field renaming without seeing more concise examples of the events.

Damien_Dallimor
Ultra Champion

You can setup Splunk "event types" for your different tasks.

http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Abouteventtypes

0 Karma

tb582
Explorer

Unfortuantly I don't think its that easy I've tried all sorts of things join, set, append but just either not doing it in the right order or not doing it right at all. Here's an example of the two queries.

index=myindex sourcetype=app host=1* OR host=050 "SUCCESS : 100% : Encode completed" | rename Task_time as "Encode Time"

search index=myindex sourcetype=app host=1* OR host=050 "SUCCESS : 100% : Push Completed" | rename Task_time as "Transfer Time"

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...