<?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: Calculate difference between 2 timestamp to find number of week? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235735#M70003</link>
    <description>&lt;P&gt;A point of clarification - do you mean "week" as in a Sunday - Saturday interval or any 7 days?  If I give you the timestamps "2016-08-10 12:00:00" and "2016-08-15 12:00:00" is there a 1 week difference, or a zero week difference?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 15:36:20 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2016-08-23T15:36:20Z</dc:date>
    <item>
      <title>Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235731#M69999</link>
      <description>&lt;P&gt;How can I use  timestamps from 2 different sources and calucate them inorder to find the difference and convert in number of weeks?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 13:48:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235731#M69999</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2016-08-23T13:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235732#M70000</link>
      <description>&lt;P&gt;You would need to provide more information than this to get an accurate answer. What are these two sources? Share a sample query, field names and sample events from each source highlighting the relevant data? Share your mock output with examples.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 15:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235732#M70000</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-23T15:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235733#M70001</link>
      <description>&lt;P&gt;index=nvd sourcetype=vuln_feed  CVE="CVE-2016-0646" |stats first(_time) as TimeStamp | convert ctime(TimeStamp) as Recent_Time | fields - TimeStamp | appendcols [search index=nessusta sourcetype=nessus:plugin  cve="CVE-2016-0646" |stats first(_time) as TimeStamp1 | convert ctime(TimeStamp1) as Recent_Time2 | fields - TimeStamp1]&lt;/P&gt;

&lt;P&gt;In the above query, Currently I am displaying timestamp from 2 different sources for a particular value which hare present in both the sources but has different timestamp. One is 4/4 and other is 11/4. I am trying to dval the difference in dates here to find # of weeks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235733#M70001</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2020-09-29T10:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235734#M70002</link>
      <description>&lt;P&gt;Give this a shot&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nvd sourcetype=vuln_feed CVE="CVE-2016-0646" |stats first(_time) as Recent_Time | appendcols [search index=nessusta sourcetype=nessus:plugin cve="CVE-2016-0646" |stats first(_time) as Recent_Time2] | eval NoOfWeeks=floor(abs(Recent_Time2-Recent_Time)/86400/7) |  convert ctime(Recent_Time*) as Recent_Time* 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;BR /&gt;
Try like this to compare individual CVE/cve values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=nvd sourcetype=vuln_feed) OR (index=nessusta sourcetype=nessus:plugin)  | eval CVE=coalesce(cve,CVE) |chart first(_time) as Recent_Time over CVE by index | rename nvd as Recent_Time nessusta as Recent_Time2 | eval NoOfWeeks=floor(abs(Recent_Time2-Recent_Time)/86400/7) |  convert ctime(Recent_Time*) as Recent_Time* 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2016 15:35:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235734#M70002</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-23T15:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235735#M70003</link>
      <description>&lt;P&gt;A point of clarification - do you mean "week" as in a Sunday - Saturday interval or any 7 days?  If I give you the timestamps "2016-08-10 12:00:00" and "2016-08-15 12:00:00" is there a 1 week difference, or a zero week difference?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 15:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235735#M70003</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-08-23T15:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235736#M70004</link>
      <description>&lt;P&gt;so based on your timestamps its 5 days and my objective is to identify the #ofdays (I am sorry if that was a confusion) in the earlier post) and eventually bucket them into  different categories. for eg  if #days difference is 14 days, then its 2 weeks and its being categorized into a specific bucket&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 15:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235736#M70004</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2016-08-23T15:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235737#M70005</link>
      <description>&lt;P&gt;Even though the above query works, it only work for specific equal values. How can I make it more generalized for CVE = cve  and list out all those CVE values. &lt;BR /&gt;
index=nvd sourcetype=vuln_feed |table CVE |dedup CVE|stats first(_time) as Recent_Time | appendcols [search index=nessusta sourcetype=nessus:plugin |table cve |dedup cve|stats first(_time) as Recent_Time2] |where CVE=cve | eval NoOfWeeks=floor(abs(Recent_Time2-Recent_Time)/86400/7) |  convert ctime(Recent_Time*) as Recent_Time* &lt;/P&gt;

&lt;P&gt;The first index is large dataset compared to the second one. that why I had to table it and then dedup it&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235737#M70005</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2020-09-29T10:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235738#M70006</link>
      <description>&lt;P&gt;(index=nvd sourcetype=vuln_feed) OR (index=nessusta sourcetype=nessus:plugin)  | eval CVE=coalesce(cve,CVE) |chart first(_time) as Recent_Time over CVE by index | rename nvd as Recent_Time nessusta as Recent_Time2 | eval NoOfWeeks=floor(abs(Recent_Time2-Recent_Time)/86400/7) |  convert ctime(Recent_Time*) as Recent_Time* &lt;BR /&gt;
