<?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: Obtaining values from a stats command to then utilize within a Timechart. in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510278#M9040</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;timestamp&lt;/FONT&gt; command requires the _time field, which the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command filters out if it is not explicitly referenced.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 19:35:25 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-07-21T19:35:25Z</dc:date>
    <item>
      <title>Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510270#M9039</link>
      <description>&lt;P&gt;Apologies, as this is a bit lengthy, but I'm completely stuck. I'm having to show data that shows a compliance percentage after adding weighted values to each result over the past 4 months&lt;/P&gt;&lt;P&gt;Basically, an item can have two states (pass or fail), and a score attributed based on severity. If an item is high severity then it is worth 72 points, if it's a medium then 36 points, and a low is worth 12.&lt;/P&gt;&lt;P&gt;I then calculate the weighted percentage of each machine using those numbers mentioned above (72/36/12).&amp;nbsp;&lt;/P&gt;&lt;P&gt;From there I have to find one more value called Actual Percentage...this means you must have a weighted percentage of over 90% AND you must have 0 high severity fails (&lt;EM&gt;this results in basically a binary 1/0 type result...1 if you meet the requirements, and 0 if you do not meet both requirements).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I was able to get this working for a singular time (such as 30 days) as shown below,&lt;/STRONG&gt; but I'm unable to make this work with a timechart if I want to see the "Actual Percentage" of all the machines over the past 4 months broken down by each month (1 mon).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Basically it's -&amp;gt; determine values for each compliance item -&amp;gt; calculate percentage to gain weighted percentage -&amp;gt; calculate the actual percentage of the machine by looking for weighted percentage above 90% and no high failed checks -&amp;gt; Produce output of the environment over the past 4 months spanning each month.&lt;/P&gt;&lt;P&gt;Thank you for any ideas to get me off this syntax block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search query
