<?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 Query, Stats Command for Number of Occurences of a String in a Log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626273#M217666</link>
    <description>&lt;P&gt;Seems to be the case that it works as I assumed. Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 22:46:57 GMT</pubDate>
    <dc:creator>dtarnaine920</dc:creator>
    <dc:date>2023-01-06T22:46:57Z</dc:date>
    <item>
      <title>How to create a search for Stats Command for Number of Occurences of a String in a Log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626224#M217652</link>
      <description>&lt;P&gt;Hi, I'm trying to come up with a query to generate the count of strings in a json field in a log, across all events.&amp;nbsp;&lt;BR /&gt;For example, say I have a search that displays say, 100,000 logs, with each log containing some JSON structured string [{"First Name": "Bob", "DOB":"1/1/1900", ..."Vendor":"Walmart"}]&lt;/P&gt;
&lt;P&gt;I want to generate a table that lists all the unique Vendor values, and the count of the values. Something like,&lt;/P&gt;
&lt;P&gt;Vendor | Count&lt;/P&gt;
&lt;P&gt;Walmart&amp;nbsp; &amp;nbsp;5&lt;/P&gt;
&lt;P&gt;Target&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;ToysRUs.&amp;nbsp; &amp;nbsp;100&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;Is something like this possible?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:29:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626224#M217652</guid>
      <dc:creator>dtarnaine920</dc:creator>
      <dc:date>2023-01-06T22:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query, Stats Command for Number of Occurences of a String in a Log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626258#M217662</link>
      <description>&lt;P&gt;Yes, it's possible.&amp;nbsp; I'll assume your next question will be about *how* it is possible.&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;First, extract the vendor field from each event.&amp;nbsp; There are a couple of ways to do that, but I like rex.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "Vendor\\\":\\\"(?&amp;lt;Vendor&amp;gt;[^\"]+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Yes, the triple-backslashes are intentional and necessary.)&lt;/P&gt;&lt;P&gt;Then count the vendor names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by Vendor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 21:13:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626258#M217662</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-01-06T21:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query, Stats Command for Number of Occurences of a String in a Log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626263#M217663</link>
      <description>&lt;P&gt;Wow, that's awesome! Thanks for the help! As a followup, is this able to be extended to extract more than just that one field? I'm seeing in other splunk community posts that rex is able to be used for multiple extractions, but I'm not too well aquainted with regular expressions.&lt;/P&gt;&lt;P&gt;For instance, extracting both the First Name and the Vendor as an example, that would produce something like&lt;/P&gt;&lt;P&gt;Name, Vendor | Count&lt;/P&gt;&lt;P&gt;Bob, Walmart&amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;Billy, Walmart&amp;nbsp; &amp;nbsp; &amp;nbsp;13&lt;/P&gt;&lt;P&gt;Blake, Target&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13&lt;/P&gt;&lt;P&gt;Billy, Target&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&lt;/P&gt;&lt;P&gt;The multiple backslashes and quotations are throwing me off in terms of how to add additional fields for extraction.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 21:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626263#M217663</guid>
      <dc:creator>dtarnaine920</dc:creator>
      <dc:date>2023-01-06T21:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query, Stats Command for Number of Occurences of a String in a Log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626269#M217664</link>
      <description>&lt;P&gt;The easiest way to extract multiple fields is to use multiple &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; commands.&amp;nbsp; It's often more efficient to do that than to create a complex regex that extracts multiple fields in one go.&amp;nbsp; It's easier to maintain and more flexible (in case field order changes), too.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626269#M217664</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-01-06T22:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query, Stats Command for Number of Occurences of a String in a Log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626270#M217665</link>
      <description>&lt;P&gt;Would that be piping the original rex command provided into another rex command with the new field I want, prior to piping into the stats count command with a by that comma separates the two fields I want?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:17:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626270#M217665</guid>
      <dc:creator>dtarnaine920</dc:creator>
      <dc:date>2023-01-06T22:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query, Stats Command for Number of Occurences of a String in a Log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626273#M217666</link>
      <description>&lt;P&gt;Seems to be the case that it works as I assumed. Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-for-Stats-Command-for-Number-of/m-p/626273#M217666</guid>
      <dc:creator>dtarnaine920</dc:creator>
      <dc:date>2023-01-06T22:46:57Z</dc:date>
    </item>
  </channel>
</rss>

