<?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 to use @myFile.spl to query Splunk API? in Security</title>
    <link>https://community.splunk.com/t5/Security/How-to-use-myFile-spl-to-query-Splunk-API/m-p/658434#M17294</link>
    <description>&lt;P&gt;Hello All&lt;/P&gt;&lt;P&gt;I was able to solve this issue, I was digging on cURL capabilities and the answer is cURL -K configFile.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Below is how it works:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;First suppose you require to send an extremely long query to Splunk API from your app or script with your cURL command (SPL search command in my case 121852 chars)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;1. curl command&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;curl -K query.spl --noproxy '*' -H "Authorization: Splunk &lt;STRONG&gt;myTOKEN&lt;/STRONG&gt;" https://&lt;STRONG&gt;mySearchHEAD&lt;/STRONG&gt;:8089/servicesNS/admin/search/search/jobs&amp;nbsp;&lt;/P&gt;&lt;P&gt;### --noproxy '*' it is optional and depends on your network setup&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;2. Your config file query.spl content and synaxis&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[someUser@algunServidor:~/myDirectorio]$ more query.spl&lt;BR /&gt;&lt;BR /&gt;-d exec_mode=oneshot&amp;nbsp; &amp;nbsp;## this can be &lt;STRONG&gt;normal&lt;/STRONG&gt;&lt;BR /&gt;-d output_mode=json&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;## this can &lt;STRONG&gt;be xml or csv&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;-d &lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;search=&lt;STRONG&gt;| search index=myIndex sourcetype=mySourcetype _raw=*somethingIamLooking for* field1=something1 field2=something2 .... fieldN=somethingN earliest=-1h latest=now&lt;/STRONG&gt;&lt;FONT size="6" color="#FF0000"&gt;&lt;FONT size="5"&gt;"&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6" color="#800080"&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;### really important to pay attention to the quotes in red above you need them to make it work.&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6" color="#000000"&gt;&lt;FONT size="3"&gt;I hope this help someone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2023 14:41:04 GMT</pubDate>
    <dc:creator>victorsalazar</dc:creator>
    <dc:date>2023-09-22T14:41:04Z</dc:date>
    <item>
      <title>How to use @myFile.spl to query Splunk API?</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-myFile-spl-to-query-Splunk-API/m-p/658021#M17288</link>
      <description>&lt;P&gt;Hello All&lt;/P&gt;
&lt;P&gt;I need to send a request to Splunk API from a Linux server but the Curl is complaining because the search argument is too long (could be up to 500000 chars). my question is: &lt;STRONG&gt;how we can use&amp;nbsp;@myFile.spl to query splunk api?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is what I have done so far but no luck yet&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;curl --noproxy '*' -k -H "Authorization: Splunk myToken" &lt;A href="https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json" target="_blank" rel="noopener"&gt;https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json&lt;/A&gt; -d search=`echo $myVar`&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#800000"&gt;error&amp;nbsp; Argument list too long&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;curl --noproxy '*' -k -H "Authorization: Splunk myToken" &lt;A href="https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json" target="_blank" rel="noopener"&gt;https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json&lt;/A&gt; -d &amp;nbsp;@query2.spl&amp;nbsp; (&lt;STRONG&gt;&lt;FONT color="#008000"&gt;Format1 in query2.spl&amp;nbsp;file&lt;/FONT&gt;&lt;/STRONG&gt;--&amp;gt; "search= | search index=myIndex ...."&amp;nbsp; &amp;nbsp; up to 500000 char)&lt;BR /&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;error&amp;nbsp;{"messages":[{"type":"FATAL","text":"Empty search."}]}&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;curl --noproxy '*' -k -H "Authorization: Splunk myToken"&amp;nbsp;&lt;BR /&gt;&lt;A href="https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json" target="_blank" rel="noopener"&gt;https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json&lt;/A&gt; -d&amp;nbsp; @query2.spl&amp;nbsp; (&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Format2 in query2.spl file --&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt; search= "| search index=myIndex ...."&amp;nbsp; &amp;nbsp; up to 500000 char -- difference with 3 is quotes position)&lt;BR /&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;error&amp;nbsp;{"messages":[{"type":"ERROR","text":"Error in 'SearchParser': Missing a search command before '\"'. Error at position '0' of search query '\"| search index...."&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;curl --noproxy '*' -k -H "Authorization: Splunk myToken" &lt;A href="https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json" target="_blank" rel="noopener"&gt;https://mySearchHead:8089/servicesNS/admin/search/search/jobs/export?output_mode=json&lt;/A&gt; -d search=@query2.spl&amp;nbsp;&amp;nbsp;&lt;BR /&gt;(&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Format2 in query2.spl file --&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;"| search index=myIndex ...."&amp;nbsp; &amp;nbsp; up to 500000 char -- difference with 3 is quotes position)&lt;BR /&gt;&lt;FONT color="#800000"&gt;&lt;STRONG&gt;error&amp;nbsp;{"messages":[{"type":"ERROR","text":"Error in 'SearchParser': Missing a search command before '@'. Error at position '0' of search query '@query2.spl'.","help":""}]}&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 20 Sep 2023 19:46:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-myFile-spl-to-query-Splunk-API/m-p/658021#M17288</guid>
      <dc:creator>victorsalazar</dc:creator>
      <dc:date>2023-09-20T19:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use @myFile.spl to query Splunk API?</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-myFile-spl-to-query-Splunk-API/m-p/658434#M17294</link>
      <description>&lt;P&gt;Hello All&lt;/P&gt;&lt;P&gt;I was able to solve this issue, I was digging on cURL capabilities and the answer is cURL -K configFile.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Below is how it works:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;First suppose you require to send an extremely long query to Splunk API from your app or script with your cURL command (SPL search command in my case 121852 chars)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;1. curl command&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;curl -K query.spl --noproxy '*' -H "Authorization: Splunk &lt;STRONG&gt;myTOKEN&lt;/STRONG&gt;" https://&lt;STRONG&gt;mySearchHEAD&lt;/STRONG&gt;:8089/servicesNS/admin/search/search/jobs&amp;nbsp;&lt;/P&gt;&lt;P&gt;### --noproxy '*' it is optional and depends on your network setup&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;2. Your config file query.spl content and synaxis&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[someUser@algunServidor:~/myDirectorio]$ more query.spl&lt;BR /&gt;&lt;BR /&gt;-d exec_mode=oneshot&amp;nbsp; &amp;nbsp;## this can be &lt;STRONG&gt;normal&lt;/STRONG&gt;&lt;BR /&gt;-d output_mode=json&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;## this can &lt;STRONG&gt;be xml or csv&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;-d &lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;search=&lt;STRONG&gt;| search index=myIndex sourcetype=mySourcetype _raw=*somethingIamLooking for* field1=something1 field2=something2 .... fieldN=somethingN earliest=-1h latest=now&lt;/STRONG&gt;&lt;FONT size="6" color="#FF0000"&gt;&lt;FONT size="5"&gt;"&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6" color="#800080"&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;### really important to pay attention to the quotes in red above you need them to make it work.&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6" color="#000000"&gt;&lt;FONT size="3"&gt;I hope this help someone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 14:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-myFile-spl-to-query-Splunk-API/m-p/658434#M17294</guid>
      <dc:creator>victorsalazar</dc:creator>
      <dc:date>2023-09-22T14:41:04Z</dc:date>
    </item>
  </channel>
</rss>

