<?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 compare field values in time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375745#M169606</link>
    <description>&lt;P&gt;I don't know what you mean here.  Tags don't change unless admins change them.  I significant rephrasing with much more detail will get you more people willing and able to help.&lt;/P&gt;</description>
    <pubDate>Sun, 06 May 2018 18:29:31 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-05-06T18:29:31Z</dc:date>
    <item>
      <title>How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375743#M169604</link>
      <description>&lt;P&gt;We are gathering data on information tags on servers. We want to know when a specific tag value changes so that we can send an alert. This is a db that is read into splunk every 30 minutes. I want to search through the data, and find the relevant data when the field changes and send an alert. Unfortunately, the source is not rising, it is batch.&lt;/P&gt;

&lt;P&gt;I'm really new to splunk, so i'm still trying to figure out which function I would use for this.&lt;/P&gt;

&lt;P&gt;Thanks for any assistance!&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 02:54:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375743#M169604</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2018-05-06T02:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375744#M169605</link>
      <description>&lt;P&gt;You would make both our lifes a lot easier if you could provide some example data and a mockup of what you would like your results to look like &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 08:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375744#M169605</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-06T08:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375745#M169606</link>
      <description>&lt;P&gt;I don't know what you mean here.  Tags don't change unless admins change them.  I significant rephrasing with much more detail will get you more people willing and able to help.&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 18:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375745#M169606</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-06T18:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375746#M169607</link>
      <description>&lt;P&gt;Yes, I understand. Sorry, first time trying to ask a question here about an app that I'm unfamiliar with. Wasn't sure what info was required, and I can't just dump company info on a public website. &lt;BR /&gt;
On a side note, I think I may have figured out one problem. Seems I was missing quotes around field names again. I honestly don't know how developers keep syntax straight between so many apps. Its maddening. &lt;/P&gt;

&lt;P&gt;So let me start over:&lt;/P&gt;

&lt;P&gt;We are pulling tags from AWS servers. We want to be notified when a tag changes. The data is put into Splunk via batch, so we have to search and find the 2nd to last entry in the data and compare it to the newest to see if the tag changes.&lt;/P&gt;

&lt;P&gt;The following kind of works, and I think I'm on the right track, but not positive.&lt;/P&gt;

&lt;P&gt;stats first("configurationItem.tags.awstagGroup") as previous, last("configurationItem.tags.awstagGroup") as current by "configurationItem.tags.Name"&lt;/P&gt;

&lt;P&gt;From what I have been reading, I think "first" is grabbing the data from the first entry of the table on the "configurationItem.tags.Name" field. So if anything changes after that first entry, it would show the wrong data with that query, and not the second to last entry of the "configurationItem.tags.Name" field. I'm not sure how to compare to the 2nd to last entry in the table. And how to display the _time that it was changed.&lt;/P&gt;

&lt;P&gt;I hope that is a little clearer. Sorry for the confusion and lack of information.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 01:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375746#M169607</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2018-05-07T01:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375747#M169608</link>
      <description>&lt;P&gt;Output would be :&lt;/P&gt;

&lt;P&gt;Name tag     Previous Tag     Current Tag     Time Changed&lt;BR /&gt;
Servername       group4            group5            5/6/18 12:13:00&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 01:09:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375747#M169608</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2018-05-07T01:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375748#M169609</link>
      <description>&lt;P&gt;My first comment back to you is being reviewed by the mods. So, sorry if you see the "output" comment before the first one. &lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 01:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375748#M169609</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2018-05-07T01:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375749#M169610</link>
      <description>&lt;P&gt;You can check this to make sure you post a "good" question &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunkbase/splunkbase/Answers/Questions"&gt;http://docs.splunk.com/Documentation/Splunkbase/splunkbase/Answers/Questions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Is your AWS data pulled with a fixed intervall? &lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 16:46:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375749#M169610</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-07T16:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375750#M169611</link>
      <description>&lt;P&gt;Thank you for that link! &lt;/P&gt;

