<?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 match fields with the same name from two events and if match add a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702811#M238269</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/273359"&gt;@SplunkUser001&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you can do this using stats, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your-search&amp;gt;
| stats
     values(hdr_mid) AS hdr_mid 
     values(eval(if(cmd="send",rcpts,""))) AS rcpts
     BY s qid&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2024 13:35:19 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2024-10-25T13:35:19Z</dc:date>
    <item>
      <title>How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702809#M238268</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have these two events that are part of a transaction.&lt;/P&gt;&lt;P&gt;These have the same s and qid. I need to match s and qid of these two and insert a field equal to hdr_mid from the second event into first event. Is this possible?&lt;/P&gt;&lt;P&gt;In final stats I group events by hdr_mid and qid so I need hdr_mid value present in first event if I want to extract all recipients email addresses.&amp;nbsp; To do so I need to pull rcpts from first event and not&amp;nbsp; the second. How would I do that?&lt;/P&gt;&lt;TABLE width="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Oct 24 13:46:56 hostname.company.com 2024-10-24T18:46:56.426217+00:00 hostname filter_instance1[31332]: rprt s=42cu1tr3wx m=1 x=42cu1tr3wx-1 cmd=send profile=mail qid=49O9Yi2a005119 rcpts=1@company.com,2@company.com,3@company.com...52@company.com&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Oct 24 13:46:56 hostname.company.com 2024-10-24T18:46:56.426568+00:00 hostname filter_instance1[31332]: rprt s=42cu1tr3wx m=1 x=42cu1tr3wx-1 mod=mail cmd=msg module= rule= action=continue attachments=0 rcpts=52 routes=allow_relay,default_inbound,internalnet size=4416 guid=Rze4pxSO_BZ4kUYS0OtXqLZjW3uHSx8d hdr_mid=&amp;lt;103502694.595.1729795616099.JavaMail.psoft@xyz123&amp;gt; qid=49O9Yi2a005119 hops-ip=x.x.x.x subject="Message subject" duration=0.271 elapsed=0.325&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 25 Oct 2024 13:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702809#M238268</guid>
      <dc:creator>SplunkUser001</dc:creator>
      <dc:date>2024-10-25T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702811#M238269</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/273359"&gt;@SplunkUser001&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you can do this using stats, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your-search&amp;gt;
| stats
     values(hdr_mid) AS hdr_mid 
     values(eval(if(cmd="send",rcpts,""))) AS rcpts
     BY s qid&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 13:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702811#M238269</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-10-25T13:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702829#M238270</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;gcusello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for a quick reply.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately this approach in its entirety will not work as there are more events that these two in a "send an email" group of events. All events except the first one from the two I posted have both hdr_mid and qid fields so I group them by these fields in stats. Also, only these two events i posted have rprt set of fields with s in them. I was thinking about somehow matching these two events on s and qid so I can insert field with hdr_mid value into first event. This will allow me to have all events with hdr_mid and qid in them so grouping by hdr_mid and qid in final stats statement will allow to pull list of recipients.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;BTW, the values statement below is exactly what I was looking for to pull rctps field from proper event.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;values(eval(if(cmd="send",rcpts,""))) AS rcpts&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 15:39:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702829#M238270</guid>
      <dc:creator>SplunkUser001</dc:creator>
      <dc:date>2024-10-25T15:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702836#M238274</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;SPAN&gt;I was thinking about somehow matching these two events on s and qid so I can insert field with hdr_mid value into first event. This will allow me to have all events with hdr_mid and qid in them so grouping by hdr_mid and qid in final stats statement will allow to pull list of recipients.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is why you need to describe the full use case including all relevant data, not just those you are trying to extract something.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;'s idea is still applicable here; you just substitute stats with &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eventstats" target="_blank" rel="noopener"&gt;eventstats&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your-search&amp;gt;
| eventstats
     values(hdr_mid) AS hdr_mid 
     values(eval(if(cmd="send",rcpts,""))) AS rcpts
     BY s qid
| stats whatever by hdr_mid qid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 18:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702836#M238274</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-10-25T18:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702849#M238281</link>
      <description>&lt;P&gt;Ok. I recognize filterd logs. What is your business case here?&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 08:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702849#M238281</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-26T08:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702854#M238282</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eventstats values(hdr_mid) AS hdr_mid by s qid&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 26 Oct 2024 11:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702854#M238282</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-26T11:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to match fields with the same name from two events and if match add a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702952#M238302</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you guys. This helped a lot.&lt;/P&gt;&lt;P&gt;I am sorry for late reply. I was away for a weekend.&lt;/P&gt;&lt;P&gt;The primary business case is to count number of emails and their sizes (grouped by sender's SMTP address) sent from Proofpoint SER to internal SMTPs. The secondary case is to get message level information about these messages (from, to, number of recipients, subject, size). These are two independent Splunk queries.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 21:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-fields-with-the-same-name-from-two-events-and-if/m-p/702952#M238302</guid>
      <dc:creator>SplunkUser001</dc:creator>
      <dc:date>2024-10-28T21:22:07Z</dc:date>
    </item>
  </channel>
</rss>

