<?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: How to pre-process input to macro before searching in base search? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pre-process-input-to-macro-before-searching-in-base/m-p/518279#M87637</link>
    <description>&lt;P&gt;Hi&lt;BR /&gt;Maybe the easiest way is to use the input validation part of macro and require that your users enter a correctly formatted input to your macro?&lt;/P&gt;&lt;P&gt;Or did this help you&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Dashboards-Visualizations/What-s-the-Token-name-for-the-Time-Picker-s-display-value-if-any/td-p/290080" target="_blank"&gt;https://community.splunk.com/t5/Dashboards-Visualizations/What-s-the-Token-name-for-the-Time-Picker-s-display-value-if-any/td-p/290080&lt;/A&gt;&lt;BR /&gt;R. Ismo&lt;/P&gt;</description>
    <pubDate>Mon, 07 Sep 2020 17:45:18 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2020-09-07T17:45:18Z</dc:date>
    <item>
      <title>How to pre-process input to macro before searching in base search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pre-process-input-to-macro-before-searching-in-base/m-p/515724#M87325</link>
      <description>&lt;P&gt;We have a wonderful set of end-users who can enter dates in various formats.&lt;/P&gt;&lt;P&gt;Data sample is like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;reportName="finance" team="financeTeam" reportDate="2020-08-20"
reportName="finance" team="financeTeam" reportDate="2020-08-22"
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro wanted to return the dataset for a specific date and expectation was user to enter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`getmyReport(2020-08-22)`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but some users, enter it as `getmyReport(today)` and my challenge is to ensure such weird inputs are tackled before it hits the search engine and to do directly in the raw data&lt;/P&gt;&lt;P&gt;So is there a way, i can do a pre-processing of my inputs before I pass it to the raw search?&lt;/P&gt;&lt;P&gt;the basic trial i've done is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults
| eval reportDate=if(reportDate="2020*",reportDate,strftime(now(),"%F")
| search (earliest=-7d index=xyz reportDate=$reportDate$)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the above doesn't work.&lt;/P&gt;&lt;P&gt;The SECOND option I've within the macro outside the base search&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xyz
| eval reportDate=if(reportDate="2020*",reportDate,strvtime(now(),"%F")
| search (reportDate=$reportDate$)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This SECOND option works, But somehow I feel the second option is performance wise poor (or will Splunk automatically optimise for Splunk 6.5x onwards?)&lt;/P&gt;&lt;P&gt;Is there a better option to pre-process macro variables before searching within _raw dataset?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 08:56:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pre-process-input-to-macro-before-searching-in-base/m-p/515724#M87325</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2020-08-24T08:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to pre-process input to macro before searching in base search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pre-process-input-to-macro-before-searching-in-base/m-p/518279#M87637</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;Maybe the easiest way is to use the input validation part of macro and require that your users enter a correctly formatted input to your macro?&lt;/P&gt;&lt;P&gt;Or did this help you&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Dashboards-Visualizations/What-s-the-Token-name-for-the-Time-Picker-s-display-value-if-any/td-p/290080" target="_blank"&gt;https://community.splunk.com/t5/Dashboards-Visualizations/What-s-the-Token-name-for-the-Time-Picker-s-display-value-if-any/td-p/290080&lt;/A&gt;&lt;BR /&gt;R. Ismo&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 17:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pre-process-input-to-macro-before-searching-in-base/m-p/518279#M87637</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-09-07T17:45:18Z</dc:date>
    </item>
  </channel>
</rss>

