<?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: Compare two events with multiple key value pairs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584464#M203522</link>
    <description>&lt;P&gt;This seems to return the two events as _raw only&lt;/P&gt;</description>
    <pubDate>Thu, 10 Feb 2022 07:26:18 GMT</pubDate>
    <dc:creator>rizwan0683</dc:creator>
    <dc:date>2022-02-10T07:26:18Z</dc:date>
    <item>
      <title>Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584452#M203511</link>
      <description>&lt;P&gt;I have two events that are semi-colon separated key value pairs. I have applied the extract command to parse the event into key value pairs. The aim is to compare the two events using the key and highlight the differences in values in a table format with the key as header and values as rows&lt;/P&gt;&lt;P&gt;Event 1&lt;BR /&gt;35=D; 54=2; 40=1; 11=abc&lt;/P&gt;&lt;P&gt;Event 2&lt;BR /&gt;35=G; 54=2; 40=2; 11=xyz&lt;/P&gt;&lt;P&gt;Result&lt;BR /&gt;35|40|11&lt;BR /&gt;D|1|abc&lt;BR /&gt;G|2|xyz&lt;BR /&gt;&lt;BR /&gt;Which function will index my keys so that I may compare their values and report in the above format?&lt;BR /&gt;&lt;BR /&gt;Extraction performed as follows:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;search&amp;gt; |&amp;nbsp;extract pairdelim=";" kvdelim="\=" clean_keys=false&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 06:50:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584452#M203511</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2022-02-10T06:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584459#M203517</link>
      <description>&lt;P&gt;For two events, you could do this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count as row
| eval row="row".row
| transpose 0 header_field=row column_name=row
| where row1!=row2
| transpose 0 header_field=row column_name=row
| fields - row&lt;/LI-CODE&gt;&lt;P&gt;If you have more than 2 events, you will need to be more specific about the comparisons for which fields from the events you want to keep&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 07:11:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584459#M203517</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T07:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584464#M203522</link>
      <description>&lt;P&gt;This seems to return the two events as _raw only&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 07:26:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584464#M203522</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2022-02-10T07:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584467#M203524</link>
      <description>&lt;P&gt;You did add it after your extract, right?&lt;/P&gt;&lt;P&gt;Please can you share your query?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 07:35:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584467#M203524</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T07:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584469#M203526</link>
      <description>&lt;P&gt;yes after extract as follows&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base search&amp;gt;
| extract pairdelim=";" kvdelim="\=" clean_keys=false 
| streamstats count as row
| eval row="row".row
| transpose 0 header_field=row column_name=row
| where row1!=row2
| transpose 0 header_field=row column_name=row
| fields - row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note the base search returns two events&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 07:41:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584469#M203526</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2022-02-10T07:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584473#M203528</link>
      <description>&lt;P&gt;Here is a runanywhere example based on your sample events showing it working&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="35=D; 54=2; 40=1; 11=abc
35=G; 54=2; 40=2; 11=xyz"
| multikv noheader=t
| fields _raw
| fields - _time
| extract pairdelim=";" kvdelim="\=" clean_keys=f
| streamstats count as row
| eval row="row".row
| transpose 0 header_field=row column_name=row
| where row1!=row2
| transpose 0 header_field=row column_name=row
| fields - row&lt;/LI-CODE&gt;&lt;P&gt;Are your real events significantly different to your examples?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 07:50:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584473#M203528</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T07:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584480#M203534</link>
      <description>&lt;P&gt;Firstly apologies, my first response was incorrect. Your code did in fact bring back _raw events as well as the output of comparing the fields and tabulating them. I had missed those as the _raw events were long and took up the width of the screen and I didn't scroll across. So it appears to be working however,&amp;nbsp;the final output is not as expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The real life data is slightly different but I don't believe it is affecting the output (e.g. timestamp field)&lt;/P&gt;&lt;P&gt;My actual output looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time | date_minute | date_second |  tag_35 | tag_52 | tag_60
