<?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 Need help to run report in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-run-report/m-p/186390#M53671</link>
    <description>&lt;P&gt;I am trying to run a report where from my iis logs I want to pull request urls that have the keywords union and select in it and want to get the top source ip's that are generating these requests. My query below return the top ip's that generate requests with the keywords but its not displaying the actual requests that are indexed under the cs_uri_query field.&lt;/P&gt;

&lt;P&gt;sourcetype=iis union select | top limit=20 c_ip | table cs_uri_query, c_ip&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 19:13:46 GMT</pubDate>
    <dc:creator>rebel2</dc:creator>
    <dc:date>2020-09-28T19:13:46Z</dc:date>
    <item>
      <title>Need help to run report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-run-report/m-p/186390#M53671</link>
      <description>&lt;P&gt;I am trying to run a report where from my iis logs I want to pull request urls that have the keywords union and select in it and want to get the top source ip's that are generating these requests. My query below return the top ip's that generate requests with the keywords but its not displaying the actual requests that are indexed under the cs_uri_query field.&lt;/P&gt;

&lt;P&gt;sourcetype=iis union select | top limit=20 c_ip | table cs_uri_query, c_ip&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:13:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-run-report/m-p/186390#M53671</guid>
      <dc:creator>rebel2</dc:creator>
      <dc:date>2020-09-28T19:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to run report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-to-run-report/m-p/186391#M53672</link>
      <description>&lt;P&gt;So see why it's behaving the way it does, back up a step in the search.  Treat your splunk search just like the linux pipeline:  The output from one command is the input for the next.  So in your case, your &lt;CODE&gt;table&lt;/CODE&gt; command is working with the output of the &lt;CODE&gt;top&lt;/CODE&gt; command.  What is the output of the &lt;CODE&gt;top&lt;/CODE&gt; command?  That's easy to see by removing everything after it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=iis union select | top limit=20 c_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When you run that, look at the output.  More specifically, look at what's not there anymore:  Your &lt;CODE&gt;cs_uri_query&lt;/CODE&gt; field.  Since it is not a part of the output of your &lt;CODE&gt;top&lt;/CODE&gt; command, it's impossible for the &lt;CODE&gt;table&lt;/CODE&gt; to display it.  So this tells us that &lt;CODE&gt;top&lt;/CODE&gt; might not be the best way to get the information you want. (at least, not directly)&lt;/P&gt;

&lt;P&gt;Now, comes the hard question:  What do you actually expect your output to be?  Your question doesn't make this clear, so I'm going to assume you want all the requests from the top 20 IP's.  If so, we're going to need to do some sub search magic:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=iis union select [search sourcetype=iis union select | top limit=20 c_ip | table ip | format] | table cs_uri_query, c_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The magic here is in the sub search.  (everything inside the &lt;CODE&gt;[]&lt;/CODE&gt;'s is it's own search)  The sub search generates a list of your top 20 c_ips, and turns them into search parameters for the outer search.  So what splunk actually sees is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=iis union select ( (c_ip="X.X.X.X") OR (c_ip="Y.Y.Y.Y") OR ... ) | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you a table of every request from those specific IP's having either 'union' or 'select' in them. &lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2015 23:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-to-run-report/m-p/186391#M53672</guid>
      <dc:creator>emiller42</dc:creator>
      <dc:date>2015-03-14T23:29:48Z</dc:date>
    </item>
  </channel>
</rss>

