<?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 alternate field for time and filtering in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595690#M207320</link>
    <description>&lt;P&gt;The data that is ingested will always get allocated a _time field based on your config for that input - that totally defines what events you get back based on your earliest/latest time range.&lt;/P&gt;&lt;P&gt;I didn't quite understand your goal&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Generate a query for all events of the past 3 weeks where there are CMDB events that have a field "created_date" spanning multiple months, I only want those events that have a created_date that falls with the the 3 week period.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is really about understanding what an 'event' ingested into Splunk will have as its _time value (ingest/CMDB event time?)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then you must define your search time range to include any events that need to be found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can manipulate _time as you have done in your second example and can test for that _time within the last 3 weeks with&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _time=strptime(created_date,"%Y-%m-%d %H:%M:%S")
| where _time&amp;gt;=relative_time(now(), "-3w@w")&lt;/LI-CODE&gt;&lt;P&gt;which will filter out only those created_date times within the last week.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 02:29:59 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-04-28T02:29:59Z</dc:date>
    <item>
      <title>Use alternate field for time and filtering</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595688#M207318</link>
      <description>&lt;P&gt;I am stuck.&amp;nbsp; Have tried all of the options I have found.&amp;nbsp; Most come close, but cannot make it work.&amp;nbsp; I collect data from a CMDB that has field with a date I need to filter on, created_date.&amp;nbsp;&lt;BR /&gt;What I am trying to accomplish: Generate a query for all events of the past 3 weeks where there are CMDB events that have a field "created_date" spanning multiple months, I only want those events that have a created_date that falls with the the 3 week period.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If I use the following query, it returns as expected all events within the three week period.&amp;nbsp; What I want are all events based on the created_date, not based on _time.&lt;BR /&gt;BTW, created_date has a standard time output: "%Y-%m-%d %H:%M:%S"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=cmdb dv_number=* dv_assigned_to=* dv_state=* created_date earliest=3w@w latest=@w
| search [| inputlookup cmdb_users.csv| table dv_assigned_to ]
| timechart span1w count(dv_number)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I also tried, was converting the field created_date, to _time using the following, which turned created_date into epoch, but did produce the correct _time ouput, but cannot use earliest/latest since my understanding is earliest/latest only work on the initial search.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=cmdb dv_number=* dv_assigned_to=* dv_state=* created_date earliest=3w@w latest=@w
| search [| inputlookup cmdb_users.csv| table dv_assigned_to ]
| eval created_date=strptime(created_date,"%Y-%m-%d %H:%M:%S") 
| eval _time=created_date
........
.....
.. &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried using a where statement, which partially worked, but would only cover the outer boundary (3weeks), not the inner boundary of the end of the last week.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where created_date &amp;lt;= relative_time(now(), "-3w@w") AND created_date &amp;gt;= relative_time(now()), "@w")
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 02:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595688#M207318</guid>
      <dc:creator>tlmayes</dc:creator>
      <dc:date>2022-04-28T02:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Use alternate field for time and filtering</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595690#M207320</link>
      <description>&lt;P&gt;The data that is ingested will always get allocated a _time field based on your config for that input - that totally defines what events you get back based on your earliest/latest time range.&lt;/P&gt;&lt;P&gt;I didn't quite understand your goal&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Generate a query for all events of the past 3 weeks where there are CMDB events that have a field "created_date" spanning multiple months, I only want those events that have a created_date that falls with the the 3 week period.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is really about understanding what an 'event' ingested into Splunk will have as its _time value (ingest/CMDB event time?)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then you must define your search time range to include any events that need to be found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can manipulate _time as you have done in your second example and can test for that _time within the last 3 weeks with&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _time=strptime(created_date,"%Y-%m-%d %H:%M:%S")
| where _time&amp;gt;=relative_time(now(), "-3w@w")&lt;/LI-CODE&gt;&lt;P&gt;which will filter out only those created_date times within the last week.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 02:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595690#M207320</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-28T02:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use alternate field for time and filtering</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595691#M207321</link>
      <description>&lt;P&gt;Yes, I tried that as well, but returns all events for the past 3 weeks, plus 4 days.&amp;nbsp; The problem is, I need all events in the past full 3 weeks, so If I run the query today, I only want the events for weeks #14, 15, and 16 (along the 7 day boundary)&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 02:36:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595691#M207321</guid>
      <dc:creator>tlmayes</dc:creator>
      <dc:date>2022-04-28T02:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use alternate field for time and filtering</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595692#M207322</link>
      <description>&lt;P&gt;Just bound the where clause with the time range you want, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval _time=strptime(created_date,"%Y-%m-%d %H:%M:%S")
| where _time&amp;gt;=relative_time(now(), "-3w@w") AND _time&amp;lt;=relative_time(now(), "@w") &lt;/LI-CODE&gt;&lt;P&gt;Is that what you mean?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 03:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595692#M207322</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-28T03:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use alternate field for time and filtering</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595694#M207324</link>
      <description>&lt;P&gt;Yes... I tried that earlier and kept getting a complaint about a missing ')'... just typed in all in again, and this time it worked.&amp;nbsp; I ended up with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval created_date=strptime(created_date,"%Y-%m-%d %H:%M:%S")
| where created_date&amp;gt;=relative_time(now(), "-3w@w") AND created_date&amp;lt;=relative_time(now(), "@w") &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the assist&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 03:32:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-alternate-field-for-time-and-filtering/m-p/595694#M207324</guid>
      <dc:creator>tlmayes</dc:creator>
      <dc:date>2022-04-28T03:32:58Z</dc:date>
    </item>
  </channel>
</rss>

