<?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 Splunk search to remove duplicated ips? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626561#M217770</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Greetings!&lt;/P&gt;
&lt;P&gt;Need help on splunk query,&lt;/P&gt;
&lt;P&gt;I have 2 indexes assets and vulns, am trying to build report to analyze percent % assets are not scanned, with below query am getting results percent, but some of the ip's are having duplicate entries which are showing as as scanned and not scanned for same ip, i need query to remove from SCANNED =0 if the same ip SCANNED=1, I tried using dedup but since its removing randomly so scanned ip's also getting removed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me with correct query&lt;/P&gt;
&lt;P&gt;((index=index1 sourcetype=asset) OR&amp;nbsp;(index=index1 sourcetype=vulns))&lt;BR /&gt;| eval vuln=if('sourcetype'="vulns","yes","no")&lt;BR /&gt;| eval assets=if('sourcetype'="asset","yes","no")&lt;BR /&gt;| stats max(eval(if(vuln="yes",1,0))) AS SCANNED max(eval(if(assets="yes",1,0))) AS ASSETS latest(ip) as ip by uuid&lt;BR /&gt;| search&amp;nbsp;ASSETS=1&lt;BR /&gt;| stats count(eval( SCANNED &amp;gt; 0)) AS scanned, count(uuid) as total&lt;BR /&gt;| eval percent = round((scanned/(total))*100,2)&lt;BR /&gt;&lt;BR /&gt;Result example&lt;/P&gt;
&lt;TABLE width="187"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="57"&gt;scanned&lt;/TD&gt;
&lt;TD width="53"&gt;ASSETS&amp;nbsp;&lt;/TD&gt;
&lt;TD width="77"&gt;ip&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;192.168.1.1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;192.168.1.1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2023 17:12:24 GMT</pubDate>
    <dc:creator>kpavan</dc:creator>
    <dc:date>2023-01-11T17:12:24Z</dc:date>
    <item>
      <title>Splunk search to remove duplicated ips?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626561#M217770</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Greetings!&lt;/P&gt;
&lt;P&gt;Need help on splunk query,&lt;/P&gt;
&lt;P&gt;I have 2 indexes assets and vulns, am trying to build report to analyze percent % assets are not scanned, with below query am getting results percent, but some of the ip's are having duplicate entries which are showing as as scanned and not scanned for same ip, i need query to remove from SCANNED =0 if the same ip SCANNED=1, I tried using dedup but since its removing randomly so scanned ip's also getting removed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me with correct query&lt;/P&gt;
&lt;P&gt;((index=index1 sourcetype=asset) OR&amp;nbsp;(index=index1 sourcetype=vulns))&lt;BR /&gt;| eval vuln=if('sourcetype'="vulns","yes","no")&lt;BR /&gt;| eval assets=if('sourcetype'="asset","yes","no")&lt;BR /&gt;| stats max(eval(if(vuln="yes",1,0))) AS SCANNED max(eval(if(assets="yes",1,0))) AS ASSETS latest(ip) as ip by uuid&lt;BR /&gt;| search&amp;nbsp;ASSETS=1&lt;BR /&gt;| stats count(eval( SCANNED &amp;gt; 0)) AS scanned, count(uuid) as total&lt;BR /&gt;| eval percent = round((scanned/(total))*100,2)&lt;BR /&gt;&lt;BR /&gt;Result example&lt;/P&gt;
&lt;TABLE width="187"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="57"&gt;scanned&lt;/TD&gt;
&lt;TD width="53"&gt;ASSETS&amp;nbsp;&lt;/TD&gt;
&lt;TD width="77"&gt;ip&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;192.168.1.1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;192.168.1.1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:12:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626561#M217770</guid>
      <dc:creator>kpavan</dc:creator>
      <dc:date>2023-01-11T17:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to remove duplicated ips</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626576#M217778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49826"&gt;@kpavan&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;((index=index1 sourcetype=asset) OR (index=index1 sourcetype=vulns))
| stats count(eval(if(sourcetype="vulnes",1,0))) AS SCANNED count(eval(if(sourcetype="asset",1,0))) AS ASSETS count AS total BY ip
| where ASSETS&amp;gt;0
| eval percent = round((SCANNED /(total))*100,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 12:13:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626576#M217778</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-01-10T12:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to remove duplicated ips</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626584#M217781</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for the response!&lt;/P&gt;&lt;P&gt;I tried with your query, since uuid is the unique identifier and ip's are overlap with different network ranges. So if I use stats by ip the % are dropping from actual percent when do manual calculation.&lt;/P&gt;&lt;P&gt;So I wanted to remove ip's where it was already mentioned as scanned.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 13:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626584#M217781</guid>
      <dc:creator>kpavan</dc:creator>
      <dc:date>2023-01-10T13:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to remove duplicated ips</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626590#M217784</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49826"&gt;@kpavan&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you must use uuid as identifier, could you have more IPs for the same IP?&lt;/P&gt;&lt;P&gt;if yes, how do you want to manage this situation?&lt;/P&gt;&lt;P&gt;maybe you could try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;((index=index1 sourcetype=asset) OR (index=index1 sourcetype=vulns))
| stats count(eval(if(sourcetype="vulnes",1,0))) AS SCANNED count(eval(if(sourcetype="asset",1,0))) AS ASSETS values(ip) AS ip count AS total BY uuid
| mvexpand ip
| stats 
   max(SCANNED) AS SCANNED 
   max(ASSETS) AS ASSETS 
   max(total) AS total BY ip 
| where ASSETS&amp;gt;0
| eval percent = round((SCANNED /(total))*100,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 13:20:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-to-remove-duplicated-ips/m-p/626590#M217784</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-01-10T13:20:19Z</dc:date>
    </item>
  </channel>
</rss>

