<?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 Get pattern count in a log line in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-pattern-count-in-a-log-line/m-p/63512#M180296</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have log lines that looks like this&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Fetching documents "FileName1.doc", "FileName2.xls", "FileName10.jpg", FileName342.docx" &amp;lt;ProcessID&amp;gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;My goal is to find how many file names there are per ProcessID, given that each name is quoted and separated by a comma and a space. How can I accomplish that?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2013 22:08:17 GMT</pubDate>
    <dc:creator>lain179</dc:creator>
    <dc:date>2013-06-13T22:08:17Z</dc:date>
    <item>
      <title>Get pattern count in a log line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-pattern-count-in-a-log-line/m-p/63512#M180296</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have log lines that looks like this&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Fetching documents "FileName1.doc", "FileName2.xls", "FileName10.jpg", FileName342.docx" &amp;lt;ProcessID&amp;gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;My goal is to find how many file names there are per ProcessID, given that each name is quoted and separated by a comma and a space. How can I accomplish that?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2013 22:08:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-pattern-count-in-a-log-line/m-p/63512#M180296</guid>
      <dc:creator>lain179</dc:creator>
      <dc:date>2013-06-13T22:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get pattern count in a log line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-pattern-count-in-a-log-line/m-p/63513#M180297</link>
      <description>&lt;P&gt;If the file names are bound by the phrase "Fetching Documents" and the "&amp;lt;ProcessID&amp;gt;", then capturing the names, converting to a list and then enumerating the items in that list will do.&lt;/P&gt;

&lt;P&gt;At search time you can catch the data with a runtime extraction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="answers-1371175757" | rex field=_raw "Fetching\sdocuments\s(?&amp;lt;FileNames&amp;gt;.+?)\s+\&amp;lt;(?&amp;lt;ProcessID&amp;gt;.+?)\&amp;gt;" | table FileNames ProcessID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are, of course, multiple ways of doing that efficiently and you can always improve on that method. This will render something like this:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled201.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Instead of a table use makemv to convert the field to a list -ensure you delimit the members of the list by a comma.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makemv delim="," FileNames
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point, enumerate using stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count(FileNames) AS count by ProcessID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All together, it should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="answers-1371175757" | rex field=_raw "Fetching\sdocuments\s(?&amp;lt;FileNames&amp;gt;.+?)\s+\&amp;lt;(?&amp;lt;ProcessID&amp;gt;.+?)\&amp;gt;" | makemv delim="," FileNames | stats count(FileNames) AS count by ProcessID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And, it should produce something like this:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled202.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;gc&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2013 02:36:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-pattern-count-in-a-log-line/m-p/63513#M180297</guid>
      <dc:creator>Gilberto_Castil</dc:creator>
      <dc:date>2013-06-14T02:36:10Z</dc:date>
    </item>
  </channel>
</rss>