2022-02-09T16:33:04.956+0000 | 33 | 4 |  G | 20220209-16:33:04.955 | 20220209-16:33:04.955
2022-02-09T16:31:42.611+0000 | 31 | 42 |  D | 20220209-16:31:42.610 | 20220209-16:31:42.610&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are genuine differences however, there are more fields that have differences not being reported here.&lt;/P&gt;&lt;P&gt;notes:&lt;/P&gt;&lt;P&gt;The first 3 columns are expected as the data does differ in those fields.&lt;BR /&gt;The headers for last 4 fields are taken from a dictionary I maintain and can access via inputlookup. In this dictionary key "11" has been mapped to a header named "tag_11".&lt;/P&gt;&lt;P&gt;I note that the keys with differences that are not showing up, happen to be those that DON'T have a mapping in this dictionary. Using my original example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Event 1&lt;BR /&gt;35=D; 54=2; 40=1; 11=abc; 75=hellow&lt;/P&gt;&lt;P&gt;Event 2&lt;BR /&gt;35=G; 54=2; 40=2; 11=xyz; 75=world&lt;BR /&gt;&lt;BR /&gt;Your code is generating the equivalent of this output:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Result&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;35|40|11&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;D|1|abc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;G|2|xyz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;i.e 75 is omitted, despite having a difference.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Keys 35, 54, 40, 11 are mapped in this dictionary&amp;nbsp;&lt;BR /&gt;Key 75 is not.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Would this cause the discrepancy in the result?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 11:45:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584480#M203534</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2022-03-03T11:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584498#M203544</link>
      <description>&lt;P&gt;I am not sure I understand, here is a runanywhere example with the additional field still showing up as expected&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="35=D; 54=2; 40=1; 11=abc; 75=hellow
35=G; 54=2; 40=2; 11=xyz; 75=world"
| multikv noheader=t
| fields _raw
| fields - _time
| extract pairdelim=";" kvdelim="\=" clean_keys=f
| streamstats count as row
| eval row="row".row
| transpose 0 header_field=row column_name=row
| where row1!=row2
| transpose 0 header_field=row column_name=row
| fields - row _raw&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITWhisperer_0-1644487011661.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17932i27F529BE3E1F71E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITWhisperer_0-1644487011661.png" alt="ITWhisperer_0-1644487011661.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As for your other example, all the columns have different values in, so all would be kept&lt;/P&gt;&lt;P&gt;What happens if there is no mapping, what is the field name in this instance?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 10:05:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584498#M203544</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T10:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584501#M203545</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&amp;gt;&amp;gt;What happens if there is no mapping, what is the field name in this instance?&lt;/P&gt;&lt;P&gt;I would expect the key name to display e.g.&amp;nbsp; 35,11,75.&lt;/P&gt;&lt;P&gt;Would it be an issue if the data was arranged randomly e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Event 1&lt;BR /&gt;35=D; 54=2; 40=1; 11=abc; 75=hellow&lt;/P&gt;&lt;P&gt;Event 2&lt;BR /&gt;54=2; 11=xyz; 75=world;&amp;nbsp;&lt;SPAN&gt;40=2;&amp;nbsp;35=G&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help breakdown what your code is doing please, specifically&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval row="row".row&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Feb 2022 10:27:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584501#M203545</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2022-02-10T10:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two events with multiple key value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584506#M203548</link>
      <description>&lt;P&gt;Specifically&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count as row
| eval row="row".row&lt;/LI-CODE&gt;&lt;P&gt;Is adding a field called row with a unique number,; this is then prepended with the string "row" so that, when the transpose is done, there are two fields with known names (row1 and row2) for the where command to be able to compare across the two columns (previously rows)&lt;/P&gt;&lt;P&gt;The order doesn't matter because the extract is putting them into the right fields&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="35=D; 54=2; 40=1; 11=abc; 75=hellow
54=2; 11=xyz; 75=world; 40=2; 35=G"
| multikv noheader=t
| fields _raw
| fields - _time
| extract pairdelim=";" kvdelim="\=" clean_keys=f
| streamstats count as row
| eval row="row".row
| transpose 0 header_field=row column_name=row
| where row1!=row2
| transpose 0 header_field=row column_name=row
| fields - row _raw&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 10 Feb 2022 10:52:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-two-events-with-multiple-key-value-pairs/m-p/584506#M203548</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-10T10:52:59Z</dc:date>
    </item>
  </channel>
</rss>

