Splunk Search

how can i match 2 conditions while setting token

nsmouli
New Member

Hi -

I have 2 drop-downs: Year lists down all the years, Month list down all the months. Now i would need to pass the span value as token to timechart command based on those year and month drop-down values.
like:
if Year=All & Month=All then span should be 1year
if Year=value(e.g 2016) & Month=All then span should be 1mon
if Year=value(e.g 2016) & Month=value(e.g Dec) then span should be 1d

I have tried with condition match but 2 conditions are not working here. Any suggestions how to achieve this please?

Thanks in advance!

0 Karma
1 Solution

niketn
Legend

Option 1
You can use eval tag to use case expression and set a token

<eval token="selTime">case($selYear$=="All" AND $selMonth$=="All","1y",$selYear$!="All" AND $selMonth$=="All","1mon",1==1,"1d")</eval>

Option 2
You can define lookup to map various Year Month combination to select span

Year,Month,Span
All,All,1y
2017,All,1mon
2016,All,1mon
2015,All,1mon

Anything that does not match Month=All can be defaulted as span=1d in your search.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

Option 1
You can use eval tag to use case expression and set a token

<eval token="selTime">case($selYear$=="All" AND $selMonth$=="All","1y",$selYear$!="All" AND $selMonth$=="All","1mon",1==1,"1d")</eval>

Option 2
You can define lookup to map various Year Month combination to select span

Year,Month,Span
All,All,1y
2017,All,1mon
2016,All,1mon
2015,All,1mon

Anything that does not match Month=All can be defaulted as span=1d in your search.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

nsmouli
New Member

yes I already got this Option 1. Thanks for your reply and support.

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...