<?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: how to correct/modify x-axis in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331655#M98645</link>
    <description>&lt;P&gt;If your index has event time (ie. _time) same as your date field in the question you have provided you can use timechart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy
| timechart span=1d count
| fieldformat _time=strftime(_time,"%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If _time field is not same as date and date field is string time, you need to convert the same to epoch and use chart instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy
| eval date=strptime(date,""%d/%m/%Y %H:%M:%s")
| chart span=1d count over date
| fieldformat date=strftime(date,"%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Ideally with timechart and chart empty time bucket should be filled with 0 when using count. If not you can always pipe fillnull command at the end i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull value=0 count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With chart or timechart &lt;STRONG&gt;span=1d&lt;/STRONG&gt; is used to created time bucket for 1 day as per your need. Final &lt;STRONG&gt;fieldformat&lt;/STRONG&gt; command formats the epoch time field to show only date as string and retains underlying time field as epoch time.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2017 19:11:37 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-06-09T19:11:37Z</dc:date>
    <item>
      <title>how to correct/modify x-axis</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331653#M98643</link>
      <description>&lt;P&gt;Dears, &lt;/P&gt;

&lt;P&gt;I have two columns , first one is called ticket and second columns is date as below&lt;BR /&gt;
Ticket  date &lt;BR /&gt;
AS123  6/6/2017 12:12:12&lt;BR /&gt;
AS345  1/6/29017 11:10:12&lt;BR /&gt;
AS564  2/6/2017 9:0:10&lt;/P&gt;

&lt;P&gt;I would like to draw a graph where the x-axis display number of days from 1 to 31 and Y-axis represent number of tickets per each day &lt;/P&gt;

&lt;P&gt;i have generate the below query :&lt;BR /&gt;
index=xxx source=yyy |table "ticket","date" | eval fields=split('date',"/") |eval num=mvindex(fields,0)| table "ticket","num" |chart  count by num&lt;/P&gt;

&lt;P&gt;but the problem is in the x-axis as it displayed only days where there is a ticket only , it doesn't mention for example that at 3rd of June there wasn't any tickets as below&lt;BR /&gt;
num  count&lt;BR /&gt;
1        1&lt;BR /&gt;
2        1&lt;BR /&gt;
6        1&lt;/P&gt;

&lt;P&gt;What i would like to get &lt;BR /&gt;
1        1&lt;BR /&gt;
2        1&lt;BR /&gt;
3        0&lt;BR /&gt;
6        0&lt;BR /&gt;
5        0&lt;BR /&gt;
6        1&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:17:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331653#M98643</guid>
      <dc:creator>wessam</dc:creator>
      <dc:date>2017-06-09T15:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to correct/modify x-axis</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331654#M98644</link>
      <description>&lt;P&gt;You can try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy |table "ticket","date" | rex field=date "^\d+\/(?&amp;lt;num&amp;gt;\d+)" |chart count by num | makecontinuous | fillnull value=0 count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Problem with above is it'll fill the missing numbers between the smallest and largest value of &lt;CODE&gt;num&lt;/CODE&gt; but not full 1 to 31 (if there was no ticket on 1, there won't be any row for that). To overcome that you can try below one.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy |table "ticket","date" | rex field=date "^\d+\/(?&amp;lt;num&amp;gt;\d+)" |chart count by num | append [| gentimes start=-1 | eval num=mvrange(1,32) | table num | mvexpand num | eval count=0 ]
| stats max(count) as count by num
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 16:36:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331654#M98644</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-09T16:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to correct/modify x-axis</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331655#M98645</link>
      <description>&lt;P&gt;If your index has event time (ie. _time) same as your date field in the question you have provided you can use timechart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy
| timechart span=1d count
| fieldformat _time=strftime(_time,"%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If _time field is not same as date and date field is string time, you need to convert the same to epoch and use chart instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xxx source=yyy
| eval date=strptime(date,""%d/%m/%Y %H:%M:%s")
| chart span=1d count over date
| fieldformat date=strftime(date,"%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Ideally with timechart and chart empty time bucket should be filled with 0 when using count. If not you can always pipe fillnull command at the end i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull value=0 count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With chart or timechart &lt;STRONG&gt;span=1d&lt;/STRONG&gt; is used to created time bucket for 1 day as per your need. Final &lt;STRONG&gt;fieldformat&lt;/STRONG&gt; command formats the epoch time field to show only date as string and retains underlying time field as epoch time.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 19:11:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331655#M98645</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-06-09T19:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to correct/modify x-axis</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331656#M98646</link>
      <description>&lt;P&gt;You need &lt;CODE&gt;makecontinuous&lt;/CODE&gt;:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Makecontinuous"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Makecontinuous&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="1,1 2,1 6,1"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?&amp;lt;num&amp;gt;.*),(?&amp;lt;count&amp;gt;.*)$"
| fields - _*

| rename COMMENT AS "Everything above creates sample event data; everything below is your solution"

| makecontinuous num span=1
| fillnull value="0"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 04:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-correct-modify-x-axis/m-p/331656#M98646</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-12T04:08:01Z</dc:date>
    </item>
  </channel>
</rss>

