<?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: Use foreach, inputlookup, subsearch and index in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Use-foreach-inputlookup-subsearch-and-index/m-p/654050#M110897</link>
    <description>&lt;P&gt;Merge the queries, but it shows me the following&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m0rt1f4g0_0-1691748800699.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26759iEB1DB39901A6AA4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="m0rt1f4g0_0-1691748800699.png" alt="m0rt1f4g0_0-1691748800699.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query is as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;index=notable search_name="Endpoint - KTH*"&lt;BR /&gt;| fields tactic_mitre, technique_mitre, search_name&lt;BR /&gt;| stats count by technique_mitre, search_name&lt;BR /&gt;|eval codes_tech=technique_mitre&lt;BR /&gt;|makemv delim=", " codes_tech&lt;BR /&gt;|mvexpand codes_tech&lt;BR /&gt;|rename count as carry&lt;BR /&gt;|stats values(search_name) as search_name, sum(carry) as Total by codes_tech&lt;/P&gt;&lt;P&gt;|append [| inputlookup mitre_lookup&lt;BR /&gt;| foreach TA00*&lt;BR /&gt;[| lookup mitre_tt_lookup technique_id as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; OUTPUT technique_name as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name, 0)&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name . " - " . &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]&lt;BR /&gt;| join type=left codes_tech&lt;BR /&gt;[&lt;BR /&gt;| rename technique_id as TA0001, search_name as TA0001_rule_name_list, Total as TA0001_max_score ]&lt;BR /&gt;| fillnull value=search_name TA0001,TA0001_rule_name_list,TA0001_technique_name&lt;BR /&gt;| fillnull value=Total TA0001_attack_count,TA0001_max_score&lt;BR /&gt;| eval TA0001=TA0001."|".TA0001_technique_name."|".TA0001_rule_name_list."|".TA0001_max_score&lt;BR /&gt;| join type=left codes_tech&lt;BR /&gt;[&lt;BR /&gt;| rename technique_id as TA0003, search_name as TA0003_rule_name_list, Total as TA0003_max_score ]&lt;BR /&gt;| fillnull value=search_name TA0003,TA0003_rule_name_list,TA0003_technique_name&lt;BR /&gt;| fillnull value=Total TA0003_attack_count,TA0003_max_score&lt;BR /&gt;| eval TA0003=TA0003."|".TA0003_technique_name."|".TA0003_rule_name_list."|".TA0003_max_score]&lt;BR /&gt;&lt;BR /&gt;| rename TA0043 as "Reconnaissance", TA0042 as "Resource Development", TA0001 as "Initial Access", TA0002 as "Execution", TA0003 as "Persistence", TA0004 as "Privilege Escalation", TA0005 as "Defense Evasion", TA0006 as "Credential Access", TA0007 as "Discovery", TA0008 as "Lateral Movement", TA0009 as "Collection", TA0011 as "Command and Control", TA0010 as "Exfiltration", TA0040 as "Impact"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want the codes_tech data to look for it in the tactics columns and when it finds the codes_tech ID, put the value of search_name and total&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2023 10:15:35 GMT</pubDate>
    <dc:creator>m0rt1f4g0</dc:creator>
    <dc:date>2023-08-11T10:15:35Z</dc:date>
    <item>
      <title>Use foreach, inputlookup, subsearch and index</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-foreach-inputlookup-subsearch-and-index/m-p/654026#M110889</link>
      <description>&lt;P&gt;Hi Splunkers.&lt;BR /&gt;I've been trying for weeks to do the following:&lt;/P&gt;&lt;P&gt;I have a search that outputs a table with MITRE techniques as shown below:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;index=notable search_name="Endpoint - KTH*"&lt;BR /&gt;| fields tactic_mitre, technique_mitre, risk_mitre, src_user, user, Computer, dest, search_name&lt;BR /&gt;| stats count by technique_mitre&lt;BR /&gt;|eval codes_tech=technique_mitre&lt;BR /&gt;|makemv delim=", " codes_tech&lt;BR /&gt;|mvexpand codes_tech&lt;BR /&gt;|rename count as carry&lt;BR /&gt;|stats sum(carry) as Total by codes_tech&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m0rt1f4g0_0-1691742237905.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26757i2DBE7C243DAF8D56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="m0rt1f4g0_0-1691742237905.png" alt="m0rt1f4g0_0-1691742237905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And I have another query that brings me a table with the IDs and names of the Techniques and tactics of MITRE&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;| inputlookup mitre_lookup&lt;BR /&gt;| foreach TA00*&lt;BR /&gt;[| lookup mitre_tt_lookup technique_id as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; OUTPUT technique_name as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name, 0)&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name . " - " . &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]&lt;BR /&gt;| fields TA0043,TA0001, TA0002, TA0003, TA0004, TA0005, TA0006, TA0007, TA0008, TA0009, TA0011, TA0010, TA0040, TA0042&lt;BR /&gt;| rename TA0043 as "Reconnaissance", TA0042 as "Resource Development", TA0001 as "Initial Access", TA0002 as "Execution", TA0003 as "Persistence", TA0004 as "Privilege Escalation", TA0005 as "Defense Evasion", TA0006 as "Credential Access", TA0007 as "Discovery", TA0008 as "Lateral Movement", TA0009 as "Collection", TA0011 as "Command and Control", TA0010 as "Exfiltration", TA0040 as "Impact"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m0rt1f4g0_1-1691742347702.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26758iF137487057CA3E58/image-size/medium?v=v2&amp;amp;px=400" role="button" title="m0rt1f4g0_1-1691742347702.png" alt="m0rt1f4g0_1-1691742347702.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to search within the MITRE table for the &lt;STRONG&gt;codes_tech&lt;/STRONG&gt; of the first query and if Total is greater than 0 I would put the &lt;STRONG&gt;Total&lt;/STRONG&gt; and otherwise leave the other IDs at 0&lt;/P&gt;&lt;P&gt;Please, I really need your help, please, please, please...&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 08:28:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-foreach-inputlookup-subsearch-and-index/m-p/654026#M110889</guid>
      <dc:creator>m0rt1f4g0</dc:creator>
      <dc:date>2023-08-11T08:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use foreach, inputlookup, subsearch and index</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Use-foreach-inputlookup-subsearch-and-index/m-p/654050#M110897</link>
      <description>&lt;P&gt;Merge the queries, but it shows me the following&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m0rt1f4g0_0-1691748800699.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26759iEB1DB39901A6AA4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="m0rt1f4g0_0-1691748800699.png" alt="m0rt1f4g0_0-1691748800699.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query is as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;index=notable search_name="Endpoint - KTH*"&lt;BR /&gt;| fields tactic_mitre, technique_mitre, search_name&lt;BR /&gt;| stats count by technique_mitre, search_name&lt;BR /&gt;|eval codes_tech=technique_mitre&lt;BR /&gt;|makemv delim=", " codes_tech&lt;BR /&gt;|mvexpand codes_tech&lt;BR /&gt;|rename count as carry&lt;BR /&gt;|stats values(search_name) as search_name, sum(carry) as Total by codes_tech&lt;/P&gt;&lt;P&gt;|append [| inputlookup mitre_lookup&lt;BR /&gt;| foreach TA00*&lt;BR /&gt;[| lookup mitre_tt_lookup technique_id as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; OUTPUT technique_name as &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name=mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name, 0)&lt;BR /&gt;| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_technique_name . " - " . &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]&lt;BR /&gt;| join type=left codes_tech&lt;BR /&gt;[&lt;BR /&gt;| rename technique_id as TA0001, search_name as TA0001_rule_name_list, Total as TA0001_max_score ]&lt;BR /&gt;| fillnull value=search_name TA0001,TA0001_rule_name_list,TA0001_technique_name&lt;BR /&gt;| fillnull value=Total TA0001_attack_count,TA0001_max_score&lt;BR /&gt;| eval TA0001=TA0001."|".TA0001_technique_name."|".TA0001_rule_name_list."|".TA0001_max_score&lt;BR /&gt;| join type=left codes_tech&lt;BR /&gt;[&lt;BR /&gt;| rename technique_id as TA0003, search_name as TA0003_rule_name_list, Total as TA0003_max_score ]&lt;BR /&gt;| fillnull value=search_name TA0003,TA0003_rule_name_list,TA0003_technique_name&lt;BR /&gt;| fillnull value=Total TA0003_attack_count,TA0003_max_score&lt;BR /&gt;| eval TA0003=TA0003."|".TA0003_technique_name."|".TA0003_rule_name_list."|".TA0003_max_score]&lt;BR /&gt;&lt;BR /&gt;| rename TA0043 as "Reconnaissance", TA0042 as "Resource Development", TA0001 as "Initial Access", TA0002 as "Execution", TA0003 as "Persistence", TA0004 as "Privilege Escalation", TA0005 as "Defense Evasion", TA0006 as "Credential Access", TA0007 as "Discovery", TA0008 as "Lateral Movement", TA0009 as "Collection", TA0011 as "Command and Control", TA0010 as "Exfiltration", TA0040 as "Impact"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want the codes_tech data to look for it in the tactics columns and when it finds the codes_tech ID, put the value of search_name and total&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 10:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Use-foreach-inputlookup-subsearch-and-index/m-p/654050#M110897</guid>
      <dc:creator>m0rt1f4g0</dc:creator>
      <dc:date>2023-08-11T10:15:35Z</dc:date>
    </item>
  </channel>
</rss>

