Splunk Search

Populate drop down with eval values

subhrangshu
Explorer

Hello,

Is it possible to populate drop down in Dashboard with eval values. I have a query as given below which returns me a string.

index=test sourcetype="testabc"
| rename sre_job_id as JOB_ID
| stats earliest(_time) AS Earliest by JOB_ID
| eval FirstEvent=strftime(Earliest,"%b %d, %Y %H:%M:%S")
| eval JOB_ID_STR=tostring(JOB_ID)
| eval JOB-ID-WITH-TIME=JOB_ID + "-" + FirstEvent
| table JOB-ID-WITH-TIME
| dedup JOB-ID-WITH-TIME
| sort JOB-ID-WITH-TIME

When I run this search with time as "Last 7 days", I get 3 records back.

7220-Aug 13, 2020 11:22:00
7320-Aug 13, 2020 11:46:32
7800-Aug 14, 2020 04:50:06

 

But when I use the same query in my drop-down in dashboard, I do not see any data. Below is the xml for the same:

<input type="dropdown" token="jobIDII" searchWhenChanged="true">
<label>JOB ID II</label>
<fieldForLabel>sre_job_id</fieldForLabel>
<fieldForValue>sre_job_id</fieldForValue>
<search>
<query>index=test sourcetype="testabc"
| rename sre_job_id as JOB_ID
| stats earliest(_time) AS Earliest by JOB_ID
| eval FirstEvent=strftime(Earliest,"%b %d, %Y %H:%M:%S")
| eval JOB_ID_STR=tostring(JOB_ID)
| eval JOB-ID-WITH-TIME=JOB_ID + "-" + FirstEvent
| table JOB-ID-WITH-TIME
| dedup JOB-ID-WITH-TIME
| sort JOB-ID-WITH-TIME</query>
<earliest>$timeToken.earliest$</earliest>
<latest>$timeToken.latest$</latest>
</search>
</input>

NOTE: timeToken is the token for DURATION.

I also have a time input to filter the data for the above query in my dashboard. Please see the picture below:

screenshotscreenshot

If you see above, JOB ID II is not populating any data and I cannot select anything from here.

Thanks for your time in advance.

 

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

Nisha18789
Builder

Hello @subhrangshu,

the problem is with below part:

<fieldForLabel>sre_job_id</fieldForLabel>
<fieldForValue>sre_job_id</fieldForValue>

Please change that to :

<fieldForLabel>JOB-ID-WITH-TIME</fieldForLabel>
<fieldForValue>JOB-ID-WITH-TIME</fieldForValue>

Hope this helps!

Please upvote my solution if it resolves the issue.

View solution in original post

Nisha18789
Builder

Hello @subhrangshu,

the problem is with below part:

<fieldForLabel>sre_job_id</fieldForLabel>
<fieldForValue>sre_job_id</fieldForValue>

Please change that to :

<fieldForLabel>JOB-ID-WITH-TIME</fieldForLabel>
<fieldForValue>JOB-ID-WITH-TIME</fieldForValue>

Hope this helps!

Please upvote my solution if it resolves the issue.

subhrangshu
Explorer

Thanks a lot @Nisha18789 😊

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

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 ...