| dedup comp_id check_id
| stats count(eval(compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed")) AS Passed, count(eval(compliance_result="failed")) AS Failed, count(eval(source_severity="high" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS HPassed, count(eval(source_severity="high" AND compliance_result="failed")) AS HFailed, count(eval(source_severity="medium" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS MPassed, count(eval(source_severity="medium" AND compliance_result="failed")) AS MFailed, count(eval(source_severity="low" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS LPassed, count(eval(source_severity="low" AND compliance_result="failed")) AS LFailed by comp_id
| eval High_Failed=HFailed
| eval WP_High=HPassed*72, WP_Med=MPassed*36, WP_Low=LPassed*12, WF_High=HFailed*72, WF_Med=MFailed*36, WF_Low=LFailed*12
| eval Weighted_Passed=WP_High+WP_Med+WP_Low, Weighted_Failed=WF_High+WF_Med+WF_Low
| eval WC_Perc=(100-((Weighted_Failed/(Weighted_Passed+Weighted_Failed))*100))
| eval WC_Perc=round(WC_Perc,1)
| eval Weighted_Comp_Passed=if((HFailed="0" AND WC_Perc&amp;gt;90), "1", "0")
| eval Weighted_Comp_Failed=if((HFailed!="0" OR WC_Perc&amp;lt;90), "1", "0")
| eval goodMachines= if(WC_Perc&amp;gt;90 AND HFailed=0, 1, 0)
| stats sum(goodMachines) as sumOfGoodMachines, count(goodMachines) as countOfMachines
| eval percentGoodMachines = ((sumOfGoodMachines / countOfMachines)*100)
| eval percentGoodMachines=round(percentGoodMachines,2)
| eval percentGoodMachines=percentGoodMachines."%"
| rename percentGoodMachines AS "Actual Compliance",
| table checklist "Actual Compliance"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 17:51:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510270#M9039</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-21T17:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510278#M9040</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;timestamp&lt;/FONT&gt; command requires the _time field, which the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command filters out if it is not explicitly referenced.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 19:35:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510278#M9040</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-21T19:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510282#M9041</link>
      <description>&lt;P&gt;So I should be utilizing the _time within the first stats command as in:&lt;/P&gt;&lt;P&gt;Stats query by comp_id _time?&lt;/P&gt;&lt;P&gt;What then would I put for the second stats line that calculates the percentage after doing the weighted conversion?&lt;/P&gt;&lt;P&gt;As you can tell I'm not very good with the timechart mechanism.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 19:43:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510282#M9041</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-21T19:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510284#M9042</link>
      <description>&lt;P&gt;Add "&lt;FONT face="courier new,courier"&gt;by _time&lt;/FONT&gt;".&lt;BR /&gt;And you need "&lt;FONT face="courier new,courier"&gt;| timechart&lt;/FONT&gt;" somewhere. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To make the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command work better when grouping by _time, insert a &lt;FONT face="courier new,courier"&gt;bin&lt;/FONT&gt; command early in your search.&amp;nbsp; Use the same span that &lt;FONT face="courier new,courier"&gt;timechart&lt;/FONT&gt; uses.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| bin span=1h _time
| stats ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:05:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510284#M9042</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-21T20:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510285#M9043</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search query
| bin _time span=1month
| stats count(eval(compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed")) AS Passed, count(eval(compliance_result="failed")) AS Failed, count(eval(source_severity="high" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS HPassed, count(eval(source_severity="high" AND compliance_result="failed")) AS HFailed, count(eval(source_severity="medium" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS MPassed, count(eval(source_severity="medium" AND compliance_result="failed")) AS MFailed, count(eval(source_severity="low" AND (compliance_result="passed" OR compliance_result="excepted_passed" OR compliance_result="excepted_failed"))) AS LPassed, count(eval(source_severity="low" AND compliance_result="failed")) AS LFailed by comp_id _time
| eval High_Failed=HFailed
| eval WP_High=HPassed*72, WP_Med=MPassed*36, WP_Low=LPassed*12, WF_High=HFailed*72, WF_Med=MFailed*36, WF_Low=LFailed*12
| eval Weighted_Passed=WP_High+WP_Med+WP_Low, Weighted_Failed=WF_High+WF_Med+WF_Low
| eval WC_Perc=(100-((Weighted_Failed/(Weighted_Passed+Weighted_Failed))*100))
| eval WC_Perc=round(WC_Perc,1)
| eval Weighted_Comp_Passed=if((HFailed="0" AND WC_Perc&amp;gt;90), "1", "0")
| eval Weighted_Comp_Failed=if((HFailed!="0" OR WC_Perc&amp;lt;90), "1", "0")
| eval goodMachines= if(WC_Perc&amp;gt;90 AND HFailed=0, 1, 0)
| stats sum(goodMachines) as sumOfGoodMachines, count(goodMachines) as countOfMachines by _time
| eval percentGoodMachines = ((sumOfGoodMachines / countOfMachines)*100)
| eval percentGoodMachines=round(percentGoodMachines,2)
| eval percentGoodMachines=percentGoodMachines."%"
| rename percentGoodMachines AS "Actual Compliance",
| table _time "Actual Compliance"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what's &lt;STRONG&gt;checklist&lt;/STRONG&gt;? your query can work?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:05:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510285#M9043</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-21T20:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510286#M9044</link>
      <description>&lt;P&gt;So first stats command should be by comp id _time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the second stats command should instead be a timechart sum(GoodMachines), but this is really where my knowledge falls off the rails.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510286#M9044</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-21T20:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510287#M9045</link>
      <description>&lt;P&gt;Apologies, the checklist at the very end should not be there. It was an artifact from prior testing.&lt;/P&gt;&lt;P&gt;It should be just _time and actual compliance for the chart itself.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:12:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510287#M9045</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-21T20:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510289#M9046</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/169601"&gt;@giventofly08&lt;/a&gt;&amp;nbsp; how about my query?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:29:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510289#M9046</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-21T20:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510302#M9047</link>
      <description>&lt;P&gt;I put everything in below the dedup line and it appears to provide results that are in line with what I would expect for the first month; however, month 2 appeared abnormally high when it should have been stagnant change (or maybe 1%) It showed last month correct at about .85% but for May it was around 3.4% before my splunk instance crashed.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 21:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510302#M9047</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-21T21:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510387#M9051</link>
      <description>&lt;P&gt;&amp;gt;&lt;SPAN&gt;below the dedup line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why? I didn't do like that. Do you know how&amp;nbsp;&lt;STRONG&gt;dedup&lt;/STRONG&gt; works?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 09:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510387#M9051</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-22T09:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510439#M9052</link>
      <description>&lt;P&gt;I had deduped in the past to remove any duplication of a computer_id (Comp_id) and the specific check in question (check_id) so that if a machine reports in more than once in a month it will take the most recent check-in results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please correct me if I'm wrong, but if I don't dedup the comp_id and check_id then if Machine A reports in 9x in a month at 0% and Machine B reports in 1 time at 100%, instead of it being 50% it would be 10%, no?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 13:25:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510439#M9052</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-22T13:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510454#M9054</link>
      <description>&lt;P&gt;There are no results shown here, no logs, just queries.&lt;BR /&gt;I think only you can determine that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;dedup&lt;/STRONG&gt; works for the entire search period.&lt;BR /&gt;Doesn't it aggregate every month?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 13:52:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510454#M9054</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-22T13:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510467#M9056</link>
      <description>&lt;P&gt;Sorry, this query basically takes log files that an agent on the computer reports in, every day or so and will provide a log file to state what the check was, the severity of it, and if it passed or failed said check.&lt;/P&gt;&lt;P&gt;The next day it will do the same for all checks again. Same for each subsequent day. So really we want a percentage of all machines with 90% success and no failed high checks. This should be done for the last day of each month.&lt;/P&gt;&lt;P&gt;I believe if we dedup by the computer_id, the check_id, and _time that should accomplish it with your bin statement?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 14:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/510467#M9056</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-22T14:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining values from a stats command to then utilize within a Timechart.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/511092#M9072</link>
      <description>&lt;P&gt;Your query did in fact work, I just had to make sure to dedup by _time and ensure that _time was accounted for in the stats lines. Thank you very much for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 12:13:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Obtaining-values-from-a-stats-command-to-then-utilize-within-a/m-p/511092#M9072</guid>
      <dc:creator>giventofly08</dc:creator>
      <dc:date>2020-07-27T12:13:15Z</dc:date>
    </item>
  </channel>
</rss>

