<?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 do you return a table of a value by a department and then display it by how many days ago it occurred ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408403#M117879</link>
    <description>&lt;P&gt;I appreciate all your help! You were wonderful. &lt;/P&gt;</description>
    <pubDate>Fri, 18 Jan 2019 22:32:15 GMT</pubDate>
    <dc:creator>ryhluc01</dc:creator>
    <dc:date>2019-01-18T22:32:15Z</dc:date>
    <item>
      <title>How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408395#M117871</link>
      <description>&lt;P&gt;I need to return a table of a value by a department and then display it by how many days ago it occurred  (Very Important, Please Help)  Thank you!&lt;/P&gt;

&lt;P&gt;I need a table of the average AMI age by the department for the past 5 days (today included) rounded to the 10th power. &lt;/P&gt;

&lt;P&gt;I'm having problems trying to make this eval return the day I want based on the AMI avg calculation. &lt;/P&gt;

&lt;P&gt;This is what I have so far: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Foo "DataStringValue"="AMI Age"  
| stats dedup_splitvals=t count AS "Count of 1530130937.1457581"  by Department.StringValue, ami_date.StringValue 
| sort Department.StringValue 
| fields - _span  
| rename ami_date.StringValue AS Date, Department.StringValue AS Vertical, instance_id.StringValue AS Instance_ID  
| eval C=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q") 
| eval A=((now()-C)/86400) 
| stats avg(A)  as Age by Vertical
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ive tried adding:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Time=(split(Date,"T")) 
| eval t=mvindex(Time,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've also tried: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval  "Average Age Yesterday"=relative_time(now(),"-1d@d")
| eval  "Average Age 2 days ago"=relative_time(now(), "-2d@d")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 19:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408395#M117871</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-17T19:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408396#M117872</link>
      <description>&lt;P&gt;By using &lt;CODE&gt;stats&lt;/CODE&gt; your dropping time in line 2. If you want the average of the entire 5 day period, you can put it all in a single bucket by adding &lt;CODE&gt;| bin _time span=5d&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Foo "DataStringValue"="AMI Age" 
| bin _time span=5d
| stats dedup_splitvals=t count AS "Count of 1530130937.1457581" by _time, Department.StringValue, ami_date.StringValue 
| sort Department.StringValue 
| fields - _span 
| rename ami_date.StringValue AS Date, Department.StringValue AS Vertical, instance_id.StringValue AS Instance_ID 
| eval C=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q") 
| eval A=((now()-C)/86400) 
| stats avg(A) as Age by _time, Vertical
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 20:11:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408396#M117872</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2019-01-17T20:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408397#M117873</link>
      <description>&lt;P&gt;@skoelpin&lt;BR /&gt;
I'm trying to display the avg age for each day (up to five days) by the department&lt;/P&gt;

&lt;P&gt;So it would look like: &lt;BR /&gt;
Department--------average age today----average age yesterday&lt;BR /&gt;
dept 1------------------------7654.8------------------------9543.2&lt;BR /&gt;
dept 2------------------------1234.6 -----------------------6789.1&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 21:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408397#M117873</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-17T21:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408398#M117874</link>
      <description>&lt;P&gt;Gotcha. You should change your bucket values to days then like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Foo "DataStringValue"="AMI Age" 
 | bin _time span=1d
 | stats dedup_splitvals=t count AS "Count of 1530130937.1457581" by _time, Department.StringValue, ami_date.StringValue 
 | sort Department.StringValue 
 | fields - _span 
 | rename ami_date.StringValue AS Date, Department.StringValue AS Vertical, instance_id.StringValue AS Instance_ID 
 | eval C=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q") 
 | eval A=((now()-C)/86400) 
 | stats avg(A) as Age by _time, Vertical
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 21:13:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408398#M117874</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2019-01-17T21:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408399#M117875</link>
      <description>&lt;P&gt;@skoelpin &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; No results found&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 21:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408399#M117875</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-17T21:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408400#M117876</link>
      <description>&lt;P&gt;What's your timespan set to? You should set it back to atleast 5 days. &lt;/P&gt;

&lt;P&gt;You can also troubleshoot this by removing line by line to see where the issue is like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=Foo "DataStringValue"="AMI Age" 
  | bin _time span=1d
  | stats dedup_splitvals=t count AS "Count of 1530130937.1457581" by _time, Department.StringValue, ami_date.StringValue 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should produce 3 columns and 5 rows. Each row will represent 1 days worth of counts. Once you confirm that is working, keep adding lines until your next transformational line. if the query above does not return results, then the issue is with the first 3 lines. You should then remove the stats command and see if it populates  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Foo "DataStringValue"="AMI Age" 
  | bin _time span=1d
  | stats  count AS "Count of 1530130937.1457581" by _time, Department.StringValue, ami_date.StringValue 
  | rename ami_date.StringValue AS Date, Department.StringValue AS Vertical, instance_id.StringValue AS Instance_ID 
  | eval C=strptime(Date,"%Y-%m-%dT%H:%M:%S.%Q") 
  | eval A=((now()-C)/86400) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since you added 2 evals, you should have 2 additional columns. Once you confirm you have that, add that last stats on and see if you're getting results. If it worked up until that last stats then you know the issue is with the last line &lt;/P&gt;

&lt;P&gt;Lastly, get rid of the &lt;CODE&gt;dedup_splitvals=t&lt;/CODE&gt; flag and don't put quotes around your fieldnames, just the values. I'd also reccomend getting rid of those sorts. You should also save the formatting and renaming to after the transformational commands. Best for last&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 21:28:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408400#M117876</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2019-01-17T21:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408401#M117877</link>
      <description>&lt;P&gt;@skoelpin Hey so this is what my supervisor is thinking(were not sure but were unable to use _time to affect this departments result query): She thinks the data isnt using splunks _time but the AMI creation time instead. &lt;/P&gt;

&lt;P&gt;So this is what the json is looking like in splunk: &lt;BR /&gt;
 "ApproximateFirstReceiveTimestamp": "1547719362928",&lt;BR /&gt;
      "SentTimestamp": "1547719362927"&lt;/P&gt;

&lt;P&gt;We end up not pulling dates and times from years ago that wont use splunks _time&lt;/P&gt;

&lt;P&gt;Any ideas? Also, thanks for all of your help. &lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 22:07:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408401#M117877</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-17T22:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408402#M117878</link>
      <description>&lt;P&gt;Your event should have a timestamp near the beginning of the event, when data is indexed, Splunk will assign a timestamp which is what you see in a separate column before the event. &lt;CODE&gt;_time&lt;/CODE&gt; is in epoch time format, so anytime you wanna split by day for instance, you need to split by Splunk's &lt;CODE&gt;_time&lt;/CODE&gt;. Perhaps you can post an event or two to help clear this up? If Splunk is indeed using the AMI time and not the timestamp from the event then you need to fix that before addressing this. &lt;/P&gt;

&lt;P&gt;Also, feel free to upvote if any of this has helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 22:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408402#M117878</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2019-01-17T22:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do you return a table of a value by a department and then display it by how many days ago it occurred ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408403#M117879</link>
      <description>&lt;P&gt;I appreciate all your help! You were wonderful. &lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2019 22:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-return-a-table-of-a-value-by-a-department-and-then/m-p/408403#M117879</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-01-18T22:32:15Z</dc:date>
    </item>
  </channel>
</rss>