&lt;P&gt;I don't have access to the index as it is from another part of the company that is using splunk. I just have access to the data. But, from what I see in the data, it is pulled every 30 minutes. &lt;/P&gt;

&lt;P&gt;This is what I have been working with this morning. Seems to be closer, but I'm getting data that still has the same info in the tag.&lt;/P&gt;

&lt;P&gt;| streamstats current=f last("configurationItem.tags.OnPremPatchGroup") as oldPatchGrp last(_time) as time_of_change by "configurationItem.tags.Name"&lt;BR /&gt;
| where "configurationItem.tags.OnPremPatchGroup" != oldPatchGrp | convert ctime(time_of_change) as time_of_change | table time_of_change "configurationItem.tags.Name" oldPatchGrp configurationItem.tags.OnPremPatchGroup | sort +"configurationItem.tags.Name" +time_of_change&lt;/P&gt;

&lt;P&gt;time_of_change  configurationItem.tags.Name oldPatchGrp configurationItem.tags.OnPremPatchGroup&lt;BR /&gt;
05/06/2018 19:53:57.038 ASAAWSTEST01    GROUP2620   GROUP2614&lt;BR /&gt;
05/06/2018 20:27:34.912 ASAAWSTEST01    AWS_EC2_AUTOPATCHING    GROUP2620&lt;BR /&gt;
05/07/2018 08:18:34.444 ASAAWSTEST01    GROUP2604   AWS_EC2_AUTOPATCHING&lt;BR /&gt;
05/06/2018 12:43:19.964 ASAAWSTEST02    Group2617   Group2614&lt;BR /&gt;
05/06/2018 13:17:50.563 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 13:48:29.774 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 14:18:45.165 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 14:48:55.298 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 15:18:30.275 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 15:49:05.525 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 16:20:02.813 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 16:49:07.123 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 17:18:37.858 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 17:49:07.489 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 18:17:54.200 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 18:47:57.105 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 19:17:57.442 ASAAWSTEST02    Group2617   Group2617&lt;BR /&gt;
05/06/2018 19:38:50.251 ASAAWSTEST02    GROUP2614   Group2617&lt;BR /&gt;
05/06/2018 19:47:33.710 ASAAWSTEST02    GROUP2614   GROUP2614&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375750#M169611</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2020-09-29T19:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375751#M169612</link>
      <description>&lt;P&gt;@batsonpm, while using streamstats to get previous value of data sorted by _time you should also be using parameter &lt;CODE&gt;window=1&lt;/CODE&gt;. Which seems to be missing in your sample query.&lt;/P&gt;

&lt;P&gt;It would be helpful for us to assist if you can provide tablular sample data of raw events that you are working with, along with your requirement.&lt;/P&gt;

&lt;P&gt;Based on information so far seems like, you have &lt;CODE&gt;time_of_change&lt;/CODE&gt;  &lt;CODE&gt;configurationItem.tags.Name&lt;/CODE&gt; and &lt;CODE&gt;configurationItem.tags.OnPremPatchGroup&lt;/CODE&gt; in your raw events. For each &lt;CODE&gt;configurationItem.tags.Name&lt;/CODE&gt; when the &lt;CODE&gt;configurationItem.tags.OnPremPatchGroup&lt;/CODE&gt; of current row does not match with previous &lt;CODE&gt;configurationItem.tags.OnPremPatchGroup&lt;/CODE&gt;, you need to fetch the previous &lt;CODE&gt;time_of_change&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Please confirm. Also provide sample raw events in tabular format for us to assist.&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 09:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375751#M169612</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-13T09:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375752#M169613</link>
      <description>&lt;P&gt;Without a lot of information to go on, I'm going to make a stab at answering this question.&lt;/P&gt;

