<?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 display count of related events in a column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418355#M120306</link>
    <description>&lt;P&gt;@rkassabov&lt;/P&gt;

&lt;P&gt;your welcome. Thank you..&lt;BR /&gt;
Happy Splunking &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2018 04:06:04 GMT</pubDate>
    <dc:creator>Shan</dc:creator>
    <dc:date>2018-05-29T04:06:04Z</dc:date>
    <item>
      <title>How to display count of related events in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418352#M120303</link>
      <description>&lt;P&gt;I am trying to get the following query to show the related_vulnerabilities as a count column, instead of showing all the related vulns.&lt;/P&gt;

&lt;P&gt;My query without the count produces this result:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5040iBEB965A67B365A15/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;However after adding the logic for the count, I get this result:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5041iD2CB7767E425782B/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This is what my query looks like with the added stats count statement:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx md_type=xxx
info_owner_orgID="xxx"
| dedup id 

| rex mode=sed field="related_vulnerabilities" "s/[][]//g"
| rex mode=sed field="related_vulnerabilities" "s/'//g"
| makemv delim="," related_vulnerabilities
| eval RV = mvindex(related_vulnerabilities,0)

| stats count(related_vulnerabilities) by info_name

| table info_name info_class related_vulnerabilities
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I add a count column that shows the count of related_vulnerabilities?&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 06:20:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418352#M120303</guid>
      <dc:creator>rkassabov</dc:creator>
      <dc:date>2018-05-25T06:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count of related events in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418353#M120304</link>
      <description>&lt;P&gt;@ rkassabov &lt;/P&gt;

&lt;P&gt;you need to provide a alias name for the filed in stats and use that alias name in table .. While using stats, If you want to display any field in table. Then you need to do some operation or at-least you need to simply use that field in stats by using function like &lt;STRONG&gt;values&lt;/STRONG&gt;(distinct values will be shown ) or &lt;STRONG&gt;list&lt;/STRONG&gt;(duplicate values also shown ) as i shown below (info_class).  I have used eval for showcasing the data. you dont want to consider it .. you can use stats and table in ur query.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Sample for ur understanding&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;|makeresults&lt;BR /&gt;&lt;BR /&gt;
| eval related_vulnerabilities="values" &lt;BR /&gt;
| eval info_name="search"&lt;BR /&gt;&lt;BR /&gt;
| eval info_class="class name"&lt;BR /&gt;
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class  by info_name&lt;BR /&gt;
| table info_name info_class related_vulnerabilities&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Use This Query&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;index=xxx md_type=xxx&lt;BR /&gt;
 info_owner_orgID="xxx"&lt;BR /&gt;
 | dedup id &lt;BR /&gt;
  | rex mode=sed field="related_vulnerabilities" "s/[][]//g"&lt;BR /&gt;
 | rex mode=sed field="related_vulnerabilities" "s/'//g"&lt;BR /&gt;
 | makemv delim="," related_vulnerabilities&lt;BR /&gt;
 | eval RV = mvindex(related_vulnerabilities,0)&lt;BR /&gt;
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class  by info_name&lt;BR /&gt;
| table info_name info_class related_vulnerabilities&lt;/P&gt;

&lt;P&gt;once u got what u needed .. please accept the answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ..  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418353#M120304</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2020-09-29T19:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count of related events in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418354#M120305</link>
      <description>&lt;P&gt;Brilliant, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 07:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418354#M120305</guid>
      <dc:creator>rkassabov</dc:creator>
      <dc:date>2018-05-25T07:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count of related events in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418355#M120306</link>
      <description>&lt;P&gt;@rkassabov&lt;/P&gt;

&lt;P&gt;your welcome. Thank you..&lt;BR /&gt;
Happy Splunking &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 04:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-of-related-events-in-a-column/m-p/418355#M120306</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2018-05-29T04:06:04Z</dc:date>
    </item>
  </channel>
</rss>

