<?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: count two status by resource name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98888#M25514</link>
    <description>&lt;P&gt;use the chart command :&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Chart"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Chart&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=access Status=404 OR Status=200 | chart count over Resource by Status&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jan 2013 20:36:51 GMT</pubDate>
    <dc:creator>yannK</dc:creator>
    <dc:date>2013-01-24T20:36:51Z</dc:date>
    <item>
      <title>count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98886#M25512</link>
      <description>&lt;P&gt;hey All, &lt;/P&gt;

&lt;P&gt;I'd like to produce a table or chart similar to the following:&lt;/P&gt;

&lt;P&gt;----------          count(status=202)         count(Status=404)&lt;BR /&gt;
Resource 1               25                         10&lt;BR /&gt;
Resource 2               50                          5&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;I'm getting close to what I want using this query; &lt;BR /&gt;
sourcetype=access Status=404 OR Status=200 | stats c(Status) by Resource&lt;/P&gt;

&lt;P&gt;but this gives me a chart that counts up all the caught status (202 and 404) in a single column. &lt;/P&gt;

&lt;P&gt;Any ideas how I can seperate the 200s into seperate columns? &lt;/P&gt;

&lt;P&gt;Extra credit: can I create a search that would isolate a time frame in which both  200s and 404s occur? For example, when the Splunk Natural Language release comes along, I'd want to say:&lt;BR /&gt;
"Splunk, show me the most recent hour in which &lt;RESOURCE&gt; experienced both 200s and 404s"&lt;/RESOURCE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 20:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98886#M25512</guid>
      <dc:creator>dreeck</dc:creator>
      <dc:date>2013-01-24T20:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98887#M25513</link>
      <description>&lt;P&gt;Side note: if I use this&lt;BR /&gt;
sourcetype=access Status=404 OR Status=200 | stats c(Status=200), c(Status=404) by Resource&lt;/P&gt;

&lt;P&gt;I get the chart format I want, but the counts are always zero.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 20:33:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98887#M25513</guid>
      <dc:creator>dreeck</dc:creator>
      <dc:date>2013-01-24T20:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98888#M25514</link>
      <description>&lt;P&gt;use the chart command :&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Chart"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Chart&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=access Status=404 OR Status=200 | chart count over Resource by Status&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 20:36:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98888#M25514</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-01-24T20:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98889#M25515</link>
      <description>&lt;P&gt;Awesome, I didn't know about Over. &lt;/P&gt;

&lt;P&gt;How can I restrict the chart to resources with counts greater than 0?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 20:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98889#M25515</guid>
      <dc:creator>dreeck</dc:creator>
      <dc:date>2013-01-24T20:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98890#M25516</link>
      <description>&lt;P&gt;This'll do it :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=access Status=404 OR Status=200 | chart count over Resource by Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype="splunkd_access" earliest=-1d | chart count over uri by status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To split this out into hourly data (using the example)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype="splunkd_access" earliest=-1d
| bin _time span=1h
| eval uri=_time.";".uri
| chart count over uri by status
| rex field=uri "(?&amp;lt;_time&amp;gt;\d+);(?&amp;lt;uri&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To look for when 2 fields have data add (for example)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where $404$&amp;gt;0 AND $200$&amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(note I have to wrap the fields in $ signs so splunk knows these are field names and not raw numbers)&lt;/P&gt;

&lt;P&gt;Now you can &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| sort - _time | head 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To get the latest.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 21:01:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98890#M25516</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-24T21:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98891#M25517</link>
      <description>&lt;P&gt;Awesome, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 21:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98891#M25517</guid>
      <dc:creator>dreeck</dc:creator>
      <dc:date>2013-01-24T21:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: count two status by resource name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98892#M25518</link>
      <description>&lt;P&gt;Difficult to do after the chart, because the fields names are replaced by the fied values after the chart.&lt;/P&gt;

&lt;P&gt;So you have to use a stats before, filter, then add a chart after for presentation.&lt;BR /&gt;
&lt;CODE&gt;sourcetype=access Status=404 OR Status=200 &lt;BR /&gt;
| stats count by Resource Status&lt;BR /&gt;
| where count &amp;gt;0&lt;BR /&gt;
| chart values(count) over Resource by Status&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 22:08:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-two-status-by-resource-name/m-p/98892#M25518</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-01-24T22:08:12Z</dc:date>
    </item>
  </channel>
</rss>

