<?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 Re: search with value from setup.xml in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71813#M17941</link>
    <description>&lt;P&gt;In the past, I have achieved this functionality using &lt;A href="http://www.splunk.com/base/Documentation/4.2/Admin/Macrosconf" rel="nofollow"&gt;macros&lt;/A&gt;. Just have your &lt;A href="http://www.splunk.com/base/Documentation/4.2/Developer/SetupExampleCustom" rel="nofollow"&gt;Python endpoint&lt;/A&gt; write out an entry in macros.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Add the definition
confMacro = {}
confMacro["definition"] = "10"

# Write out the conf file
self.writeConf("macros", "order_transaction_min_count", confMacro)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The resulting macros.conf should look something like (in local/macros.conf):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[order_transaction_min_count]
definition=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, update your searches to use the macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search eventtype="Orders" | transaction fields="OrderNumber" | search count&amp;lt;`order_transaction_min_count`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Make sure to include a default value for the macro under the default directory (default/macros.conf) so that you can avoid a warning if the user did not override it with their own value.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2011 22:36:30 GMT</pubDate>
    <dc:creator>LukeMurphey</dc:creator>
    <dc:date>2011-03-31T22:36:30Z</dc:date>
    <item>
      <title>search with value from setup.xml</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71812#M17940</link>
      <description>&lt;P&gt;I have a setup.xml and a myappsetup.conf all setup properly (lets make that assumption for now, still many bugs to iron out). From within myappsetup.conf, there is a field called &lt;STRONG&gt;order_transaction_min_count&lt;/STRONG&gt; and I want to use this field in my searches.&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search eventtype="Orders" | transaction fields="OrderNumber" | search count&amp;lt;order_transaction_min_count&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Is this correct? Or am I missing something here?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2011 17:07:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71812#M17940</guid>
      <dc:creator>klee310</dc:creator>
      <dc:date>2011-03-31T17:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: search with value from setup.xml</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71813#M17941</link>
      <description>&lt;P&gt;In the past, I have achieved this functionality using &lt;A href="http://www.splunk.com/base/Documentation/4.2/Admin/Macrosconf" rel="nofollow"&gt;macros&lt;/A&gt;. Just have your &lt;A href="http://www.splunk.com/base/Documentation/4.2/Developer/SetupExampleCustom" rel="nofollow"&gt;Python endpoint&lt;/A&gt; write out an entry in macros.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Add the definition
confMacro = {}
confMacro["definition"] = "10"

# Write out the conf file
self.writeConf("macros", "order_transaction_min_count", confMacro)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The resulting macros.conf should look something like (in local/macros.conf):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[order_transaction_min_count]
definition=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, update your searches to use the macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search eventtype="Orders" | transaction fields="OrderNumber" | search count&amp;lt;`order_transaction_min_count`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Make sure to include a default value for the macro under the default directory (default/macros.conf) so that you can avoid a warning if the user did not override it with their own value.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2011 22:36:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71813#M17941</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2011-03-31T22:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: search with value from setup.xml</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71814#M17942</link>
      <description>&lt;P&gt;thanks LukeMurphey &lt;/P&gt;

&lt;P&gt;Actually, I have gone with another route. Instead of using macros, I wrote a custom command which reads the the configuration dictionary with: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk.clilib.cli_common.getConfStanza("myappconfig", "setupentity")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and also reading the first argument to my command using: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sys.argv[1]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was able to extract the information i needed and perform the custom search within the script. so now, my final search command would look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search eventtype="Orders" | transaction fields="OrderNumber" | mycustomcommand order_transaction_min_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for your reply anyways.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2011 11:33:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-with-value-from-setup-xml/m-p/71814#M17942</guid>
      <dc:creator>klee310</dc:creator>
      <dc:date>2011-04-01T11:33:24Z</dc:date>
    </item>
  </channel>
</rss>

