<?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 Can someone provide the most simple example possible of using the chart command? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382557#M25071</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I am reading the documentation here: &lt;A href="http://docs.splunk%5Bdot%5Dcom/Documentation/Splunk/7.1.2/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk[dot]com/Documentation/Splunk/7.1.2/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I was hoping that after reading through this I would be able to use some of these functions/commands. I tried to Google to find simpler examples but did not come up with anything. Can someone please provide the most simple example possible of using the &lt;STRONG&gt;chart&lt;/STRONG&gt; command? &lt;/P&gt;

&lt;P&gt;For instance I am trying to find the number of errors for each month. I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="localhost" sourcetype=alert_DBMS | chart values(date_month) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does not show anything useful though. Any tips splunk land? &lt;/P&gt;

&lt;P&gt;I also have this search which does show a chart but the chart is useless. The chart is shown below in Figure 1. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="localhost" sourcetype=alert_DBMS | chart count by date_hour, date_wday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Useless chart returned by my dumb splunk query"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5469i5E97A54E82A2D5C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Useless chart returned by my dumb splunk query" alt="Useless chart returned by my dumb splunk query" /&gt;&lt;/span&gt;&lt;BR /&gt;
&lt;EM&gt;Figure 1&lt;/EM&gt;: Useless chart created with very limited SPL skills&lt;/P&gt;

&lt;P&gt;Finally, does anyone have a link to more readable documentation? I think the documentation is info overload with links to more links to more links... a confusing frustrating experience.  A &lt;EM&gt;Head First&lt;/EM&gt; type of documentation website would be ideal. &lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;rogue_carrot&lt;/P&gt;</description>
    <pubDate>Wed, 01 Aug 2018 21:59:25 GMT</pubDate>
    <dc:creator>rogue_carrot</dc:creator>
    <dc:date>2018-08-01T21:59:25Z</dc:date>
    <item>
      <title>Can someone provide the most simple example possible of using the chart command?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382557#M25071</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I am reading the documentation here: &lt;A href="http://docs.splunk%5Bdot%5Dcom/Documentation/Splunk/7.1.2/SearchReference/CommonStatsFunctions"&gt;http://docs.splunk[dot]com/Documentation/Splunk/7.1.2/SearchReference/CommonStatsFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I was hoping that after reading through this I would be able to use some of these functions/commands. I tried to Google to find simpler examples but did not come up with anything. Can someone please provide the most simple example possible of using the &lt;STRONG&gt;chart&lt;/STRONG&gt; command? &lt;/P&gt;

&lt;P&gt;For instance I am trying to find the number of errors for each month. I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="localhost" sourcetype=alert_DBMS | chart values(date_month) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does not show anything useful though. Any tips splunk land? &lt;/P&gt;

&lt;P&gt;I also have this search which does show a chart but the chart is useless. The chart is shown below in Figure 1. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="localhost" sourcetype=alert_DBMS | chart count by date_hour, date_wday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Useless chart returned by my dumb splunk query"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5469i5E97A54E82A2D5C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Useless chart returned by my dumb splunk query" alt="Useless chart returned by my dumb splunk query" /&gt;&lt;/span&gt;&lt;BR /&gt;
&lt;EM&gt;Figure 1&lt;/EM&gt;: Useless chart created with very limited SPL skills&lt;/P&gt;

&lt;P&gt;Finally, does anyone have a link to more readable documentation? I think the documentation is info overload with links to more links to more links... a confusing frustrating experience.  A &lt;EM&gt;Head First&lt;/EM&gt; type of documentation website would be ideal. &lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;rogue_carrot&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 21:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382557#M25071</guid>
      <dc:creator>rogue_carrot</dc:creator>
      <dc:date>2018-08-01T21:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone provide the most simple example possible of using the chart command?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382558#M25072</link>
      <description>&lt;P&gt;I'm going to give you what you asked for, but I think you really just need to understand all the different visualizations that are available.  Your particular search would be much better off using the basic "timechart" command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host="localhost" sourcetype=alert_DBMS | timechart count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you had more than one value for host (or some other field) you could get multiple lines on a single timechart...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=* sourcetype=alert_DBMS | timechart count by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, the commands that can produce good output for making visualizations (various kinds of charts) are : &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;timechart&lt;/CODE&gt;, which we've shown you above and is useful for a time-based visualization; &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;stats&lt;/CODE&gt;, which is the first tool in your tool belt,  and which can chew up data in pretty much any way you can imagine, and which throws away the underlying events, so anything that you don't explicitly use in the command is GONE;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eventstats&lt;/CODE&gt;, which does the same thing as stats but then adds the relevant results to each event rather than throwing the events away;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;streamstats&lt;/CODE&gt;, which uses the same aggregate commands as &lt;CODE&gt;stats&lt;/CODE&gt; but processes the records in the order they arrive, and only sees what has gone before, and which adds the relevant results to each event rather than throwing the events away;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;chart&lt;/CODE&gt;, which produces a matrix by two fields, with the first field named giving the values for each row, and the second field named giving the values for the column.&lt;/P&gt;

