Splunk Search

paranthesis error in search query

secure
Path Finder

Hi,

Im trying to use an OR function in the below query trying to combine two indexes and then use stats function like an alternate for join command

(index=serverdata sourcetype="server:stats" | rex "app_code=\"(?<application_code>[|w.\"]*)" ) OR (index="hostapp" source=hostDB_Table dataasset="*host_Data*")

secure_0-1738790565197.png

i have tried to use escape characters but its still not working

thanks 

 

 

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @secure ,

as @PickleRick said, in the main search you cannot use a command as rex.

You have two choices:

move the rex after the main search:

(index=serverdata sourcetype="server:stats") OR (index="hostapp" source=hostDB_Table dataasset="*host_Data*")
| rex "app_code=\"(?<application_code>[|w.\"]*)"

or use append:

(index=serverdata sourcetype="server:stats" 
| rex "app_code=\"(?<application_code>[|w.\"]*)"
| append [ search index="hostapp" source=hostDB_Table dataasset="*host_Data*")]

This second solution runs only if you have, in the secondary search, less than 50,000 results, for this reason I orefer the first one.

In addition, there's a third solution that I prefer: if you create a fixed field extraction, using the regex, you don't need to insert it in the search and you can use only the main search:

(index=serverdata sourcetype="server:stats") OR (index="hostapp" source=hostDB_Table dataasset="*host_Data*")

Ciao.

Giuseppe

0 Karma

PickleRick
SplunkTrust
SplunkTrust

The 50k results limit for subsearch applies only to join! The default limit for a subsearch is 10k results.

PickleRick
SplunkTrust
SplunkTrust

It doesn't work like that. Parentheses group search conditions only. You can't spawn separate post-processing command for part of your data this way. You would need to use multisearch or append. But in your case it's probably not needed. Just do your rex command after the initial search.

Unrelated note - don't use wildcards at the beginning of your search term unless you really can't avoid it.

0 Karma

NevilleRadcliff
Loves-to-Learn

Thanks, I will keep it in mind.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @NevilleRadcliff ,

let us know if we can help you more, or, please, accept one answer for the other people of Community.

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...