<?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: Substituting _time with an extracted time field changing behavior unexpectedly in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129073#M26495</link>
    <description>&lt;P&gt;to be honest I'm quite busy and couldn't check carefully your searches if there's some other mistakes. Sometimes, bwt, _time field gives problem with substitutions or other operation. That's why I suggested a cleaner approach from the beginning, with the correct time extraction.&lt;/P&gt;

&lt;P&gt;Let me know!&lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
    <pubDate>Fri, 11 Apr 2014 15:46:57 GMT</pubDate>
    <dc:creator>marcoscala</dc:creator>
    <dc:date>2014-04-11T15:46:57Z</dc:date>
    <item>
      <title>Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129069#M26491</link>
      <description>&lt;P&gt;Details:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The data is coming in from syslog and the time that I want to base my searches off of is in fact the "localtime" contained inside the message (the actual time the event occurred on the se
rver) rather than the timestamp of the syslog message itself&lt;/LI&gt;
&lt;LI&gt;My end goal is to catch events that occur within 1second of each other as long as the "channel" is the same and the sourcetypes differ. &lt;/LI&gt;
&lt;LI&gt;I test that my logic works for two events that I've identified as matching (the two sample events provided), but when I expand my timerange, then my results are drastically changed and I don't get expected results such as the transaction of the two events I've identified.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have the following 2 sample events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype A
2014-04-11T04:00:15.270885-04:00 -  Alert - string1 - severity[Alert] source[string3] ip[-] description[description1] details[] reason[EventSet] localtime[2014/04/11 04:00:02.0 EDT] time[2014/04/11 08:00:02.0 UTC] count[1] value[x] 
sourcetype B
2014-04-11T04:00:03.312903-04:00 -  Alert Clear - string2 - severity[Alert] source[string3] ip[-] description[description2] details[] reason[EventReset] localtime[2014/04/11 04:00:03.0 EDT] time[2014/04/11 08:00:03.0 UTC] count[1] value[x] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The important information is the "localtime", which is being extracted into a field of the same name, and the "source", which is being extracted into a field named channel. So I can abbreviate the data as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event1: _time="2014-04-11T04:00:15.270885-04:00", sourcetype=A, channel=mysource1, localtime="2014/04/11 04:00:02.0 EDT"
event2: _time="2014-04-11T04:00:03.312903-04:00", sourcetype=B, channel=mysource1, localtime="2014/04/11 04:00:03.0 EDT"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I run the below search I get the 2 results listed above:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex earliest=@d+4h latest=@d+4h+1m ((sourcetype=A "string1") OR ((sourcetype=B OR sourcetype=C) "string2")) (channel="string3" OR channel=string4) | eval localtime=strptime(localtime, "%Y/%m/%d %H:%M:%S.0 %Z") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But if I add the below eval statement, I only get event1 in my results, even though the values in _time still fall within the earliest-latest range:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex earliest=@d+4h latest=@d+4h+1m ((sourcetype=A "string1") OR ((sourcetype=B OR sourcetype=C) "string2")) (channel="string3" OR channel=string4) | eval localtime=strptime(localtime, "%Y/%m/%d %H:%M:%S.0 %Z") | eval _time = localtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Something that makes this even odder is that if I run the above search with a transaction in it, both events get caught as I'd expect in my transaction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex earliest=@d+4h latest=@d+4h+1m ((sourcetype=A "string1") OR ((sourcetype=B OR sourcetype=C) "string2")) (channel="string3" OR channel="string4") | eval localtime=strptime(localtime, "%Y/%m/%d %H:%M:%S.0 %Z") | eval _time = localtime | transaction channel maxpause=2s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the behavior I'm looking for in the end, but sadly the story doesn't end here. If I now use the above search, and increase latest to @d+4h+10m, then the transaction is lost...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=remyindex earliest=@d+4h latest=@d+4h+10m ((sourcetype=A "string1") OR ((sourcetype=B OR sourcetype=C) "string2")) (channel="string3" OR channel="string4") | eval localtime=strptime(localtime, "%Y/%m/%d %H:%M:%S.0 %Z") | eval _time = localtime | transaction channel maxpause=2s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 14:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129069#M26491</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2014-04-11T14:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129070#M26492</link>
      <description>&lt;P&gt;Aholzer,&lt;BR /&gt;
if the real timestam of the event you get is stored in the 'localtime' field, my suggestion is to customize timestamp recognition and set _time to that timestamp instead of the syslog timestamp.&lt;/P&gt;

&lt;P&gt;You can do it setting the correct TIME_PREFIX and  TIME_FORMAT&lt;BR /&gt;
TIME_PREFIX=localtime[ &lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129070#M26492</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2020-09-28T16:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129071#M26493</link>
      <description>&lt;P&gt;Try instead of eval, use rename. (|rename localtime as _time)&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 15:43:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129071#M26493</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-11T15:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129072#M26494</link>
      <description>&lt;P&gt;Let me test that. I don't think that it will solve everything though. I'll report back after I make the change.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 15:43:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129072#M26494</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2014-04-11T15:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129073#M26495</link>
      <description>&lt;P&gt;to be honest I'm quite busy and couldn't check carefully your searches if there's some other mistakes. Sometimes, bwt, _time field gives problem with substitutions or other operation. That's why I suggested a cleaner approach from the beginning, with the correct time extraction.&lt;/P&gt;

&lt;P&gt;Let me know!&lt;/P&gt;

&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 15:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129073#M26495</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2014-04-11T15:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129074#M26496</link>
      <description>&lt;P&gt;I appreciate it. Doing what you suggest is a good idea and will eliminate at least one point of failure. The server is restarting now, I'll need to wait to get some data before I can test if it's been fixed or not. Again, thanks for your input&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 15:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129074#M26496</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2014-04-11T15:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129075#M26497</link>
      <description>&lt;P&gt;Marco,&lt;/P&gt;

&lt;P&gt;From preliminary testing it would seem that this did the trick. I found a couple of events that I should be catching under my logic (after the time change), I've tested with a short and a wide timerange, and in both cases the events come up in a transaction.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 19:30:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129075#M26497</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2014-04-11T19:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting _time with an extracted time field changing behavior unexpectedly</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129076#M26498</link>
      <description>&lt;P&gt;Glad it worked! Please don't forget to mark the question answered!&lt;/P&gt;

&lt;P&gt;And happy Splunking!&lt;BR /&gt;
Marco&lt;/P&gt;</description>
      <pubDate>Sat, 12 Apr 2014 06:19:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substituting-time-with-an-extracted-time-field-changing-behavior/m-p/129076#M26498</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2014-04-12T06:19:14Z</dc:date>
    </item>
  </channel>
</rss>

