<?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 loop through times for same search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695380#M236461</link>
    <description>&lt;P&gt;It looks like you may be going about this the wrong way. Please explain in non-Splunk terms what it is you are trying to achieve.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2024 07:20:19 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-08-06T07:20:19Z</dc:date>
    <item>
      <title>How to loop through times for same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695378#M236459</link>
      <description>&lt;P&gt;Hi Splunk Experts,&lt;BR /&gt;I'm not sure how easy it's using Splunk,&amp;nbsp;I've a field (_time) with list of epoch_time values in it. I want to loop through each value and run a search using the time value in below query by replacing $_time$. Any advice would be much appreciated, Thanks in advance!!&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;_time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722888000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722888600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722889200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722889800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722890400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="24px"&gt;1722891000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main earliest=$_time$-3600 latest=$_time$ user arrival
| timechart span=10m count by user limit=15
| untable _time user value
| join type=left user
[| inputlookup UserDetails.csv
| eval DateStart=strftime(relative_time($_time$), "-7d@d"), "%Y-%m-%d")
| where Date &amp;gt; DateStart]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 07:07:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695378#M236459</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2024-08-06T07:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through times for same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695380#M236461</link>
      <description>&lt;P&gt;It looks like you may be going about this the wrong way. Please explain in non-Splunk terms what it is you are trying to achieve.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 07:20:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695380#M236461</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-08-06T07:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through times for same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695381#M236462</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253572"&gt;@Thulasinathan_M&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you cannot use a calculation (earliest=$_time$-3600) in a search, but you can put the values to use for your search in a lookup, with the only attention point to use the same fields, something like this:&lt;/P&gt;&lt;P&gt;in the lookup you should put two fields: earliest and latest and the run a search like the following&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main [| inputlookup my_time_periods.csv | fields earliest latest ] user arrival
| timechart span=10m count by user limit=15
| untable _time user value
| join type=left user
[| inputlookup UserDetails.csv
| eval DateStart=strftime(relative_time(_time), "-7d@d"), "%Y-%m-%d")
| where Date &amp;gt; DateStart&lt;/LI-CODE&gt;&lt;P&gt;two addition infos:&lt;/P&gt;&lt;P&gt;don't use index=main, but use your own index.&lt;/P&gt;&lt;P&gt;don't user join for an inputlookup: the lookup command is a left join and in general use the join command only when you haven't any other solution because Splunk isn't a database and it's a very slow command!&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index [| inputlookup my_time_periods.csv | fields earliest latest ] user arrival
| timechart span=10m count by user limit=15
| untable _time user value
| lookup UserDetails.csv user
| eval DateStart=strftime(relative_time(_time), "-7d@d"), "%Y-%m-%d")
| where Date &amp;gt; DateStart&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 07:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-times-for-same-search/m-p/695381#M236462</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-08-06T07:21:25Z</dc:date>
    </item>
  </channel>
</rss>

