Splunk Search

ddl bind with rex

Jasmine
Path Finder

In the below query if c= I,  the reg expression is | rex field=attr.namespace "(?<DB>[^\.]*)"
if c= other than "I" then rex would be | rex field=attr.ns "(?<DB>[^\.]*)"

 

index="aaa" (source="/test/log/testing.log")  host IN(host1) c=N
          | rex field=attr.ns "(?<DB>[^\.]*)"
   	 | table  DB| dedup DB

 how can i adjust the query?

Labels (1)
0 Karma
1 Solution

tscroggins
Influencer

Hi @Jasmine,

You can assign the field value to a temporary field first, and then use the rex command to extract the value you want:

index="aaa" (source="/test/log/testing.log") host IN (host1) c=*
| eval DB=if(c=="I", 'attr.namespace', 'attr.ns')
| rex field=DB "(?<DB>[^\.]*)"
| table DB
| dedup DB

View solution in original post

tscroggins
Influencer

Hi @Jasmine,

You can assign the field value to a temporary field first, and then use the rex command to extract the value you want:

index="aaa" (source="/test/log/testing.log") host IN (host1) c=*
| eval DB=if(c=="I", 'attr.namespace', 'attr.ns')
| rex field=DB "(?<DB>[^\.]*)"
| table DB
| dedup DB
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...