&lt;P&gt;Assuming that you are getting two different (by time) result sets from a DB query with only a few values that you want to check, like you have the count of somethings that come from the db query into Splunk something like (in a CSV format in this case):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;wallets,10
purses,15
backpacks,6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you might get another result set from the data that has the number of purses change, but no the wallets and backpacks:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;wallets,10
purses,14
backpacks,6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So you then want to alert on the number of purses changing. This could be done in the following manner (I'm using a "runAnywhere" example, where &lt;STRONG&gt;the first 6 lines are just setting up the data&lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="wallets,10|purses,15|backpacks,6|wallets,10|purses,14|backpacks,6"
| makemv delim="|" data
| mvexpand data
| rex field=data "(?&amp;lt;dbfield&amp;gt;.*),(?&amp;lt;val&amp;gt;.*)"
| fields - data, _time
| mvcombine dbfield
| eval cnt=mvcount(dbfield)
| search cnt=1
| mvcombine val
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Instead of using the term &lt;CODE&gt;tag&lt;/CODE&gt;, which you used in your question, I'm using the term &lt;CODE&gt;dbfield&lt;/CODE&gt; as I would understand it from what you have asked. If you wish to understand the parts of the search above, you can just start with using the first line in a search and then add additional lines (in the order they are provided), and you will see the results at each step. Here is my explanation of the parts that make up the heart of my solution:&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;mvcombine&lt;/CODE&gt; command starts the actual work of combining the data by the &lt;CODE&gt;dbfield&lt;/CODE&gt;. The next &lt;CODE&gt;eval&lt;/CODE&gt; command counts the number of values ( &lt;CODE&gt;val&lt;/CODE&gt; ) for the &lt;CODE&gt;dbfield&lt;/CODE&gt; entries. This will put multiple &lt;CODE&gt;dbfield&lt;/CODE&gt;s where they are the same for a given &lt;CODE&gt;val&lt;/CODE&gt;. The &lt;CODE&gt;search&lt;/CODE&gt; will get rid of the entries where the &lt;CODE&gt;val&lt;/CODE&gt; was the same in both places. The &lt;CODE&gt;mvcombine&lt;/CODE&gt; command will then put the &lt;CODE&gt;dbfield&lt;/CODE&gt; back together by the different &lt;CODE&gt;val&lt;/CODE&gt; fields. This would also get rid of entries where there was not a second entry for a given &lt;CODE&gt;dbfield&lt;/CODE&gt;, so you may need to look at a different solution for that. This is &lt;STRONG&gt;just&lt;/STRONG&gt; looking at a &lt;CODE&gt;dbfield&lt;/CODE&gt; value changing. You can alert if there are any results returned.&lt;/P&gt;

&lt;P&gt;In &lt;STRONG&gt;your&lt;/STRONG&gt; base search you will probably want to search through just the last two sets of data that have come in.&lt;/P&gt;

&lt;P&gt;There are other ways of doing this, but this might help get you going in the right direction. If this doesn't match your expected results, please provide a better description of what you need to accomplish.&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 17:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375752#M169613</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-05-13T17:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare field values in time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375753#M169614</link>
      <description>&lt;P&gt;I was working with someone and this is what worked for us. I was missing the part where I needed to use spath for the fields, and the window. &lt;/P&gt;

&lt;P&gt;| spath output=PG path=configurationItem.tags.OnPremPatchGroup&lt;BR /&gt;
| spath output=NAME path=configurationItem.tags.Name&lt;BR /&gt;
| streamstats global=f current=t window=2 latest(PG) as current_PG, earliest(PG) as last_PG by NAME&lt;BR /&gt;
| where current_PG!=last_PG&lt;BR /&gt;
| table _time, NAME, last_PG, current_PG&lt;BR /&gt;
| rename NAME as Server, last_PG as "Old Patch Group", current_PG as "New Patch Group" &lt;BR /&gt;
| sort +_time&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:33:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-field-values-in-time/m-p/375753#M169614</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2020-09-29T19:33:10Z</dc:date>
    </item>
  </channel>
</rss>

