<?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 Need to combine nearest _time values for each field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490459#M136952</link>
    <description>&lt;P&gt;Hi Splunker,&lt;/P&gt;

&lt;P&gt;In my application when there is action, 3 events will be created for it.&lt;/P&gt;

&lt;P&gt;Eg : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      _time                    field_1           old_value             new_value             user                name
2020-01-19 13:28:55              ABC                                  C51R                6191                 355767013
2020-01-19 13:28:55              DEF                                  C51R                                     355767013
2020-01-19 13:28:55              DEF             C53R                                                     355767013
2020-01-19 12:09:58              ABC                                  C54L                6567                 355767013
2020-01-19 12:09:58              DEF                                  C54L                                     355767013
2020-01-19 12:09:57              DEF             C54R                                                     355767013
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From the above event, u can see 3 different rows created for each action, some time there might be 5 to 10 seconds gap in _time in the events.&lt;/P&gt;

&lt;P&gt;name is common and unique in the events, i wanted to know the old value, new value and the user chagned with the _time in single row.&lt;/P&gt;

&lt;P&gt;My expectations.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      _time                      old_valu       new_value             user                name
2020-01-19 13:28:55               C53R           C51R                6191              355767013

2020-01-19 12:09:58               C54R           C54L                6567              355767013
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;Note: i tried | transaction span=1m _time , | bucket span=1m &lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2020 06:02:12 GMT</pubDate>
    <dc:creator>SathyaNarayanan</dc:creator>
    <dc:date>2020-01-23T06:02:12Z</dc:date>
    <item>
      <title>Need to combine nearest _time values for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490459#M136952</link>
      <description>&lt;P&gt;Hi Splunker,&lt;/P&gt;

&lt;P&gt;In my application when there is action, 3 events will be created for it.&lt;/P&gt;

&lt;P&gt;Eg : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      _time                    field_1           old_value             new_value             user                name
2020-01-19 13:28:55              ABC                                  C51R                6191                 355767013
2020-01-19 13:28:55              DEF                                  C51R                                     355767013
2020-01-19 13:28:55              DEF             C53R                                                     355767013
2020-01-19 12:09:58              ABC                                  C54L                6567                 355767013
2020-01-19 12:09:58              DEF                                  C54L                                     355767013
2020-01-19 12:09:57              DEF             C54R                                                     355767013
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From the above event, u can see 3 different rows created for each action, some time there might be 5 to 10 seconds gap in _time in the events.&lt;/P&gt;

&lt;P&gt;name is common and unique in the events, i wanted to know the old value, new value and the user chagned with the _time in single row.&lt;/P&gt;

&lt;P&gt;My expectations.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      _time                      old_valu       new_value             user                name
2020-01-19 13:28:55               C53R           C51R                6191              355767013

2020-01-19 12:09:58               C54R           C54L                6567              355767013
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;Note: i tried | transaction span=1m _time , | bucket span=1m &lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 06:02:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490459#M136952</guid>
      <dc:creator>SathyaNarayanan</dc:creator>
      <dc:date>2020-01-23T06:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine nearest _time values for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490460#M136953</link>
      <description>&lt;P&gt;@SathyaNarayanan &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH
| eval t=_time | bucket _time span=1m | stats latest(t) as t values(old_value) as old_value values(new_value) as new_value values(user) as user by _time, name | eval _time=t | table _time old_value new_value user name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="       time                    field_1           old_value             new_value             user                name
 2020-01-19 13:28:55              ABC                                  C51R                6191                 355767013
 2020-01-19 13:28:55              DEF                                  C51R                                     355767013
 2020-01-19 13:28:55              DEF             C53R                                                         355767013
 2020-01-19 12:09:58              ABC                                  C54L                6567                 355767013
 2020-01-19 12:09:58              DEF                                  C54L                                     355767013
 2020-01-19 12:09:57              DEF             C54R                                                         355767013" 
| multikv forceheader=1 
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S") 
| table _time field_1 old_value new_value user name
| rename comment as "Upto this is for data generation only" 
| eval t=_time | bucket _time span=1m | stats latest(t) as t values(old_value) as old_value values(new_value) as new_value values(user) as user by _time, name | eval _time=t | table _time old_value new_value user name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 08:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490460#M136953</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-01-23T08:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine nearest _time values for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490461#M136954</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="time,field_1,old_value,new_value,user,name
2020-01-19 13:28:55,ABC,,C51R,6191,355767013
2020-01-19 13:28:55,DEF,,C51R,,355767013
2020-01-19 13:28:55,DEF,C53R,,,355767013
2020-01-19 12:09:58,ABC,,C54L,6567,355767013
2020-01-19 12:09:58,DEF,,C54L,,355767013
2020-01-19 12:09:57,DEF,C54R,,,355767013" 
| multikv forceheader=1
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S") 
| table _time field_1 old_value new_value user name
    `comment("above is your sample. from here, the logic")` 
| transaction maxspan=10s name 
| table _time old_value new_value user name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @SathyaNarayanan&lt;BR /&gt;
try &lt;CODE&gt;transaction maxspan=&lt;/CODE&gt; .&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 11:49:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490461#M136954</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T11:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine nearest _time values for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490462#M136955</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;As per your query will show only one change, in my scenario there will be several changes.&lt;/P&gt;

&lt;P&gt;for example.&lt;/P&gt;

&lt;P&gt;OLD_VALUE  NEW_VALUE&lt;BR /&gt;
C53R                  C56&lt;BR /&gt;
C51                    C53R&lt;BR /&gt;
C54 R                  C51&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-combine-nearest-time-values-for-each-field/m-p/490462#M136955</guid>
      <dc:creator>SathyaNarayanan</dc:creator>
      <dc:date>2020-09-30T03:49:07Z</dc:date>
    </item>
  </channel>
</rss>

