<?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: Percentage Difference between 2 indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306292#M163647</link>
    <description>&lt;P&gt;Hey I think you want to show percentage something like this so in addition to above query you can write something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="softwareimport" Product_Name="*ActiveX*") OR (index="device_list" device_state="Active") 
| stats count(eval(index="softwareimport")) as Total_ProductName_Count count(eval(index="device_list")) as Total_DeviceState_Count 
| eval Percentage=round((Total_DeviceState_Count*100)/Total_ProductName_Count,2)."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2018 09:01:48 GMT</pubDate>
    <dc:creator>mayurr98</dc:creator>
    <dc:date>2018-01-15T09:01:48Z</dc:date>
    <item>
      <title>Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306288#M163643</link>
      <description>&lt;P&gt;I have 2 searches from 2 different indexes.  The first search is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="softwareimport" Product_Name="*ActiveX*"  | stats count by Product_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second search is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="device_list" device_state="Active" | stats count by device_state
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I then do a percentage of these 2 values so that I can show a percentage value (i.e. xx%)?&lt;/P&gt;

&lt;P&gt;I am just starting to learn how to use eval and came across something called appendcols but not sure if this is right for the context I am working in.  &lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 07:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306288#M163643</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-01-15T07:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306289#M163644</link>
      <description>&lt;P&gt;I have tried something like&lt;/P&gt;

&lt;P&gt;index="devicelist" OR index="softwareimport" | stats count by Product_Name | stats count by Device_State&lt;BR /&gt;
| eval percentage=Device_State/Product_Name&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:39:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306289#M163644</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-09-29T17:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306290#M163645</link>
      <description>&lt;P&gt;This should do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="softwareimport" Product_Name="*ActiveX*") OR (index="device_list" device_state="Active")
| stats count(eval(index="softwareimport")) as count_softwareimport count(eval(index="device_list")) as count_device_list
| eval percentage = count_device_list / count_softwareimport * 100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2018 08:09:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306290#M163645</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-01-15T08:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306291#M163646</link>
      <description>&lt;P&gt;I see. Will try that and get back&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 08:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306291#M163646</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-01-15T08:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306292#M163647</link>
      <description>&lt;P&gt;Hey I think you want to show percentage something like this so in addition to above query you can write something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="softwareimport" Product_Name="*ActiveX*") OR (index="device_list" device_state="Active") 
| stats count(eval(index="softwareimport")) as Total_ProductName_Count count(eval(index="device_list")) as Total_DeviceState_Count 
| eval Percentage=round((Total_DeviceState_Count*100)/Total_ProductName_Count,2)."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306292#M163647</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-15T09:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306293#M163648</link>
      <description>&lt;P&gt;Sure sir, Try and let us know we are glad to help you out!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 10:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306293#M163648</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-15T10:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306294#M163649</link>
      <description>&lt;P&gt;Works beautifully.  Thanks for the support!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 01:29:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306294#M163649</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-01-16T01:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306295#M163650</link>
      <description>&lt;P&gt;I have experimented a bit with doing some joins to match my data between 2 indexes and then tried adapting my configuration using what I have learnt from the percentage question.  So related but different.  I have the following search&lt;/P&gt;

&lt;P&gt;index="softwareimport" "Product Name"="Adobe Flash Player 28 ActiveX" OR "Product Name"="Adobe Flash Player 27 ActiveX"&lt;BR /&gt;
| join "Device Name" [search index="devicelist" "Device State"=Active "Operating System"="&lt;EM&gt;Windows&lt;/EM&gt;" AND "Operating System"!="&lt;EM&gt;server&lt;/EM&gt;"]&lt;BR /&gt;
| stats count(eval(index="softwareimport")) as count_softwareimport count(eval(index="devicelist")) as count_device&lt;BR /&gt;
| eval "ActiveX Compliance" = round((count_softwareimport*100)/count_device,0)."%"&lt;BR /&gt;
| table "ActiveX Compliance"&lt;/P&gt;

&lt;P&gt;This generates a value of "0%"&lt;/P&gt;

&lt;P&gt;What I am trying to do is get a percentage based on this configuration.  If I run this search:&lt;/P&gt;

&lt;P&gt;index="softwareimport" "Product Name"="Adobe Flash Player 28 ActiveX" OR "Product Name"="Adobe Flash Player 27 ActiveX"&lt;BR /&gt;
| join "Device Name" [search index="devicelist" "Device State"="Active" "Operating System"!="&lt;EM&gt;server&lt;/EM&gt;"]&lt;BR /&gt;
| stats count AS "ActiveX Current"&lt;/P&gt;

&lt;P&gt;This returns a value of "3990".&lt;/P&gt;

&lt;P&gt;I did then try to do the following search&lt;/P&gt;

&lt;P&gt;index="softwareimport" "Product Name"="Adobe Flash Player 28 ActiveX" OR "Product Name"="Adobe Flash Player 27 ActiveX"&lt;BR /&gt;
| join "Device Name" [search index="devicelist" "Device State"=Active "Operating System"="&lt;EM&gt;Windows&lt;/EM&gt;" AND "Operating System"!="&lt;EM&gt;server&lt;/EM&gt;"]&lt;BR /&gt;
| stats count(eval(index="softwareimport")) as count_softwareimport count(eval([search index="devicelist" "Device State"=Active "Operating System"="&lt;EM&gt;Windows&lt;/EM&gt;"])) as count_device&lt;BR /&gt;
| eval "ActiveX Compliance" = round((count_softwareimport*100)/count_device,0)."%"&lt;BR /&gt;
| table "ActiveX Compliance"&lt;/P&gt;

&lt;P&gt;This ends up generating "Error in 'SearchProcessor': Mismatched quotes and/or parenthesis." even though all the quotes are matched.  &lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306295#M163650</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2020-09-29T17:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306296#M163651</link>
      <description>&lt;P&gt;So the first query I will always get a 0% which is not correct.  On the last query I get the error.  I checked and all search terms are validated by SPLUNK (i.e. AND, Eval, AND, AS) but I get either the "0" behaviour or the "mismatched quotes" despite there not being a mismatched quote that I can see.  &lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:44:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306296#M163651</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2018-01-16T14:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage Difference between 2 indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306297#M163652</link>
      <description>&lt;P&gt;Hey join is by default left join so you will get the events for sure even if there is no match just that you will not able to do further analysis this is what happening with your query. You need to look into your data. What i suggest is to do not run full query. Rather run it in bits and pieces check the output of the query after every &lt;CODE&gt;|&lt;/CODE&gt; specially after &lt;CODE&gt;| stats count(eval(index="softwareimport")) as count_softwareimport count(eval([search index="devicelist" "Device State"=Active "Operating System"="Windows"])) as count_device&lt;/CODE&gt; this command see if you are getting proper results. Percentage is just a calculation on this set of results so if you are getting proper results then you should get your output. So just debug it at each &lt;CODE&gt;|&lt;/CODE&gt; and see where you aint getting results . &lt;/P&gt;

&lt;P&gt;Also,if you are not able to debug this then open a new ticket and post this question with detail description and sample events. I am sure someone from community or me would help you.&lt;/P&gt;

&lt;P&gt;I hope this helps you!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:56:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-Difference-between-2-indexes/m-p/306297#M163652</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T14:56:38Z</dc:date>
    </item>
  </channel>
</rss>

