<?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 How to search Splunk API from a remote host with Forwarder installed via CLI with user and password in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-Splunk-API-from-a-remote-host-with-Forwarder/m-p/230543#M68354</link>
    <description>&lt;P&gt;If you wish to Search the API via command line (using the Splunk Binary included in the Forwarder package for example) it is executed as follows:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/bin/splunk search 'yoursearch' -uri 'https://splunkAPI_Instance:8089/'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works great on its own, however, prompts for User &amp;amp; Password on execution.  Making scripted extraction of splunk data to export to local file called from a cron job or otherwise difficult.&lt;/P&gt;

&lt;P&gt;My Question is, how can you execute the same and provide the username &amp;amp; password the way one might with CURL or WGET in the command request itself?&lt;/P&gt;

&lt;P&gt;CURL  example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:pass &lt;A href="https://splunkAPI_Instance:8089/services/saved/searches" target="test_blank"&gt;https://splunkAPI_Instance:8089/services/saved/searches&lt;/A&gt; \
     -d name=MySavedSearch                                           \ 
     --data-urlencode search="index=_internal source=*metrics.log"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;CURL outlined in Splunk Documentation References:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I can't seem to find any documentation (in this REST User doc or otherwise) around passing the username &amp;amp; password via command line when specifically leveraging the splunk forwarder/binary.   (Without also the SDK and adding Python or Ruby to the mix).&lt;/P&gt;

&lt;P&gt;Side note:  CURL &amp;amp; WGET are prohibited from being installed on the server where the forwarder in this scenario happens to exist, so it would be ideal to use the forwarder installation itself to perform the search since it is already there and available to local users of that (unix) system.&lt;/P&gt;

&lt;P&gt;Once solution identified, the following should be updated to reflect the same information:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/AboutCLIsearches"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/AboutCLIsearches&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/RESTTUT/RESTsearches"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/RESTTUT/RESTsearches&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing#Authentication_and_authorization"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing#Authentication_and_authorization&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2016 22:14:05 GMT</pubDate>
    <dc:creator>watkinst</dc:creator>
    <dc:date>2016-03-02T22:14:05Z</dc:date>
    <item>
      <title>How to search Splunk API from a remote host with Forwarder installed via CLI with user and password</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-Splunk-API-from-a-remote-host-with-Forwarder/m-p/230543#M68354</link>
      <description>&lt;P&gt;If you wish to Search the API via command line (using the Splunk Binary included in the Forwarder package for example) it is executed as follows:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/bin/splunk search 'yoursearch' -uri 'https://splunkAPI_Instance:8089/'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works great on its own, however, prompts for User &amp;amp; Password on execution.  Making scripted extraction of splunk data to export to local file called from a cron job or otherwise difficult.&lt;/P&gt;

&lt;P&gt;My Question is, how can you execute the same and provide the username &amp;amp; password the way one might with CURL or WGET in the command request itself?&lt;/P&gt;

&lt;P&gt;CURL  example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:pass &lt;A href="https://splunkAPI_Instance:8089/services/saved/searches" target="test_blank"&gt;https://splunkAPI_Instance:8089/services/saved/searches&lt;/A&gt; \
     -d name=MySavedSearch                                           \ 
     --data-urlencode search="index=_internal source=*metrics.log"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;CURL outlined in Splunk Documentation References:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I can't seem to find any documentation (in this REST User doc or otherwise) around passing the username &amp;amp; password via command line when specifically leveraging the splunk forwarder/binary.   (Without also the SDK and adding Python or Ruby to the mix).&lt;/P&gt;

&lt;P&gt;Side note:  CURL &amp;amp; WGET are prohibited from being installed on the server where the forwarder in this scenario happens to exist, so it would be ideal to use the forwarder installation itself to perform the search since it is already there and available to local users of that (unix) system.&lt;/P&gt;

&lt;P&gt;Once solution identified, the following should be updated to reflect the same information:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/AboutCLIsearches"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/AboutCLIsearches&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/RESTTUT/RESTsearches"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/RESTTUT/RESTsearches&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing#Authentication_and_authorization"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/RESTUM/RESTusing#Authentication_and_authorization&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 22:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-Splunk-API-from-a-remote-host-with-Forwarder/m-p/230543#M68354</guid>
      <dc:creator>watkinst</dc:creator>
      <dc:date>2016-03-02T22:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to search Splunk API from a remote host with Forwarder installed via CLI with user and password</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-Splunk-API-from-a-remote-host-with-Forwarder/m-p/230544#M68355</link>
      <description>&lt;P&gt;Hi watkinst,&lt;/P&gt;

&lt;P&gt;your can use the &lt;CODE&gt;-auth&lt;/CODE&gt; switch with your remote search command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/opt/splunkforwarder/bin/splunk search 'index=_internal' -uri 'https://someremoteip:8089' -auth admin:changeme
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just remember that you have to allow remote login on the remote Splunk instance in &lt;CODE&gt;server.conf&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;allowRemoteLogin=always
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;read the docs for more details on this &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Admin/AccessandusetheCLIonaremoteserver"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Admin/AccessandusetheCLIonaremoteserver&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 23:03:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-Splunk-API-from-a-remote-host-with-Forwarder/m-p/230544#M68355</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-03-02T23:03:35Z</dc:date>
    </item>
  </channel>
</rss>

