<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How To Pass Parameters to Saved Search Using Splunklib in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-To-Pass-Parameters-to-Saved-Search-Using-Splunklib/m-p/557080#M158207</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Does anyone know how to pass parameters to a saved search using the splunklib for the Splunk API?&lt;/P&gt;&lt;P&gt;I am able to use it to get results from my saved searches, but now I would like to be able to pass a variable value to my saved search. I've seen a few examples of people using the "curl" approach, but I wanted to see if there was a way to do this by directly using the splunklib for Python.&lt;/P&gt;&lt;P&gt;This is the snippet of code where I retrieve my saved search and then run it.&lt;/P&gt;&lt;PRE&gt;number_of_users = 10&lt;BR /&gt;search_name = "Find Most Recent Users"&lt;BR /&gt;mysavedsearch = service.saved_searches[search_name]&lt;BR /&gt;job = mysavedsearch.dispatch()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I have a saved search named: Find Most Recent Users&lt;/P&gt;&lt;P&gt;And that search looks like:&amp;nbsp; "index=INDEX host=HOST sourcetype=SOURCETYPE | rex field=_raw "User:(?&amp;lt;user_id&amp;gt;\d+) | where isnotnull(user_id) | head $number_of_users$"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I pass the variable "number_of_users" into the above?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 21:25:08 GMT</pubDate>
    <dc:creator>Traer001</dc:creator>
    <dc:date>2021-06-24T21:25:08Z</dc:date>
    <item>
      <title>How To Pass Parameters to Saved Search Using Splunklib</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Pass-Parameters-to-Saved-Search-Using-Splunklib/m-p/557080#M158207</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Does anyone know how to pass parameters to a saved search using the splunklib for the Splunk API?&lt;/P&gt;&lt;P&gt;I am able to use it to get results from my saved searches, but now I would like to be able to pass a variable value to my saved search. I've seen a few examples of people using the "curl" approach, but I wanted to see if there was a way to do this by directly using the splunklib for Python.&lt;/P&gt;&lt;P&gt;This is the snippet of code where I retrieve my saved search and then run it.&lt;/P&gt;&lt;PRE&gt;number_of_users = 10&lt;BR /&gt;search_name = "Find Most Recent Users"&lt;BR /&gt;mysavedsearch = service.saved_searches[search_name]&lt;BR /&gt;job = mysavedsearch.dispatch()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I have a saved search named: Find Most Recent Users&lt;/P&gt;&lt;P&gt;And that search looks like:&amp;nbsp; "index=INDEX host=HOST sourcetype=SOURCETYPE | rex field=_raw "User:(?&amp;lt;user_id&amp;gt;\d+) | where isnotnull(user_id) | head $number_of_users$"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I pass the variable "number_of_users" into the above?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 21:25:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Pass-Parameters-to-Saved-Search-Using-Splunklib/m-p/557080#M158207</guid>
      <dc:creator>Traer001</dc:creator>
      <dc:date>2021-06-24T21:25:08Z</dc:date>
    </item>
  </channel>
</rss>