I tried this and it only display values from nessusta index and not nvd. when switch around in coalesce(CVE,cve) it displays values of nvd but not nessusta. So I think coalesce would not be the right option&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:40:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235738#M70006</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2020-09-29T10:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235739#M70007</link>
      <description>&lt;P&gt;Does the field CVE OR cve exists in both the sources? I assumed that both fields doesn't exists in the same event. If that is not the case, replace &lt;CODE&gt;| eval CVE=coalesce(cve,CVE)&lt;/CODE&gt; with &lt;CODE&gt;| eval CVE=if(index="nvd",CVE,cve)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235739#M70007</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-23T19:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235740#M70008</link>
      <description>&lt;P&gt;Can you explain the coalesce function in splunk? Does it append values from 2 different fields into one field?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235740#M70008</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2016-08-23T20:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235741#M70009</link>
      <description>&lt;P&gt;&lt;CODE&gt;coalesce&lt;/CODE&gt; in Splunk works just like &lt;CODE&gt;coalesce&lt;/CODE&gt; in SQL.  Given a set of arguments it returns the first not-NULL argument.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235741#M70009</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2016-08-23T20:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235742#M70010</link>
      <description>&lt;P&gt;When in doubt, look at Splunk documentation.&lt;BR /&gt;
Search Commands&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Commandsbycategory"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Commandsbycategory&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Eval/Where functions&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235742#M70010</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-23T20:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235743#M70011</link>
      <description>&lt;P&gt;Got it thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235743#M70011</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2016-08-23T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235744#M70012</link>
      <description>&lt;P&gt;Question: I wrote this following query &lt;/P&gt;

&lt;P&gt;index=nessusta sourcetype=nessus:plugin |table cve{},factor| mvexpand cve{}|stats dc(cve{}) as totalcve by factor |eval TotalCVE = [search index="summary" source="Total Number of CVE from NVD" | return $TotalCVE  ] |eval perc=tostring(totalcve/TotalCVE*100,"commas")."%"&lt;/P&gt;

&lt;P&gt;OUtPUT&lt;/P&gt;

&lt;P&gt;factor totalcve  TotalCVE  perc &lt;BR /&gt;
High  24798  78548  31.57%&lt;BR /&gt;&lt;BR /&gt;
Low  1253  78548  1.60%&lt;BR /&gt;&lt;BR /&gt;
Medium  12099  78548  15.40%  &lt;/P&gt;

&lt;P&gt;is there a way to list out CVE % coverage by factor. &lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 21:07:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235744#M70012</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2016-08-23T21:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235745#M70013</link>
      <description>&lt;P&gt;Could you provide (based on your sample data above) what field to be created and what expected value will be?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 21:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235745#M70013</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-23T21:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between 2 timestamp to find number of week?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235746#M70014</link>
      <description>&lt;P&gt;(index=nvd sourcetype=vuln_feed ) OR (index=nessusta sourcetype=nessus:plugin)|eval CVE1=coalesce(CVE,cve)|chart first(_time) as Recent_Time over CVE1 by index | rename nvd as Recent_Time, nessusta as Recent_Time2 | eval NoOfWeeks=floor(abs(Recent_Time2-Recent_Time)/86400/7) |  convert ctime(Recent_Time*) as Recent_Time*| eval Sev= case(NoOfWeeks&amp;gt;=0 AND NoOfWeeks&amp;lt;=4,"High",NoOfWeeks&amp;gt;=5 AND NoOfWeeks&amp;lt;=8,"Medium",NoOfWeeks&amp;gt;=8 AND NoOfWeeks&amp;lt;=16,"Low")&lt;/P&gt;

&lt;P&gt;Need some suggestion, in the above statement coalesce(CVE,cve), the list of" CVE" ahs 100+ values where as cve has only 2 values &lt;BR /&gt;
and when I run the above query. this is what I see below&lt;/P&gt;

&lt;P&gt;CVE1 Recent_time2  NoOfWeeks Recent_time  Sev&lt;BR /&gt;
CVE-2016-5672  8/16           0      08/08/2016 22:04:24   High&lt;/P&gt;

&lt;P&gt;However I am find how I can find % of CVE and cve and then search it by Sev(High Low Medium)&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-difference-between-2-timestamp-to-find-number-of-week/m-p/235746#M70014</guid>
      <dc:creator>ashishlal82</dc:creator>
      <dc:date>2020-09-29T10:51:46Z</dc:date>
    </item>
  </channel>
</rss>

