<?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: Use parametric time variable in source name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565080#M196853</link>
    <description>&lt;P&gt;Rather than setting the lookup name in an eval, use a subsearch.&amp;nbsp; Try this query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| set diff 
    [ | search index=myindex [ | makeresults 
        | eval source=strftime(now(),"*%Y-%m-%d*.csv") | return source ]
    | stats count by idx 
    | table idx] 
    [ search index=myindex source="*2021-08-25*.csv" 
    | stats count by idx 
    | table idx] 
| join idx 
    [ search index=myindex [ | makeresults 
        | eval source=strftime(now(),"*%Y-%m-%d*.csv") | return source ] ] 
| table "SITE ID",idx,"Title",FQDN,"Asset Primary Identifier","IP Address",Hostname,"Operating System", Port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Aug 2021 16:49:43 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-08-27T16:49:43Z</dc:date>
    <item>
      <title>Use parametric time variable in source name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565070#M196847</link>
      <description>&lt;P&gt;Hello to everybody,&lt;/P&gt;&lt;P&gt;we are trying to set a search that makes a diff between two files of two different days. This is the working search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| set diff
[| search index=myindex source="*2021-08-27*.csv"
| stats count by idx
| table idx]
[ search index=myindex source="*2021-08-26*.csv"
| stats count by idx
| table idx]
| join idx
[ search index=myindex source="*2021-08-27*.csv"]
| table "SITE ID",idx,"Title",FQDN,"Asset Primary Identifier","IP Address",Hostname,"Operating System", Port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, we'd like to make it parametric, we'd like dates contained in source names are calculated automatically, so we tried to insert this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| set diff 
    [ | eval todayFile=strftime(now(),"*%Y-%m-%d*.csv")
    | search index=myindex source=todayFile
    | stats count by idx 
    | table idx] 
    [ search index=myindex source="*2021-08-25*.csv" 
    | stats count by idx 
    | table idx] 
| join idx 
    [ search index=myindex source=todayFile] 
| table "SITE ID",idx,"Title",FQDN,"Asset Primary Identifier","IP Address",Hostname,"Operating System", Port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it's not working, or, better, it doesn't return errors but it doesn't return correct results either.&lt;/P&gt;&lt;P&gt;How can we substitute&amp;nbsp;source="*2021-08-25*.csv" with an instruction that dynamically inserts today date in our source filename in order to run the search every day?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 14:05:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565070#M196847</guid>
      <dc:creator>nicofantinato</dc:creator>
      <dc:date>2021-08-27T14:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Use parametric time variable in source name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565080#M196853</link>
      <description>&lt;P&gt;Rather than setting the lookup name in an eval, use a subsearch.&amp;nbsp; Try this query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| set diff 
    [ | search index=myindex [ | makeresults 
        | eval source=strftime(now(),"*%Y-%m-%d*.csv") | return source ]
    | stats count by idx 
    | table idx] 
    [ search index=myindex source="*2021-08-25*.csv" 
    | stats count by idx 
    | table idx] 
| join idx 
    [ search index=myindex [ | makeresults 
        | eval source=strftime(now(),"*%Y-%m-%d*.csv") | return source ] ] 
| table "SITE ID",idx,"Title",FQDN,"Asset Primary Identifier","IP Address",Hostname,"Operating System", Port&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 16:49:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565080#M196853</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-08-27T16:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Use parametric time variable in source name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565277#M196942</link>
      <description>&lt;P&gt;It works!&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 06:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-parametric-time-variable-in-source-name/m-p/565277#M196942</guid>
      <dc:creator>nicofantinato</dc:creator>
      <dc:date>2021-08-31T06:36:12Z</dc:date>
    </item>
  </channel>
</rss>

