Getting Data In

Help with search query

avneet26
Engager

i have a list of string lets say  "abc" "bcd" "def" "efg" "fgh".

I want to search each of these string against a query for example :

"abc"

index=xyz sourcetype=logs host=localhost
| table _time,  _raw

and i want to search it as - if this string occurs in the result-set within last 10 days then it should print "present" otherwise it should print "absent"

Labels (1)
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

if you have only small number of strings which you are looking, then you can try this

index=xyz sourcetype=logs host=localhost earliest=-10d@d
| rex "(?<foo1>string1)"
..... ```Add all strings here one by one```
| rex "(?<fooN>stringN)"
| stats values(foo*) as foo*
| fillnull value=NULL foo1 ... fooN ```here you must named all variables```
| foreach foo* 
    [eval present_<<FIELD>> = if ('<<FIELD>>' == "NULL", "absent", "present")]
| table foo* present*

r. Ismo 

Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...