&lt;P&gt;Notice, the &lt;CODE&gt;stats&lt;/CODE&gt; family can have any number of &lt;CODE&gt;by&lt;/CODE&gt; fields, but chart must have only one or two. For &lt;CODE&gt;timechart&lt;/CODE&gt; you get &lt;CODE&gt;_time&lt;/CODE&gt; and any number of calculated fields.  It also has some other bells and whistles but I don't want to confuse you with that right now.&lt;/P&gt;

&lt;P&gt;On to the &lt;CODE&gt;chart&lt;/CODE&gt; example you asked for.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Here's a simple, run-anywhere search that will produce a decent chart...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval mydata="sam:[oranges,5][bananas,7][grapes,37][apples,19]!!!!david:[oranges,12][grapes,15][pears,19]!!!!olivia:[guanabanas,3][bananas,4][papayas,2][apples,2]" 
| makemv delim="!!!!" mydata 
| mvexpand mydata
| rex field=mydata "^(?&amp;lt;name&amp;gt;\w*):"
| rex field=mydata max_match=0 "\[(?&amp;lt;fruit&amp;gt;\w*,\w*)\]"
| mvexpand fruit
| rex field=fruit "^(?&amp;lt;fruitname&amp;gt;\w*),(?&amp;lt;fruitcount&amp;gt;\w*)$"
| table name fruitname fruitcount
| rename COMMENT as "everything above this just creates test data"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sam     oranges     5
sam     bananas     7
sam     grapes     37
sam     apples     19
david   oranges    12
david   grapes     15
david   pears      19
olivia  guanabanas  3
olivia  bananas     4
olivia  papayas     2
olivia  apples      2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the chart command...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart sum(fruitcount) over fruitname by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;fruitname   david   olivia   sam
apples                  2     19
bananas                 4      7
grapes         15             37
guanabanas              3    
oranges        12              5
papayas                 2    
pears          19               
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see, the &lt;CODE&gt;chart&lt;/CODE&gt; command actually produces a particular kind of table, with one field values along the top to label each column, and one along the left side to label each row.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Now, if you want a pie chart, you could do &lt;/P&gt;

&lt;P&gt;... how many total fruits each person has...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(fruitcount) as totalfruits by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... how many of each fruit there are...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(fruitcount) as totalfruits by fruitname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... how many different fruit each person has&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats dc(fruitname) as fruittypes by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... how many different people have each fruit&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats dc(name) as peoplecount by fruitname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... the highest number of each fruits that any person has&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(fruitcount) as maxcount by fruitname 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And any of the above could be switched from a pie chart to a bar chart and will work just fine.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 04:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382558#M25072</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-02T04:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone provide the most simple example possible of using the chart command?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382559#M25073</link>
      <description>&lt;P&gt;@ rogue_carrot &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=06/23/2014 end=07/23/2014 increment=1d  | chart eval(sum(starttime)/max(endtime)) as calculation max(starttime) min(starttime)   BY starthuman
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I believe you have already taken look into below url. If not please take a look into it .. And let me know what functionality in this chart you need to us in your query .. So i can help you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; . &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Chart"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Chart&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 04:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382559#M25073</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2018-08-02T04:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone provide the most simple example possible of using the chart command?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382560#M25074</link>
      <description>&lt;P&gt;Thank-you for providing the in-depth answer. I went through it and learned some stuff. I was hoping for even simpler ways to use the chart command but I think you have some useful examples. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 22:18:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382560#M25074</guid>
      <dc:creator>rogue_carrot</dc:creator>
      <dc:date>2018-08-14T22:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone provide the most simple example possible of using the chart command?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382561#M25075</link>
      <description>&lt;P&gt;Thank-you for providing an example. I copy and pasted your SPL into my Splunk instance and was surprised that some results were returned. Your SPL is way over my head... Something simpler would be very appreciated. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 22:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Can-someone-provide-the-most-simple-example-possible-of-using/m-p/382561#M25075</guid>
      <dc:creator>rogue_carrot</dc:creator>
      <dc:date>2018-08-14T22:22:37Z</dc:date>
    </item>
  </channel>
</rss>

