<?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: Turn stats search into chart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256381#M76754</link>
    <description>&lt;P&gt;If I understand correctly what you are asking for, you want everything in one chart correct?&lt;BR /&gt;
If that's the case simply try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode 
| eval result = if(resultCode = "0", "Success", "Failure") 
| stats count by gateway result
| eval gateway_result = gateway."-".result
| chart sum(count) as count by gateway_result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output should be as follows based on the sample you gave above:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2017i081F47FC4784CEF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2016 14:31:28 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2016-10-17T14:31:28Z</dc:date>
    <item>
      <title>Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256379#M76752</link>
      <description>&lt;P&gt;Trying to find a way to put the results of this search into a chart. I know the issue is that there are 2 fields Im trying to chart together but the results are useless unless they are tied together:&lt;BR /&gt;
&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure")  | stats count by gateway result&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;gateway           result   count&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;BRAINTREE  Failure 92&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;VERISIGN   Failure 666&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;VERISIGN   Success 7240&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What I would LIKE to do is pie chart the successes and failures by gateway.&lt;BR /&gt;
Any ideas on how to accomplish this? Its a pretty simple search so there not much to narrow down.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:17:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256379#M76752</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2016-10-17T14:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256380#M76753</link>
      <description>&lt;P&gt;How about something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure") | stats count by gateway result | eval gateway=gateway." (".result.")" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt; if it doesn't have to be a pie-chart, you can do this and use column/bar chart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure") | chart count over gateway by result
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:27:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256380#M76753</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-17T14:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256381#M76754</link>
      <description>&lt;P&gt;If I understand correctly what you are asking for, you want everything in one chart correct?&lt;BR /&gt;
If that's the case simply try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode 
| eval result = if(resultCode = "0", "Success", "Failure") 
| stats count by gateway result
| eval gateway_result = gateway."-".result
| chart sum(count) as count by gateway_result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output should be as follows based on the sample you gave above:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2017i081F47FC4784CEF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:31:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256381#M76754</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-17T14:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256382#M76755</link>
      <description>&lt;P&gt;You have two columns so it't difficult to use a pie!&lt;BR /&gt;
you could create an histogram with, gateway on x-axis and results stacked.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure") | chart count over gateway by result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256382#M76755</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-10-17T14:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256383#M76756</link>
      <description>&lt;P&gt;You have two columns so it't difficult to use a pie!&lt;BR /&gt;
you could create an histogram with, gateway on x-axis and results stacked.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure") | chart count over gateway by result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256383#M76756</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-10-17T14:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256384#M76757</link>
      <description>&lt;P&gt;Beautiful, I KNEW it was something simple I was not thinking about. Just didn't eval the results together.&lt;/P&gt;

&lt;P&gt;Thanks a bunch!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256384#M76757</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2016-10-17T14:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256385#M76758</link>
      <description>&lt;P&gt;So there are a couple of options, assuming this is for a dashboard and your gateways you are charting are fixed, you could use your existing search as a base search, and then have each panel be success/failure by gateway: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search id="base"&amp;gt;
  &amp;lt;query&amp;gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure") | stats count by gateway result&amp;lt;/query&amp;gt;
  &amp;lt;earliest&amp;gt;$time.earliest$&amp;lt;/earliest&amp;gt;
  &amp;lt;latest&amp;gt;$time.latest$&amp;lt;/latest&amp;gt;
&amp;lt;/search&amp;gt;
...
&amp;lt;chart&amp;gt;
  &amp;lt;title&amp;gt;VERISIGN activity&amp;lt;/title&amp;gt;
   &amp;lt;search base="base"&amp;gt;
      &amp;lt;query&amp;gt;where gateway="VERISIGN"| fields - gateway&amp;lt;/query&amp;gt;
    &amp;lt;/search&amp;gt;
    ...
&amp;lt;/chart&amp;gt;
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The upside of this is one search, and a view for each gateway, the downside is it assumes fairly static set of gateways and you'd have to change each time. Alternatively you could have a chart of successes and a chart of failures, with gateways being the members, but this might not be the visualization you're wanting.&lt;/P&gt;

&lt;P&gt;Another option may be to have a parent chart that shows overall volume by gateway, and a custom drilldown to see the success/failure in a separate chart... (or see volume by success/failure and drill down to gateways)... the downside here being you wind up with a click away from the single glass of pane.&lt;/P&gt;

&lt;P&gt;I'm not as familiar with Sideview Utils as I should be, but I also vaguely remember there might be a module to dynamically generate charts like this.&lt;/P&gt;

&lt;P&gt;Finally the simplest option would be to just tie together the results and show all on one piechart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=java host=*pay* api_domain=payment resultCode | eval result = if(resultCode = "0", "Success", "Failure"), gateway_result=gateway.":".result | stats count by gateway_result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR keep your search as a base and add&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval gateway_result = gateway.":".result | fields - gateway result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as postprocess search... depends on the other panels you want to drive from the base.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:38:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256385#M76758</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2016-10-17T14:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256386#M76759</link>
      <description>&lt;P&gt;Well MOSTLY. When this is run it returns &lt;BR /&gt;
a count of 1 for each gateway_result because &lt;CODE&gt;| chart count by gateway_result&lt;/CODE&gt; is only counting 1 record of each for some reason.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:26:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256386#M76759</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2020-09-29T11:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256387#M76760</link>
      <description>&lt;P&gt;Replace last &lt;CODE&gt;| chart count by gateway_result&lt;/CODE&gt; with &lt;CODE&gt;| chart sum(count) as count by gateway_result&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:46:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256387#M76760</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-17T14:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256388#M76761</link>
      <description>&lt;P&gt;Fixed my answer there as I made a mistake when copying and pasting from my lab instance&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256388#M76761</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-17T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256389#M76762</link>
      <description>&lt;P&gt;or get rid of the unnecessary stats in the middle &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:52:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256389#M76762</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2016-10-17T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256390#M76763</link>
      <description>&lt;P&gt;Ahhh had some side help, removed the &lt;CODE&gt;stats count by gateway result&lt;/CODE&gt; and got it working&lt;BR /&gt;
thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 14:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256390#M76763</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2016-10-17T14:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Turn stats search into chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256391#M76764</link>
      <description>&lt;P&gt;True. I wasn't even using a stats count in my lab as I was testing this from a CSV with inputcsv:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;gateway,result,count
BRAINTREE,Failure,92
VERISIGN,Failure,666
VERISIGN,Success,7240
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2016 15:01:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Turn-stats-search-into-chart/m-p/256391#M76764</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-17T15:01:50Z</dc:date>
    </item>
  </channel>
</rss>

