<?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: Splunk Table Query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/666069#M228502</link>
    <description>&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2023 19:59:31 GMT</pubDate>
    <dc:creator>Awanish1212</dc:creator>
    <dc:date>2023-10-24T19:59:31Z</dc:date>
    <item>
      <title>Splunk Table Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/661141#M228261</link>
      <description>&lt;P&gt;These are the sample parameters for index, host, source&lt;/P&gt;&lt;P&gt;index="production"&lt;BR /&gt;host="abc.com-i-1234"&lt;BR /&gt;source="Log-*-3333-abc4j.log"&lt;/P&gt;&lt;P&gt;Suppose there are three Splunk queries as shown below:&lt;BR /&gt;----------------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;index="production" host="abc.com-*" source="Log-*" | eval ID=substr(host,9,7) | dedup ID| table ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Suppose it gives output as :&lt;/P&gt;&lt;TABLE border="0" width="64" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="19"&gt;ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-5678&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-9123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-4567&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------------------------&lt;BR /&gt;&lt;STRONG&gt;Query 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;index="production" host="abc.com-$field2$" source="Log-*-*-abc4j.log" | eval Sub_ID = mvindex(split(source,"-"),2) | dedup Sub_ID | table Sub_ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Suppose it gives output as :&lt;/P&gt;&lt;TABLE border="0" width="64" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="19"&gt;Sub_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;222&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;3333&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;4444&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;555&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;666&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;7777&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;8888&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where, $field2$ denotes the "ID" generated from Query 1 and each "ID" from Query 1 is mapped to two values of "Sub_ID" generated from Query 2.&lt;/P&gt;&lt;P&gt;E.g&lt;BR /&gt;if the query was-&lt;BR /&gt;index="production" host="abc.com-i-1234" source="Log-*-*-abc4j.log" | eval Sub_ID = mvindex(split(source,"-"),2) | dedup Sub_ID | table Sub_ID&lt;/P&gt;&lt;P&gt;it will give output as:&lt;/P&gt;&lt;TABLE border="0" width="64" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="19"&gt;Sub_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;222&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;-------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query 3:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;index="production" host="abc.com-$field2$" source="Log-*-$field3$-log4j.log" | dedup RP_Remote_User | table RP_Remote_User | stats count as events&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Suppose it gives output as :&lt;BR /&gt;events:&lt;BR /&gt;52&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;where, $field2$ denotes the "ID" generated from query 1 and $field3$ denotes the "Sub_ID" generated from Query 2&lt;/P&gt;&lt;P&gt;E.g&lt;BR /&gt;if the query was-&lt;BR /&gt;index="production" host="abc.com-i-1234" source="Log-*-3333-log4j.log" | dedup RP_Remote_User | table RP_Remote_User | stats count as events&lt;/P&gt;&lt;P&gt;it will give output as: (on the basis of "ID" : i-1234 and "Sub_ID":3333)&lt;BR /&gt;events:&lt;BR /&gt;52&lt;/P&gt;&lt;P&gt;---------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Could you please help me with the Splunk query to generate the output in tabular format as below (count of events corresponding to each ID and its Sub_ID) with the help of above mentioned three queries:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="0" width="192" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="19"&gt;ID&lt;/TD&gt;&lt;TD width="64"&gt;Sub_ID&lt;/TD&gt;&lt;TD width="64"&gt;Events&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-1234&lt;/TD&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;38&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;222&lt;/TD&gt;&lt;TD&gt;48&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-5678&lt;/TD&gt;&lt;TD&gt;3333&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4444&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-9123&lt;/TD&gt;&lt;TD&gt;555&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;666&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;i-4567&lt;/TD&gt;&lt;TD&gt;7777&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;8888&lt;/TD&gt;&lt;TD&gt;29&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 07:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/661141#M228261</guid>
      <dc:creator>Awanish1212</dc:creator>
      <dc:date>2023-10-18T07:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Table Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/666040#M228492</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258647"&gt;@Awanish1212&lt;/a&gt;&amp;nbsp;- Try below&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="production" host="abc.com-*" source="Log-*"
| eval ID=substr(host,9,7)
| eval Sub_ID = mvindex(split(source,"-"),2)
| stats dc(RP_Remote_User) as events by ID, Sub_ID
| stats list(Sub_ID) as Sub_ID, list(events) as events by ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!!! Kindly upvote if it does!!!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 16:47:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/666040#M228492</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2023-10-24T16:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Table Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/666069#M228502</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 19:59:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Table-Query/m-p/666069#M228502</guid>
      <dc:creator>Awanish1212</dc:creator>
      <dc:date>2023-10-24T19:59:31Z</dc:date>
    </item>
  </channel>
</rss>

