Splunk Search

help on eval command

jip31
Motivator

Hi
I dont know why my eval command doesnt return any resulys

 `index` 
| lookup tutu.csv HOSTNAME as host output SITE 
| stats values(SITE) as Site, values(index) AS index  BY host 
| eval check=if(index="ai-toto*" ,"toto index only","All indexes") 
| search check="toto index only" 
| table host 

If I delete the eval comamnd I have results
I have done a workaround like this:

| stats values(SITE) as Site, dc(index) AS index BY host 
| where NOT index==4

It works but I would like to know why my original search doesnt works

Tags (1)
0 Karma
1 Solution

to4kawa
Ultra Champion
  `index` 
 | lookup tutu.csv HOSTNAME as host output SITE 
 | stats values(SITE) as Site, values(index) AS index  BY host 
 | eval check=if(index="ai-toto*" ,"toto index only","All indexes") 
 | search check="toto index only" 
 | table host 

this query's index is multivalue.
so | eval check=if(index="ai-toto*" ,"toto index only","All indexes") is not work.

View solution in original post

0 Karma

to4kawa
Ultra Champion
  `index` 
 | lookup tutu.csv HOSTNAME as host output SITE 
 | stats values(SITE) as Site, values(index) AS index  BY host 
 | eval check=if(index="ai-toto*" ,"toto index only","All indexes") 
 | search check="toto index only" 
 | table host 

this query's index is multivalue.
so | eval check=if(index="ai-toto*" ,"toto index only","All indexes") is not work.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

try this:

`index` | lookup tutu.csv HOSTNAME as host output SITE | stats values(SITE) as Site, values(index) AS index BY host | mvexpand index | eval check=if(match(index,"ai-toto*") ,"toto index only","All indexes") | search check="toto index only" | dedup host | table host
0 Karma

jip31
Motivator

thanks its ok

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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