Splunk Enterprise

Help on eval strange behaviour

jip31
Motivator

hello

I have a strange behavior with an eval command

if I am doing this it works well

 

 

| eval site=case(site=="0", "AA", site=="BR", "BB", site=="PER", "CC", 1==1,site) 
| eval s=lower(s)  
|search site="$site$"

 

 

 but if I put | search site="$site$" just after the eval, the search command is not recognized as a splunk command!

 

 

| eval site=case(site=="0", "AA", site=="BR", "BB", site=="PER", "CC", 1==1,site)   
|search site="$site$"

 

 

 what is wrong please?

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

jip31
Motivator

I found the solution by parsing each pipe section on a separate line.

View solution in original post

Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jip31 

It would be better if you can share your sample XML. It will help us to understand the token and the filtration.

Meanwhile, you can try the below XML I've tried to replicate the issue with fix.

<form version="1.1">
  <label>Site Filter</label>
  <fieldset submitButton="false">
    <input type="text" token="site">
      <label>Site</label>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults 
| eval site="0|BR|PER|KAMLESH", site=split(site,"|") 
| mvexpand site 
| eval site=case(site=="0", "AA", site=="BR", "BB", site=="PER", "CC", 1==1,site)
| eval siteFilter="$site$"
| search (siteFilter="" OR site="$site$") | table site
</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">50</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>

 

I hope this will help you.

 

Thanks
KV
If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma

jip31
Motivator

I found the solution by parsing each pipe section on a separate line.

Tags (1)
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...