Knowledge Management

How to parametrize my search?

sramya1234
New Member

Hi,
Can we parametrize the splunk queries?

Here is the query and i want to parameterize the "-7".

index=xyz sourcetype=n1 earliest=-7d@d "abc p=save" " xm=POST"  |
  rex field=msg " tt=(?[0-9]+)" | 
  fields id, time |
  stats count (id) as COUNT
        perc50(time) as a
        perc90(time) as k
0 Karma

gokadroid
Motivator

Yes we can by using the time picker and use its value in the query if this is in a dashboard or report.

Please see here for similar question
https://answers.splunk.com/answers/139043/can-we-add-a-time-range-picker-that-interacts-dynamically-...

Please see here docs on how to add a time picker to dashboard
http://docs.splunk.com/Documentation/Splunk/6.5.1/Viz/FormEditor#Add_a_time_input_to_a_form

For report, while saving the report, add a time picker option can be selected.

0 Karma

sramya1234
New Member

Ok…let me be more specific…
I have created a report and calling this report by ODBC connection like

Select * from splunk_report1.

This report runs the above mentioned query and i want to pass the value for the "earliest" so i can change last 7 days to last 1 day if required.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...