<?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: How can we add original fields after using stats count? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536437#M151673</link>
    <description>&lt;P&gt;eventstats doesn't seem likely as the abuse API seems to only take a single IP address.&lt;/P&gt;&lt;P&gt;A couple of possibilities, one to use join, so in the subsearch you can do the base search and the lookups as you are currently doing and then the outer search will join with the subsearch on host address, but join is not a good solution as there are resource limits you may hit.&lt;/P&gt;&lt;P&gt;An alternative, which may work could be to run an appendpipe subsearch. The difference with that is that the appendpipe subsearch is run after the main search. In that search, you could do the stats/abuseip calls and then a further stats after that which merges the values from the appendpipe into their corresponding row, something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Base Search&amp;gt; 
| stats count by src_ip, query, host_addr 
| appendpipe [
  | stats count by host_addr
  | abuseip ipfield=host_addr 
]
| sort - host_addr
| filldown query src_ip
| stats values(LastReportedAt) as LastReportedAt values(AbuseConfidence) as AbuseConfidence by src_ip, query, host_addr&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 20 Jan 2021 06:25:50 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-01-20T06:25:50Z</dc:date>
    <item>
      <title>How can we add original fields after using stats count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536417#M151666</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have a use-case where responses(host_addr) returned from DNS queries are passed through AbuseIPDB API to check for any potential matches.&amp;nbsp; Since the API has a set limit we dont want to query an IP more than once. To achieve this, stats is used to get distinct values and then it is passed through the API. It works well but due to the use of "stats", we lose all the other crucial fields from the original data, e.g. src_ip, query etc. Here's a sample query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Base Search&amp;gt; | stats count by host_addr |  table host_addr |  abuseip ipfield=host_addr | sort - AbuseConfidence&lt;/LI-CODE&gt;&lt;P&gt;Could eventstats come to the rescue here? If so, what could be a potential syntax of that search? From the other examples I saw, eventstats sees to be more useful when performing a actual stats function like sum etc.&lt;/P&gt;&lt;P&gt;End goal is to create something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table src_ip, query, host_addr, LastReportedAt, AbuseConfidence&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but also keeping API limits in check(Using only unique values of host_addr).&lt;/P&gt;&lt;P&gt;Any pointers on this will be appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;~ Abhi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 03:02:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536417#M151666</guid>
      <dc:creator>att35</dc:creator>
      <dc:date>2021-01-20T03:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can we add original fields after using stats count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536431#M151670</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/179828"&gt;@att35&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use values() function in stats to keep the required values for table. Please try below search; (I assume LastReportedAt field returns from abuseip command.)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Base Search&amp;gt; 
| stats values(src_ip) as src_ip values(query) as query by host_addr 
| abuseip ipfield=host_addr 
| sort - AbuseConfidence
| table src_ip, query, host_addr, LastReportedAt, AbuseConfidence&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you an upvote is appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 05:34:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536431#M151670</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-01-20T05:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can we add original fields after using stats count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536437#M151673</link>
      <description>&lt;P&gt;eventstats doesn't seem likely as the abuse API seems to only take a single IP address.&lt;/P&gt;&lt;P&gt;A couple of possibilities, one to use join, so in the subsearch you can do the base search and the lookups as you are currently doing and then the outer search will join with the subsearch on host address, but join is not a good solution as there are resource limits you may hit.&lt;/P&gt;&lt;P&gt;An alternative, which may work could be to run an appendpipe subsearch. The difference with that is that the appendpipe subsearch is run after the main search. In that search, you could do the stats/abuseip calls and then a further stats after that which merges the values from the appendpipe into their corresponding row, something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Base Search&amp;gt; 
| stats count by src_ip, query, host_addr 
| appendpipe [
  | stats count by host_addr
  | abuseip ipfield=host_addr 
]
| sort - host_addr
| filldown query src_ip
| stats values(LastReportedAt) as LastReportedAt values(AbuseConfidence) as AbuseConfidence by src_ip, query, host_addr&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 20 Jan 2021 06:25:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-we-add-original-fields-after-using-stats-count/m-p/536437#M151673</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-01-20T06:25:50Z</dc:date>
    </item>
  </channel>
</rss>

