<?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 count(var) by &amp;quot;a list of values within a field&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412961#M119037</link>
    <description>&lt;P&gt;First of all, sorry, if I am missing something really obvious here but after hours of googling I am still stuck with the following problem.&lt;/P&gt;

&lt;P&gt;Basically I have a list of URLs and a score in the format like that:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.abc.com/abc/abc.html"&gt;http://www.abc.com/abc/abc.html&lt;/A&gt; 50&lt;BR /&gt;
&lt;A href="http://www.abc.com/abc/abc.html"&gt;http://www.abc.com/abc/abc.html&lt;/A&gt; 30&lt;BR /&gt;
&lt;A href="http://www.xyz.org/asd/"&gt;www.xyz.org/asd/&lt;/A&gt; 12&lt;BR /&gt;
qwer.com/asd 7&lt;/P&gt;

&lt;P&gt;What I try to achieve now is to group some of the URLs and have the sum of the score displayed in a table. For example:&lt;/P&gt;

&lt;P&gt;abc.com &amp;amp; xyz.org = "External Sites" will then lead to the following table:&lt;/P&gt;

&lt;H2&gt;`Site name      | Sum&lt;/H2&gt;

&lt;P&gt;External Sites  | 92`&lt;/P&gt;

&lt;P&gt;The approach so far is to have an &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval siteName = if(match(url, [some regex], ...)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;add a new field with the site name which works.&lt;/P&gt;

&lt;P&gt;The interesting part now is, that some of the groups might not have events present all the time and &lt;CODE&gt;| stats sum(score) as Sum by siteName&lt;/CODE&gt; obviously gives me only sum of the groups that are present.&lt;/P&gt;

&lt;P&gt;Is there any way to give me a table for an list of sitenames that "could" be there like the following:&lt;/P&gt;

&lt;H2&gt;`Site name       | Sum&lt;/H2&gt;

&lt;P&gt;External Sites   | 92&lt;BR /&gt;
Internal Sites   | 0`&lt;/P&gt;

&lt;P&gt;Thank you very much in advance&lt;/P&gt;

&lt;P&gt;Andreas&lt;/P&gt;</description>
    <pubDate>Mon, 20 Aug 2018 11:18:11 GMT</pubDate>
    <dc:creator>ndey</dc:creator>
    <dc:date>2018-08-20T11:18:11Z</dc:date>
    <item>
      <title>count(var) by "a list of values within a field"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412961#M119037</link>
      <description>&lt;P&gt;First of all, sorry, if I am missing something really obvious here but after hours of googling I am still stuck with the following problem.&lt;/P&gt;

&lt;P&gt;Basically I have a list of URLs and a score in the format like that:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.abc.com/abc/abc.html"&gt;http://www.abc.com/abc/abc.html&lt;/A&gt; 50&lt;BR /&gt;
&lt;A href="http://www.abc.com/abc/abc.html"&gt;http://www.abc.com/abc/abc.html&lt;/A&gt; 30&lt;BR /&gt;
&lt;A href="http://www.xyz.org/asd/"&gt;www.xyz.org/asd/&lt;/A&gt; 12&lt;BR /&gt;
qwer.com/asd 7&lt;/P&gt;

&lt;P&gt;What I try to achieve now is to group some of the URLs and have the sum of the score displayed in a table. For example:&lt;/P&gt;

&lt;P&gt;abc.com &amp;amp; xyz.org = "External Sites" will then lead to the following table:&lt;/P&gt;

&lt;H2&gt;`Site name      | Sum&lt;/H2&gt;

&lt;P&gt;External Sites  | 92`&lt;/P&gt;

&lt;P&gt;The approach so far is to have an &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval siteName = if(match(url, [some regex], ...)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;add a new field with the site name which works.&lt;/P&gt;

&lt;P&gt;The interesting part now is, that some of the groups might not have events present all the time and &lt;CODE&gt;| stats sum(score) as Sum by siteName&lt;/CODE&gt; obviously gives me only sum of the groups that are present.&lt;/P&gt;

&lt;P&gt;Is there any way to give me a table for an list of sitenames that "could" be there like the following:&lt;/P&gt;

&lt;H2&gt;`Site name       | Sum&lt;/H2&gt;

&lt;P&gt;External Sites   | 92&lt;BR /&gt;
Internal Sites   | 0`&lt;/P&gt;

&lt;P&gt;Thank you very much in advance&lt;/P&gt;

&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 11:18:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412961#M119037</guid>
      <dc:creator>ndey</dc:creator>
      <dc:date>2018-08-20T11:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: count(var) by "a list of values within a field"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412962#M119038</link>
      <description>&lt;P&gt;Try setting the sums to zero before the &lt;CODE&gt;stats&lt;/CODE&gt; command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval 'External Sites'=0, 'Internal Sites'=0 | stats sum(...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Aug 2018 11:52:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412962#M119038</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-20T11:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: count(var) by "a list of values within a field"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412963#M119039</link>
      <description>&lt;P&gt;Whoops, I just realized, that the example tables I put into the post are messed up, which might have made the desired format a bit unclear. Here is another try&lt;/P&gt;

&lt;P&gt;Site Name   -  Sum&lt;BR /&gt;
...............................&lt;BR /&gt;
Internal Sites  -   20&lt;BR /&gt;
External Sites   -  40&lt;/P&gt;

&lt;P&gt;The problem is I am looking for a way to have one filed containing tags like "External Sites", "Internal Sites" .... and then sum up the score by these tags&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 08:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412963#M119039</guid>
      <dc:creator>ndey</dc:creator>
      <dc:date>2018-08-21T08:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: count(var) by "a list of values within a field"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412964#M119040</link>
      <description>&lt;P&gt;You have the general idea in your original question.  Use &lt;CODE&gt;case&lt;/CODE&gt; to evaluate URLs as either internal or external.  Then use the &lt;CODE&gt;stats&lt;/CODE&gt; command to count internal vs external sites.&lt;/P&gt;

&lt;P&gt;... | eval siteName = case(if(match(url, "something that matches internal sites"),"internal", 1=1, "external") | eval external=0, internal=0 | stats sum by siteName&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 11:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-var-by-quot-a-list-of-values-within-a-field-quot/m-p/412964#M119040</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-21T11:54:18Z</dc:date>
    </item>
  </channel>
</rss>

