<?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 How to get stats on a string and name the string as a column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501138#M139554</link>
    <description>&lt;P&gt;ProxyName=PLB and ("/policies"  OR "/bills")   stats count by ProxyName&lt;/P&gt;

&lt;P&gt;I want the string "/policies" or "/bills" to be in a column name TYPE with the counts for each string.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 15:47:29 GMT</pubDate>
    <dc:creator>maddenm2</dc:creator>
    <dc:date>2019-12-04T15:47:29Z</dc:date>
    <item>
      <title>How to get stats on a string and name the string as a column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501138#M139554</link>
      <description>&lt;P&gt;ProxyName=PLB and ("/policies"  OR "/bills")   stats count by ProxyName&lt;/P&gt;

&lt;P&gt;I want the string "/policies" or "/bills" to be in a column name TYPE with the counts for each string.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 15:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501138#M139554</guid>
      <dc:creator>maddenm2</dc:creator>
      <dc:date>2019-12-04T15:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get stats on a string and name the string as a column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501139#M139555</link>
      <description>&lt;P&gt;Could you provide event samples that contain both types? Have you considered extracting the field "type". Please provide some more data so we can see what you're working with.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:36:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501139#M139555</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2019-12-04T16:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get stats on a string and name the string as a column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501140#M139556</link>
      <description>&lt;P&gt;Like this (upper-casing of &lt;CODE&gt;AND&lt;/CODE&gt; is VERY important):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" AND sourcetype="AndSourcetypeToo" AND ProxyName="PLB" AND ("/policies" OR "/bills")
| eval TYPE = if(searchmatch("/policies"), "policies", "bills")
| stats COUNT BY TYPE ProxyName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or better yet, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" AND sourcetype="AndSourcetypeToo" AND ProxyName="PLB" AND ("/policies" OR "/bills")
| eval TYPE = if(searchmatch("/policies"), "policies", "bills")
| chart COUNT BY TYPE ProxyName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or even better, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" AND sourcetype="AndSourcetypeToo" AND ProxyName="PLB" AND ("/policies" OR "/bills")
| stats count AS TOTAL count(eval(searchmatch("/policies"))) AS policies count(eval(searchmatch("/bills"))) AS bills BY ProxyName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 18:14:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-stats-on-a-string-and-name-the-string-as-a-column/m-p/501140#M139556</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-04T18:14:53Z</dc:date>
    </item>
  </channel>
</rss>

