<?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: splunk visualization separate lines per day in a line graph in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396743#M6741</link>
    <description>&lt;P&gt;I agree.  The &lt;CODE&gt;timewrap&lt;/CODE&gt; command is great but if you are on an older release, you may need the (somewhat buggy) app:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="https://splunkbase.splunk.com/app/1645/" target="test_blank"&gt;https://splunkbase.splunk.com/app/1645/&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 11 Aug 2018 20:40:10 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-08-11T20:40:10Z</dc:date>
    <item>
      <title>splunk visualization separate lines per day in a line graph</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396741#M6739</link>
      <description>&lt;P&gt;I have a query that counts events from 30 days ago to current day but I filter the results so that I am only getting the count of events for the days in those 30 days that equals the current week day. So that if today is Wednesday, I would only see the count of events for all the Wednesdays in the last 30 days. Query is below:&lt;/P&gt;

&lt;P&gt;index=abc sourcetype=abc_proxy(Action=InteractionQueued OR Action=InteractionDequeued) earliest=-30d@d latest=now()| timechart span=1d count| eval day_of_week = lower(strftime(_time, "%A")), now = lower(strftime(now(), "%A"))| where day_of_week =  now|fields - day_of_week - now&lt;/P&gt;

&lt;P&gt;Table is kind of big because I am doing hourly breakdowns but a portion of the output looks like this:&lt;/P&gt;

&lt;P&gt;_time   count&lt;BR /&gt;
2018-07-11T00:00    7872&lt;BR /&gt;
2018-07-11T01:00    5741&lt;BR /&gt;
2018-07-11T02:00    6480&lt;BR /&gt;
2018-07-11T03:00    10198&lt;BR /&gt;
2018-07-11T04:00    11394&lt;BR /&gt;
2018-07-11T05:00    17033&lt;BR /&gt;
2018-07-11T06:00    17464&lt;BR /&gt;
2018-07-11T07:00    21961&lt;BR /&gt;
2018-07-11T08:00    28636&lt;BR /&gt;
2018-07-11T09:00    27801&lt;BR /&gt;
2018-07-11T10:00    28537&lt;BR /&gt;
2018-07-11T11:00    27996&lt;BR /&gt;
2018-07-11T12:00    24798&lt;BR /&gt;
2018-07-11T13:00    27681&lt;BR /&gt;
2018-07-11T14:00    25653&lt;BR /&gt;
2018-07-11T15:00    32204&lt;BR /&gt;
2018-07-11T16:00    32450&lt;BR /&gt;
2018-07-11T17:00    23217&lt;BR /&gt;
2018-07-11T18:00    23988&lt;BR /&gt;
2018-07-11T19:00    22152&lt;BR /&gt;
2018-07-11T20:00    19021&lt;BR /&gt;
2018-07-11T21:00    19446&lt;/P&gt;

&lt;P&gt;My problem now is with the visualization. Right now I get one continuous line for all the week days that match current weekday.  I would like to have a line graph where each day is a separate line in the graph and where each line has an hourly granularity.&lt;/P&gt;

&lt;P&gt;I wish I could attach images but I don't have enough points. BUt basically whatever the output is of the query, switch to visualization tab and select line graph.&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396741#M6739</guid>
      <dc:creator>mmdacutanan</dc:creator>
      <dc:date>2020-09-29T20:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: splunk visualization separate lines per day in a line graph</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396742#M6740</link>
      <description>&lt;P&gt;First, there is a timewrap visualization that may be exactly what you need, avoiding any of the tricks I'm going to give you.  Try that first.  &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Timewrap"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Timewrap&lt;/A&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Here's a run-anywhere example of how you could do it if that didn't work for you...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit  
| fields _time date_wday 
| rename COMMENT as "Limit to the fields you need"

| rename COMMENT as "do a preliminary stats at the granularity level you need - here 1 hour"
| bin _time   span=1h 
| stats first(date_wday) as date_wday count as hourcount by _time

| rename COMMENT as "limit to the day you want.  Here we assume that you want the day of week of the last date"
| eventstats latest(date_wday) as last_wday
| where date_wday = last_wday
| fields - last_wday

| rename COMMENT as "calculate the date, the last date, and how many weeks back each date is"
| bin _time as day span=1d 
| eventstats max(day) as maxday
| eval weeksback=(maxday-day)/604800 

| rename COMMENT as "move the date forward an even number of weeks, to match the last date"
| eval _time = _time + weeksback*604800

| rename COMMENT as "pretty up the week names, and drop unneeded fields"
| eval weeksback=if(weeksback=0,"Current ".date_wday,weeksback." Weeks Back")
| fields - day maxday
| timechart span=1h sum(hourcount) by weeksback

| rename COMMENT as "get rid of any completely empty records at the beginning or end"
| addtotals row=t col=f
| where isnotnull(Total)
| fields - Total   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Aug 2018 04:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396742#M6740</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-11T04:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: splunk visualization separate lines per day in a line graph</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396743#M6741</link>
      <description>&lt;P&gt;I agree.  The &lt;CODE&gt;timewrap&lt;/CODE&gt; command is great but if you are on an older release, you may need the (somewhat buggy) app:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="https://splunkbase.splunk.com/app/1645/" target="test_blank"&gt;https://splunkbase.splunk.com/app/1645/&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Aug 2018 20:40:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-visualization-separate-lines-per-day-in-a-line-graph/m-p/396743#M6741</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-08-11T20:40:10Z</dc:date>
    </item>
  </channel>
</rss>

