Splunk Search

Is there a way to edit the output given by sub search?

Callum_f
Explorer

I have a sub query that gives the output example below 

Sub Query

 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") 
| fields error.requestId 
| rename error.requestId as requestId 
| dedup requestId 
| format ]

Output

( requestId="jjadjdfjjedd_jehdfjdjfhj" ) OR ( requestId="jgjfnfdn_jrhfjdbfd" )....

I need to edit the format that is returned from the first query. 

 

Is there a way to change the search to something less specific? Such as

(*jjadjdfjjedd_jehdfjdjfhj*) OR (*jgjfnfdn_jrhfjdbfd*) .....

As I need to find all events that include the requestId, not just when it is specific to that variable.

Labels (2)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try like this

 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") 
| fields error.requestId 
| rename error.requestId as query
| dedup query
| format ]

The query field is treated differently

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try like this

 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") 
| fields error.requestId 
| rename error.requestId as query
| dedup query
| format ]

The query field is treated differently

Callum_f
Explorer


@ITWhisperer It works thank you very much 🙂

I need to search over the last 30 days but it seems to crash with a time of over 24 hours. Is there a way to break the search up so it can run as the sub search is giving a large number of values that are then searched on. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could try this

 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") earliest=-1d@d latest=@d
| fields error.requestId 
| rename error.requestId as query
| dedup query
| format ] OR
 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") earliest=-2d@d latest=-1d@d
| fields error.requestId 
| rename error.requestId as query
| dedup query
| format ] OR
 [ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") earliest=-3d@d latest=-2d@d
| fields error.requestId 
| rename error.requestId as query
| dedup query
| format ]
etc.

Or perhaps you need to approach it a different way to eliminate the subsearch or make your 30 day search the main search and your other search the subsearch

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...