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
Get Updates on the Splunk Community!

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...

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