<?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 do I split a SQL statement's query fields and relate each field with the app name? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557367#M158297</link>
    <description>&lt;P&gt;The first part before the blank lines uses makeresults to create some dummy data based on your post. The second part after the blank lines is the processing that would be applied to your real events. Perhaps you can share some more realistic examples of your log events so a more appropriate solution can be suggested? For events, it is more useful in you share the raw event data in a code block &amp;lt;/&amp;gt; so it can be copy/pasted into a makeresults section for me to test with.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jun 2021 08:22:17 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-06-28T08:22:17Z</dc:date>
    <item>
      <title>How do I split a SQL statement's query fields and relate each field with the app name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557306#M158289</link>
      <description>&lt;P&gt;I have a search result like below:&lt;/P&gt;&lt;P&gt;{&amp;nbsp;&lt;A href="https://splunkit.southernco.com:8000/en-US/app/devcoe/search?q=search%20index%3D%20scs_techsvcs_dss%20source%3D%22*ScCoolEmployeeWS.Business.Milestones.log%22%20%7C%20rex%20field%3D_raw%20%22s%2F%5E.*%20%7B%2F%7B%2F%22%20mode%3Dsed&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-24h%40h&amp;amp;latest=now&amp;amp;sid=1624574888.262776" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;dt&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;2021-06-24T22:46:40.7013297Z&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;flds&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;[&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://splunkit.southernco.com:8000/en-US/app/devcoe/search?q=search%20index%3D%20scs_techsvcs_dss%20source%3D%22*ScCoolEmployeeWS.Business.Milestones.log%22%20%7C%20rex%20field%3D_raw%20%22s%2F%5E.*%20%7B%2F%7B%2F%22%20mode%3Dsed&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-24h%40h&amp;amp;latest=now&amp;amp;sid=1624574888.262776" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://splunkit.southernco.com:8000/en-US/app/devcoe/search?q=search%20index%3D%20scs_techsvcs_dss%20source%3D%22*ScCoolEmployeeWS.Business.Milestones.log%22%20%7C%20rex%20field%3D_raw%20%22s%2F%5E.*%20%7B%2F%7B%2F%22%20mode%3Dsed&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-24h%40h&amp;amp;latest=now&amp;amp;sid=1624574888.262776" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;fn&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;username&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;nv&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;: LearningRegApplication&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://splunkit.southernco.com:8000/en-US/app/devcoe/search?q=search%20index%3D%20scs_techsvcs_dss%20source%3D%22*ScCoolEmployeeWS.Business.Milestones.log%22%20%7C%20rex%20field%3D_raw%20%22s%2F%5E.*%20%7B%2F%7B%2F%22%20mode%3Dsed&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-24h%40h&amp;amp;latest=now&amp;amp;sid=1624574888.262776" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;fn&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;dbQueries&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;nv&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SQL_QUERIES=Select emp.fieldA, emp.fieldB, emp.fieldC, emp.fieldD from Template.table emp WHERE (UPPER(emp.fieldA) = UPPER(:emp.fieldA)) AND (UPPER(emp.fieldB) = UPPER(:emp_fieldB)) AND (UPPER(emp.fieldC) IN (UPPER('aaa'), UPPER('bbb'), UPPER('ccc'), UPPER('ddd')))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;sf&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;EmployeeLogic&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;sid&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;T1-SECURITY-{A-8FE-76E9-C3A2-ED890B}&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;sm&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;GetAsync&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;stat&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Success&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;tid&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;yb6Any-PG00IG53&lt;/SPAN&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;I used&amp;nbsp; &amp;nbsp;|SPATH OUTPUT=status PATH=stat | SPATH OUTPUT=nv PATH=flds{}.nv | SPATH OUTPUT=fn PATH=flds{}.fn | Table fn nv host status.&amp;nbsp; The results return 4 columns.&amp;nbsp; Each row has the array of the 2 sets of key-value pair in the fn/nv stacked together.&amp;nbsp; &amp;nbsp;But host and status has only hostname and status values as follows:&lt;/P&gt;&lt;P&gt;fn&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nv&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; host&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;status&lt;/P&gt;&lt;P&gt;(Row 1) username&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;LearningRegApplication&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyHost&amp;nbsp; Success&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;(Row 1) dbQueries&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;SQL_QUERIES=Select emp.fieldA, emp.fieldB, emp.fieldC, emp.fieldD from Template.table emp WHERE (UPPER(emp.fieldA) = UPPER(:emp.fieldA)) AND (UPPER(emp.fieldB) = UPPER(:emp_fieldB)) AND (UPPER(emp.fieldC) IN (UPPER('aaa'), UPPER('bbb'), UPPER('ccc'), UPPER('ddd')))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And I have uploaded a CSV file that contains all query fields name.&amp;nbsp; I want to see each field was queried by which application and insert them in that field row (not sure what is the best way to present this information).&amp;nbsp; So the output may look like something below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldA&amp;nbsp;&amp;nbsp;LearningRegApplication&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldB&amp;nbsp;&amp;nbsp;LearningRegApplication, AThirdApp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldC&amp;nbsp;&amp;nbsp;LearningRegApplication, ASecondApp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldD&amp;nbsp;&amp;nbsp;LearningRegApplication&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldE&amp;nbsp;&amp;nbsp;ASecondApp, AThirdApp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fieldF&amp;nbsp;&amp;nbsp;AForthApp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What is the way to use the full CSV list of field names to&amp;nbsp;insert the app to each SQL field name?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 19:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557306#M158289</guid>
      <dc:creator>rilee</dc:creator>
      <dc:date>2021-06-27T19:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a SQL statement's query fields and relate each field with the app name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557310#M158290</link>
      <description>&lt;P&gt;Will some of this help?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{
   \"dt\": \"2021-06-24T22:46:40.7013297Z\",
   \"flds\": [
     {
       \"fn\": \"username\",
       \"nv\": \"LearningRegApplication\"
     },
     {
       \"fn\": \"dbQueries\",
       \"nv\": \"SQL_QUERIES=Select emp.fieldA, emp.fieldB, emp.fieldC, emp.fieldD from Template.table emp WHERE (UPPER(emp.fieldA) = UPPER(:emp.fieldA)) AND (UPPER(emp.fieldB) = UPPER(:emp_fieldB)) AND (UPPER(emp.fieldC) IN (UPPER('aaa'), UPPER('bbb'), UPPER('ccc'), UPPER('ddd')))\"
     }
   ],
   \"sf\": \"EmployeeLogic\",
   \"sid\": \"T1-SECURITY-{A-8FE-76E9-C3A2-ED890B}\",
   \"sm\": \"GetAsync\",
   \"stat\": \"Success\",
   \"tid\": \"yb6Any-PG00IG53\"
}"



| spath output=status path=stat
| spath output=nv path=flds{}.nv
| spath output=fn path=flds{}.fn
| table fn nv host status
| eval fieldname=mvindex(fn,0)
| eval {fieldname}=mvindex(nv,0)
| eval fieldname=mvindex(fn,1)
| eval {fieldname}=mvindex(nv,1)
| fields - fn nv
| rex field=dbQueries "(?i)select\s+(?&amp;lt;columns&amp;gt;.*)\s+from"
| eval column=split(columns,", ")
| mvexpand column&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 27 Jun 2021 20:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557310#M158290</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-27T20:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a SQL statement's query fields and relate each field with the app name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557330#M158295</link>
      <description>&lt;P&gt;Thank you for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand the syntax you shared but&amp;nbsp;I am not sure how to incorporate the syntax.&amp;nbsp; (Reading now more examples for |makeresults usage.)&amp;nbsp; I appended your lines after my initial lines (that yielded many rows of results):&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index="my_index"&lt;BR /&gt;(host="host1*" OR host="host2" OR host="host3" OR host="host4")&lt;BR /&gt;source="*Business.Milestones.log"&lt;BR /&gt;| rex field=_raw "s/^.* {/{/" mode=sed&lt;/P&gt;&lt;P&gt;Execution error tells me&amp;nbsp;&lt;STRONG&gt;| Makeresults&lt;/STRONG&gt; needs to be the first command in search.&lt;/P&gt;&lt;P&gt;What I showed in Json is&amp;nbsp;from the first row of the returned results.&amp;nbsp; The search has many rows returned with the SQL statement dynamically generated. So the column count will vary.&amp;nbsp; Will the |Makeresults syntax able to translate that?&amp;nbsp; And I need to fill(append) the application names ((nv,0)) in each column((nv,1).&amp;nbsp; If I make the results working, how to&amp;nbsp;make the metrics to summarize desired final output?&amp;nbsp; e.g.:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="17.741935483870968%"&gt;&lt;P&gt;columnA&lt;/P&gt;&lt;/TD&gt;&lt;TD width="82.25806451612904%"&gt;app1, app2, etc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.741935483870968%"&gt;ColumnB&lt;/TD&gt;&lt;TD width="82.25806451612904%"&gt;app2, app4, etc.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.741935483870968%"&gt;&lt;P&gt;etc. As many columns&lt;/P&gt;&lt;/TD&gt;&lt;TD width="82.25806451612904%"&gt;whichever apps request for whatever columns&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 05:05:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557330#M158295</guid>
      <dc:creator>rilee</dc:creator>
      <dc:date>2021-06-28T05:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a SQL statement's query fields and relate each field with the app name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557367#M158297</link>
      <description>&lt;P&gt;The first part before the blank lines uses makeresults to create some dummy data based on your post. The second part after the blank lines is the processing that would be applied to your real events. Perhaps you can share some more realistic examples of your log events so a more appropriate solution can be suggested? For events, it is more useful in you share the raw event data in a code block &amp;lt;/&amp;gt; so it can be copy/pasted into a makeresults section for me to test with.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 08:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557367#M158297</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-28T08:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a SQL statement's query fields and relate each field with the app name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557386#M158300</link>
      <description>&lt;P&gt;Got it, I see something new.&amp;nbsp; One step at a time.&amp;nbsp; Just started Splunking for less than 7 days.&amp;nbsp; &amp;nbsp;Hopefully one day can be as powerful as you all.&amp;nbsp; So I can also whisper without too much sweat!&amp;nbsp; ^_^ Later.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 09:32:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-SQL-statement-s-query-fields-and-relate-each/m-p/557386#M158300</guid>
      <dc:creator>rilee</dc:creator>
      <dc:date>2021-06-28T09:32:14Z</dc:date>
    </item>
  </channel>
</rss>

