<?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 How can I generate a trending analysis into the past? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-generate-a-trending-analysis-into-the-past/m-p/136554#M184750</link>
    <description>&lt;P&gt;I'm working with Qualys vulnerability data in splunk.  &lt;/P&gt;

&lt;P&gt;Qualys has an api call that runs once daily and collects any &lt;EM&gt;changes&lt;/EM&gt;  to the environment over the last day.  Since splunk only receives a new event when a change is made, calculating TOTALS for vulnerabilities (QID) or impacted hosts (HOST_ID) really involves searching the entire event log.&lt;/P&gt;

&lt;P&gt;Example:  I want to a count of all systems currently affected by QID 100101 -&lt;/P&gt;

&lt;P&gt;sourcetype=qualys_vm_detection HOSTVULN QID=100101 | dedup HOST_ID, QID | search STATUS!="FIXED" | stats count(HOST_ID) as #_affected&lt;/P&gt;

&lt;P&gt;logic: I build the basic search criteria. I perform a DE DUPLICATION process on the HOST_ID and QID pairs to make sure I'm not over counting and I am looking at the most current host/vuln pair.   I then run a check to exclude anything being reported as "FIXED" and I can the calculate the total number of hosts currently affected.&lt;/P&gt;

&lt;P&gt;Question:  How can I generate a trending chart of that total &lt;STRONG&gt;into the past?&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The big issue is that HOSTVULN events only get added with a status change.  If I do a typical time chart, I'm reporting &lt;EM&gt;only on the __changes&lt;/EM&gt;_ made daily_ not the total numbers.   If I were working foward, I could create a summary table but what if the request is "show me how the total number of hosts affected by xxxxxx went down over the last week/month."&lt;/P&gt;

&lt;P&gt;What I really need to do is calculate that total, back up the 'latest' by a day, repeat the calculation and then iterate over a requested period.   I realize this will take a LOT of time but I can't think of another approach given the nature of the data coming into splunk.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:16:05 GMT</pubDate>
    <dc:creator>klawman</dc:creator>
    <dc:date>2020-09-28T18:16:05Z</dc:date>
    <item>
      <title>How can I generate a trending analysis into the past?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-generate-a-trending-analysis-into-the-past/m-p/136554#M184750</link>
      <description>&lt;P&gt;I'm working with Qualys vulnerability data in splunk.  &lt;/P&gt;

&lt;P&gt;Qualys has an api call that runs once daily and collects any &lt;EM&gt;changes&lt;/EM&gt;  to the environment over the last day.  Since splunk only receives a new event when a change is made, calculating TOTALS for vulnerabilities (QID) or impacted hosts (HOST_ID) really involves searching the entire event log.&lt;/P&gt;

&lt;P&gt;Example:  I want to a count of all systems currently affected by QID 100101 -&lt;/P&gt;

&lt;P&gt;sourcetype=qualys_vm_detection HOSTVULN QID=100101 | dedup HOST_ID, QID | search STATUS!="FIXED" | stats count(HOST_ID) as #_affected&lt;/P&gt;

&lt;P&gt;logic: I build the basic search criteria. I perform a DE DUPLICATION process on the HOST_ID and QID pairs to make sure I'm not over counting and I am looking at the most current host/vuln pair.   I then run a check to exclude anything being reported as "FIXED" and I can the calculate the total number of hosts currently affected.&lt;/P&gt;

&lt;P&gt;Question:  How can I generate a trending chart of that total &lt;STRONG&gt;into the past?&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The big issue is that HOSTVULN events only get added with a status change.  If I do a typical time chart, I'm reporting &lt;EM&gt;only on the __changes&lt;/EM&gt;_ made daily_ not the total numbers.   If I were working foward, I could create a summary table but what if the request is "show me how the total number of hosts affected by xxxxxx went down over the last week/month."&lt;/P&gt;

&lt;P&gt;What I really need to do is calculate that total, back up the 'latest' by a day, repeat the calculation and then iterate over a requested period.   I realize this will take a LOT of time but I can't think of another approach given the nature of the data coming into splunk.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-generate-a-trending-analysis-into-the-past/m-p/136554#M184750</guid>
      <dc:creator>klawman</dc:creator>
      <dc:date>2020-09-28T18:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I generate a trending analysis into the past?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-generate-a-trending-analysis-into-the-past/m-p/136555#M184751</link>
      <description>&lt;P&gt;I think you might want something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=qualys_vm_detection HOSTVULN QID=100101
| sort 0 _time
| eval IsItFixed=if(STATUS="FIXED","yes","no")
| dedup HOST_ID, IsItFixed
| streamstats count(eval(IsItFixed="no")) as NotFixed count(eval(IsItFixed="yes")) as Fixed 
| timechart span=1d last(NotFixed) as NotFixed last(Fixed) as Fixed
| eval StillNotFixed='NotFixed'-'Fixed'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(This might not be exactly right, but it should give you something to work with.)&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;sort&lt;/CODE&gt; command just turns your events around so that they go forward in time.&lt;BR /&gt;
The &lt;CODE&gt;eval&lt;/CODE&gt; command rolls up all of the not-fixed statuses into the same value (I'm assuming there are different unfixed statuses).&lt;BR /&gt;
The &lt;CODE&gt;dedup&lt;/CODE&gt; command gives us the proper unique pairs of machine name and whether it is fixed or not.&lt;BR /&gt;
The &lt;CODE&gt;streamstats&lt;/CODE&gt; command adds a cumulative value to each event so that it contains the ongoing total of machines that are fixed and machines that were once unfixed.&lt;BR /&gt;
The &lt;CODE&gt;timechart&lt;/CODE&gt; command gives you the last cumulative value for each kind of machine on each day.&lt;BR /&gt;
The last &lt;CODE&gt;eval&lt;/CODE&gt; command then gives you the difference between the ones that have been fixed and the ones that haven't been.&lt;/P&gt;

&lt;P&gt;The problem with your search as described above is that when you did your &lt;CODE&gt;search STATUS!="FIXED"&lt;/CODE&gt;, you lost all of the information when machines got  fixed. Without that information, you can't keep a running total.&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 17:35:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-generate-a-trending-analysis-into-the-past/m-p/136555#M184751</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-11-26T17:35:32Z</dc:date>
    </item>
  </channel>
</rss>

