<?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: Splunk question on stats/multiple stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102370#M26444</link>
    <description>&lt;P&gt;Thought of that too. &lt;/P&gt;

&lt;P&gt;Unfortunately lookup table is not applicable here (both sourcetypes are created on the fly)&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jan 2013 04:23:43 GMT</pubDate>
    <dc:creator>asarolkar</dc:creator>
    <dc:date>2013-01-29T04:23:43Z</dc:date>
    <item>
      <title>Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102365#M26439</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have two sourcetypes with disparate pieces of information that i want to bring together. &lt;/P&gt;

&lt;P&gt;Note that there are &lt;STRONG&gt;MULTIPLE MODULES per ORG&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="orglog" -&amp;gt; OrgName, OrgAccountNumber, OrgModuleNum
sourcetype="modulelog" -&amp;gt; ModuleNo, ModuleType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am doing a coalesce which works just fine for me ( I recently discovered that a coalesce is the closest splunk will ever get to a full outer join - which to my understanding the JOIN type=outer command does not do)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="orglog" OR sourcetype="modulelog" | eval ModuleID=coalesce(OrgModuleNum,ModuleNo) | dedup ModuleID | *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;What if i want to generate a report in this format. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;OrgName | OrgAccountNumber | ModuleType 1 | ModuleType 2 | ModuleType3 | ModuleType4

  ACME INC          123            12        99              1384              232
  FAKE CORPINC      6673           0         199             787               101
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know that what I want will not come from a simple stats (that some complicated god-knows-what operation is needed here). &lt;STRONG&gt;Bear in Mind, we are only interested in counting the number of modules (NOT INTERESTED in the actual ModuleID)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Am I going about this the wrong way ? I am not lazy, just trying to figure out the best possible solution (not necessarily the most elegant one)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 02:49:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102365#M26439</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-29T02:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102366#M26440</link>
      <description>&lt;P&gt;I'm not sure I am clear on what it is you are doing. The sourcetype "orglog" has fields "OrgName", "OrgAccountNumber", and "OrgModuleNum". The sourcetype "modulelog" has fields "ModuleNo" and "ModuleType". The only thing in common between the events is "OrgModuleNum" and "ModuleNum" which are really jsut differnt names for the same type of value. If that is correct, you do want to do a join, but first you should rename the fields so that the field that represent the module number has the same field name for both sourcetypes. &lt;/P&gt;

&lt;P&gt;I would think something like this would work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=orglog | eval ModuleID=OrgModuleNum | join ModuleID [search source=modulelog | eval ModuleID=ModuleNo] | stats count(ModuleType) by OrgName, ModuleType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if all you want is the number of modules for each OrgName, I don't get why you can't just do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=orglog | stats count(OrgModuleNum) by OrgName, OrgModuleNum
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Jan 2013 03:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102366#M26440</guid>
      <dc:creator>rtadams89</dc:creator>
      <dc:date>2013-01-29T03:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102367#M26441</link>
      <description>&lt;P&gt;The FORMER is true.&lt;BR /&gt;
The only thing in common between the events is "OrgModuleNum" and "ModuleNum" which are really just differnt names for the same type of value. THAT IS CORRECT&lt;/P&gt;

&lt;P&gt;If I run your search it does not give me anything from modulelog. Just FYI&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 03:21:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102367#M26441</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-29T03:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102368#M26442</link>
      <description>&lt;P&gt;Actually, I take that back.&lt;/P&gt;

&lt;P&gt;That worked like a charm ! &lt;/P&gt;

&lt;P&gt;I just added a "search sourcetype" in the inner sub-search.&lt;/P&gt;

&lt;P&gt;MAN ! You just saved me a ton of grief ! WOHOOO&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 03:31:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102368#M26442</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-29T03:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102369#M26443</link>
      <description>&lt;P&gt;Glad that worked. I have edited the answer to include the required explicit "search" command. On a side note, if the relationship between ModuleNo and ModuleType doesn't change, you might want to put this in data in a lookup table instead of indexing it as events. If you need help with this, check the documentation on lookup tables or post another question.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 03:59:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102369#M26443</guid>
      <dc:creator>rtadams89</dc:creator>
      <dc:date>2013-01-29T03:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk question on stats/multiple stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102370#M26444</link>
      <description>&lt;P&gt;Thought of that too. &lt;/P&gt;

&lt;P&gt;Unfortunately lookup table is not applicable here (both sourcetypes are created on the fly)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 04:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-question-on-stats-multiple-stats/m-p/102370#M26444</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-29T04:23:43Z</dc:date>
    </item>
  </channel>
</rss>

