<?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 Multi search / correlate conundrum in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503444#M140047</link>
    <description>&lt;P&gt;Sorry for not spelling the problem out in the title, I'm a bit stuck even for the correct language to describe my puzzle. It's best I explain...&lt;/P&gt;

&lt;P&gt;I have one index full of log data like the following:&lt;/P&gt;

&lt;P&gt;MessageID User &lt;BR /&gt;
1 Bill &lt;BR /&gt;
2 Carol &lt;BR /&gt;
3 Jane &lt;BR /&gt;
4 Phil &lt;BR /&gt;
5 Bill &lt;/P&gt;

&lt;P&gt;and also&lt;/P&gt;

&lt;P&gt;MessageID Attribute A Attribute B Attribute C&lt;BR /&gt;
1 Y Y N &lt;BR /&gt;
2 Y N N&lt;BR /&gt;
5 Y N N&lt;/P&gt;

&lt;P&gt;The Message ID ties together the user and the attributes that I'm interested in as I'd like a table that for each user, counts the number of times they've got a message that has an attribute we are interested in. For example for the above data the table would be:&lt;/P&gt;

&lt;P&gt;User    Attribute A Attribute B Attribute C&lt;BR /&gt;
Bill            2           1           0&lt;BR /&gt;
Carol       0           1           0&lt;BR /&gt;
Jane        0           0           0&lt;BR /&gt;
Phil            0           0           0&lt;/P&gt;

&lt;P&gt;Or to explain another way...Bill had two messages sent to him, and both had attribute A and one had tribute B. Of Carol's messages, only one had Attribute B.&lt;/P&gt;

&lt;P&gt;This is as far as I've got, but it only returns the result for one user, and I'm not sure if JOIN is the right approach for this task!&lt;/P&gt;

&lt;P&gt;index=thelog recipient bill | join MessageID  [search index=thelog "Attribute A" ] |  stats count as Recipient by recipient&lt;/P&gt;

&lt;P&gt;Your genius is much appreciated!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Oct 2019 06:52:16 GMT</pubDate>
    <dc:creator>jeremywebb</dc:creator>
    <dc:date>2019-10-12T06:52:16Z</dc:date>
    <item>
      <title>Multi search / correlate conundrum</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503444#M140047</link>
      <description>&lt;P&gt;Sorry for not spelling the problem out in the title, I'm a bit stuck even for the correct language to describe my puzzle. It's best I explain...&lt;/P&gt;

&lt;P&gt;I have one index full of log data like the following:&lt;/P&gt;

&lt;P&gt;MessageID User &lt;BR /&gt;
1 Bill &lt;BR /&gt;
2 Carol &lt;BR /&gt;
3 Jane &lt;BR /&gt;
4 Phil &lt;BR /&gt;
5 Bill &lt;/P&gt;

&lt;P&gt;and also&lt;/P&gt;

&lt;P&gt;MessageID Attribute A Attribute B Attribute C&lt;BR /&gt;
1 Y Y N &lt;BR /&gt;
2 Y N N&lt;BR /&gt;
5 Y N N&lt;/P&gt;

&lt;P&gt;The Message ID ties together the user and the attributes that I'm interested in as I'd like a table that for each user, counts the number of times they've got a message that has an attribute we are interested in. For example for the above data the table would be:&lt;/P&gt;

&lt;P&gt;User    Attribute A Attribute B Attribute C&lt;BR /&gt;
Bill            2           1           0&lt;BR /&gt;
Carol       0           1           0&lt;BR /&gt;
Jane        0           0           0&lt;BR /&gt;
Phil            0           0           0&lt;/P&gt;

&lt;P&gt;Or to explain another way...Bill had two messages sent to him, and both had attribute A and one had tribute B. Of Carol's messages, only one had Attribute B.&lt;/P&gt;

&lt;P&gt;This is as far as I've got, but it only returns the result for one user, and I'm not sure if JOIN is the right approach for this task!&lt;/P&gt;

&lt;P&gt;index=thelog recipient bill | join MessageID  [search index=thelog "Attribute A" ] |  stats count as Recipient by recipient&lt;/P&gt;

&lt;P&gt;Your genius is much appreciated!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2019 06:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503444#M140047</guid>
      <dc:creator>jeremywebb</dc:creator>
      <dc:date>2019-10-12T06:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multi search / correlate conundrum</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503445#M140048</link>
      <description>&lt;P&gt;@jeremywebb,&lt;/P&gt;

&lt;P&gt;Try this and test against your data. By looking at your explanation &amp;amp; data,  the second row of your result should be &lt;CODE&gt;Carol 1 0 0&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=thelog |fields recipient,MessageID,AttributeA,AttributeB,AttributeC
| eventstats values(Attribute*) as Attribute* by MessageID
| stats count(eval(AttributeA="Y")) as AttributeA,count(eval(AttributeB="Y")) as AttributeB,count(eval(AttributeC="Y")) as AttributeC by recipient
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Oct 2019 12:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503445#M140048</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-10-12T12:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multi search / correlate conundrum</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503446#M140049</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="MessageID,User
1,Bill
2,Carol
3,Jane
4,Phil
5,Bill"
| eval sourcetype="A"
| append [| makeresults 
| eval _raw="MessageID,AttributeA,AttributeB,AttributeC
1,Y,Y,N
2,Y,N,N
5,Y,N,N"
| eval sourcetype="B"]
| multikv forceheader=1
| fields - _* sourcetype linecount

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| stats list(*) AS * values(User) AS User BY MessageID
| stats count(eval(AttributeA="Y")) AS AttributeA count(eval(AttributeB="Y")) AS AttributeB count(eval(AttributeC="Y")) AS AttributeC BY User
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Oct 2019 20:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503446#M140049</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-12T20:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multi search / correlate conundrum</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503447#M140050</link>
      <description>&lt;P&gt;Worked like a charm, and I learnt something from the approach. Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 07:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503447#M140050</guid>
      <dc:creator>jeremywebb</dc:creator>
      <dc:date>2019-10-22T07:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Multi search / correlate conundrum</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503448#M140051</link>
      <description>&lt;P&gt;Thanks for this!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 07:17:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-search-correlate-conundrum/m-p/503448#M140051</guid>
      <dc:creator>jeremywebb</dc:creator>
      <dc:date>2019-10-22T07:17:33Z</dc:date>
    </item>
  </channel>
</rss>

