<?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: Counting Particular Characters Within a Field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54088#M13206</link>
    <description>&lt;P&gt;This didn't see to work. It gave me a separate column for the colons, but the count wasn't correct.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2012 18:09:03 GMT</pubDate>
    <dc:creator>henryt1</dc:creator>
    <dc:date>2012-12-04T18:09:03Z</dc:date>
    <item>
      <title>Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54085#M13203</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I need to put together a report that involves counting certain characters in a field within Splunk. For instance, my query looks like "... | stats count by q". What I'm returned with the field "q" might look like either of the following:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;(summary:(superhydrophob*%20OR%20superoleophob*))%20AND%20(summary:(fabric%20OR%20hair%20OR%20skin))%20AND%20(publicationdate:[2007%20TO%202012])&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;%28summary%3A%28machine%20AND%20learning%20AND%20error%29%29%20AND%20%28publicationdate%3A%5B2007%20TO%202012%5D%29%20AND%20%28country%3AUS%29&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Within those two results I'm interested in how many total colons there are, so because of HTML encoding I would be interested in both &lt;STRONG&gt;":" as well as "%3A"&lt;/STRONG&gt;. So the total amount of characters with these two results that I would like to get back would be 6.&lt;/P&gt;

&lt;P&gt;Is there anyway I could do this within Splunk? Right now I have to export and use Excel, which is extremely time consuming. Any help would be greatly appreciated, thanks in advance.&lt;/P&gt;

&lt;P&gt;-Tyler&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:54:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54085#M13203</guid>
      <dc:creator>henryt1</dc:creator>
      <dc:date>2020-09-28T12:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54086#M13204</link>
      <description>&lt;P&gt;This should help.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/28276/count-of-character-in-field"&gt;http://splunk-base.splunk.com/answers/28276/count-of-character-in-field&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Details on the functions of eval here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 17:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54086#M13204</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2012-12-04T17:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54087#M13205</link>
      <description>&lt;P&gt;Rex and eval might be able to help in this case. My approach first decodes the q field, so you only have to work with one format of colon. Then, you can count the number of matches for a single colon. &lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your_search | eval dq = urldecode(q)|rex max_match=100 field=dq "(?&amp;lt;colons&amp;gt;:)"|stats count(colons) as "Number of Total colons" by dq&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 17:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54087#M13205</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-12-04T17:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54088#M13206</link>
      <description>&lt;P&gt;This didn't see to work. It gave me a separate column for the colons, but the count wasn't correct.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 18:09:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54088#M13206</guid>
      <dc:creator>henryt1</dc:creator>
      <dc:date>2012-12-04T18:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54089#M13207</link>
      <description>&lt;P&gt;How far off was it? and the count is per distinct url. If you just want total, then do "count(colons)". You can also try setting max_match to 0, which means unlimited. But I'm not sure if you have more than 100 colons in a line or not. &lt;BR /&gt;
I did notice that because you have "%20" (a space), the q did not extract properly on my test. So for the colons it sees, it sees the right number, but doesn't get the whole q because of the space.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 18:24:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54089#M13207</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-12-04T18:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54090#M13208</link>
      <description>&lt;P&gt;It looks like it's still seeing the whole "q" field but the count is pretty far off.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 19:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54090#M13208</guid>
      <dc:creator>henryt1</dc:creator>
      <dc:date>2012-12-04T19:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Particular Characters Within a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54091#M13209</link>
      <description>&lt;P&gt;&lt;CODE&gt;..| eval bar = urldecode(q) | eval colCount=mvcount(split(bar,":"))-1 | stats count by q colCount | eventstats sum(colCount) as TotalColons&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2013 14:04:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Particular-Characters-Within-a-Field/m-p/54091#M13209</guid>
      <dc:creator>_d_</dc:creator>
      <dc:date>2013-10-17T14:04:36Z</dc:date>
    </item>
  </channel>
</rss>

