<?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 Extract string and separate results by different strings in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132181#M36038</link>
    <description>&lt;P&gt;I have been looking for days for an answer to this on Splunk answers and elsewhere.&lt;BR /&gt;&lt;BR /&gt;
I have a query like this: &lt;BR /&gt;
sourcetype="*-xxx01" (XXX0014 OR XXX0019 OR XXX0018 OR XXX0015)  | timechart span=30m COUNT&lt;/P&gt;

&lt;P&gt;XXX014, XXX019, XXX018, XXX015 are all strings in each log entry (they are KPIs) (its either XXX014 or XXX019 or XXX018 or XXX015 obviously in each log entry).  I am trying to get results returned that are in columns  so I can separate the results based on these KPIs.  This would be so easy if they were part of a field.  I could use "by fieldname" but these aren't part of a field.  I was hoping I could do "COUNT by sum(XXX0014) sum(XXX019) sum(XXX018) sum(XXX015)" but that doesn't work.  Below is an example of a log entry.  Any help would be greatly appreciated!!  (ultimate goal is a timechart bar graph that separates by different string values in each span)&lt;/P&gt;

&lt;P&gt;2014-04-15 15:00:48,056 [INFO] [UUID=XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX subNo=XXXXXXXXXXX yhn=000000000] XXX0014: Ignored notification grant. cause=IgnoreNotificationException Ignore Grant Notification &lt;/P&gt;

&lt;P&gt;Where it says XXX0014... that is the value I want to separate my results with. &lt;/P&gt;</description>
    <pubDate>Tue, 15 Apr 2014 15:04:10 GMT</pubDate>
    <dc:creator>EricLloyd79</dc:creator>
    <dc:date>2014-04-15T15:04:10Z</dc:date>
    <item>
      <title>Extract string and separate results by different strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132181#M36038</link>
      <description>&lt;P&gt;I have been looking for days for an answer to this on Splunk answers and elsewhere.&lt;BR /&gt;&lt;BR /&gt;
I have a query like this: &lt;BR /&gt;
sourcetype="*-xxx01" (XXX0014 OR XXX0019 OR XXX0018 OR XXX0015)  | timechart span=30m COUNT&lt;/P&gt;

&lt;P&gt;XXX014, XXX019, XXX018, XXX015 are all strings in each log entry (they are KPIs) (its either XXX014 or XXX019 or XXX018 or XXX015 obviously in each log entry).  I am trying to get results returned that are in columns  so I can separate the results based on these KPIs.  This would be so easy if they were part of a field.  I could use "by fieldname" but these aren't part of a field.  I was hoping I could do "COUNT by sum(XXX0014) sum(XXX019) sum(XXX018) sum(XXX015)" but that doesn't work.  Below is an example of a log entry.  Any help would be greatly appreciated!!  (ultimate goal is a timechart bar graph that separates by different string values in each span)&lt;/P&gt;

&lt;P&gt;2014-04-15 15:00:48,056 [INFO] [UUID=XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX subNo=XXXXXXXXXXX yhn=000000000] XXX0014: Ignored notification grant. cause=IgnoreNotificationException Ignore Grant Notification &lt;/P&gt;

&lt;P&gt;Where it says XXX0014... that is the value I want to separate my results with. &lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 15:04:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132181#M36038</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2014-04-15T15:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string and separate results by different strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132182#M36039</link>
      <description>&lt;P&gt;The easiest would be to get them extracted into a field, say &lt;CODE&gt;KPI&lt;/CODE&gt;, and do a &lt;CODE&gt;timechart count by KPI&lt;/CODE&gt;. For your sample event, you should be able to temporarily extract the field like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | rex "\]\s+(?&amp;lt;KPI&amp;gt;\w+):" | timechart count by KPI
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that works, move the extraction to the config (Settings -&amp;gt; Fields -&amp;gt; Field Extractions) so you can drop the &lt;CODE&gt;rex&lt;/CODE&gt; call from the search. If your other KPIs are in differently looking events you can define multiple extractions that all yield the same field name.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 15:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132182#M36039</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-15T15:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string and separate results by different strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132183#M36040</link>
      <description>&lt;P&gt;This worked beautifully... thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2014 16:19:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-string-and-separate-results-by-different-strings/m-p/132183#M36040</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2014-04-15T16:19:56Z</dc:date>
    </item>
  </channel>
</rss>

