<?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 Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146806#M29903</link>
    <description>&lt;P&gt;Using Splunk Enterprise 6.2.1 along with the latest version of the splunk-reskit-powershell toolkit, I (and others on my team with local installations of Splunk Enterprise) are having trouble automating the creation of an index using &lt;CODE&gt;New-SplunkIndex&lt;/CODE&gt;. The code looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Import-Module Splunk
Disable-CertificateValidation
Connect-Splunk -ComputerName $env:COMPUTERNAME -Protocol https -Port 8089
New-SplunkIndex -Name test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The error message:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Invoke-HTTPPost : Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (400) Bad Request."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using verbose output, we get this response:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;response&amp;gt;
  &amp;lt;messages&amp;gt;
   &amp;lt;msg type="ERROR"&amp;gt;
 In handler 'indexes': Argument "search" is not supported by this handler.&amp;lt;/msg&amp;gt;
  &amp;lt;/messages&amp;gt;
&amp;lt;/response&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Digging into the verbose output, we can see the data being POST'ed to the Splunk endpoint:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;VERBOSE:  [Invoke-HTTPPost] :: $PostString = search=&amp;amp;name=test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We were able to dig into Splunk-Core.psm1, modify the &lt;CODE&gt;Invoke-HttpPost&lt;/CODE&gt; function, and get past this error. We did so by essentially commenting out &lt;A href="https://github.com/splunk/splunk-reskit-powershell/blob/master/Source/Splunk/Splunk-Core/Splunk-Core.psm1#L224"&gt;line 224&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;Based on our limited research, it seems like the core &lt;CODE&gt;Invoke-HTTPPost&lt;/CODE&gt; method always includes a &lt;CODE&gt;search&lt;/CODE&gt; value within message body being POST'ed; however, the REST endpoint for creating a new index rejects the &lt;CODE&gt;search&lt;/CODE&gt; parameter.&lt;/P&gt;

&lt;P&gt;Is there a different way we should be using the toolkit to create an index, or is this a bug within the toolkit itself?&lt;/P&gt;</description>
    <pubDate>Wed, 18 Feb 2015 21:45:10 GMT</pubDate>
    <dc:creator>broccliman</dc:creator>
    <dc:date>2015-02-18T21:45:10Z</dc:date>
    <item>
      <title>Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146806#M29903</link>
      <description>&lt;P&gt;Using Splunk Enterprise 6.2.1 along with the latest version of the splunk-reskit-powershell toolkit, I (and others on my team with local installations of Splunk Enterprise) are having trouble automating the creation of an index using &lt;CODE&gt;New-SplunkIndex&lt;/CODE&gt;. The code looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Import-Module Splunk
Disable-CertificateValidation
Connect-Splunk -ComputerName $env:COMPUTERNAME -Protocol https -Port 8089
New-SplunkIndex -Name test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The error message:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Invoke-HTTPPost : Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (400) Bad Request."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using verbose output, we get this response:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;response&amp;gt;
  &amp;lt;messages&amp;gt;
   &amp;lt;msg type="ERROR"&amp;gt;
 In handler 'indexes': Argument "search" is not supported by this handler.&amp;lt;/msg&amp;gt;
  &amp;lt;/messages&amp;gt;
&amp;lt;/response&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Digging into the verbose output, we can see the data being POST'ed to the Splunk endpoint:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;VERBOSE:  [Invoke-HTTPPost] :: $PostString = search=&amp;amp;name=test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We were able to dig into Splunk-Core.psm1, modify the &lt;CODE&gt;Invoke-HttpPost&lt;/CODE&gt; function, and get past this error. We did so by essentially commenting out &lt;A href="https://github.com/splunk/splunk-reskit-powershell/blob/master/Source/Splunk/Splunk-Core/Splunk-Core.psm1#L224"&gt;line 224&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;Based on our limited research, it seems like the core &lt;CODE&gt;Invoke-HTTPPost&lt;/CODE&gt; method always includes a &lt;CODE&gt;search&lt;/CODE&gt; value within message body being POST'ed; however, the REST endpoint for creating a new index rejects the &lt;CODE&gt;search&lt;/CODE&gt; parameter.&lt;/P&gt;

&lt;P&gt;Is there a different way we should be using the toolkit to create an index, or is this a bug within the toolkit itself?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 21:45:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146806#M29903</guid>
      <dc:creator>broccliman</dc:creator>
      <dc:date>2015-02-18T21:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146807#M29904</link>
      <description>&lt;P&gt;It is a bug (created &lt;A href="https://github.com/splunk/splunk-reskit-powershell/issues/13"&gt;issue #13&lt;/A&gt;). Submit a pull request or open an issue if you'd like credit for the fix: &lt;A href="https://github.com/splunk/splunk-reskit-powershell"&gt;https://github.com/splunk/splunk-reskit-powershell&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The toolkit is open source, and in need of refactoring to use our v2 .NET SDK. Chip in if that's something you're interested in helping with.&lt;/P&gt;

&lt;P&gt;Great troubleshooting, by the way!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 00:15:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146807#M29904</guid>
      <dc:creator>halr9000</dc:creator>
      <dc:date>2015-02-20T00:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146808#M29905</link>
      <description>&lt;P&gt;Thanks for the response. Although this doesn't change my situation, you did answer my question - marking this as the answer.&lt;/P&gt;

&lt;P&gt;I would submit a PR, but my change lacks the context of the larger use of &lt;CODE&gt;Invoke-HTTPPost&lt;/CODE&gt;; I think its too narrow-sighted. Instead, we will move forward by implementing our own version of &lt;CODE&gt;New-SplunkIndex&lt;/CODE&gt; using HTTP against the REST API.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 01:22:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146808#M29905</guid>
      <dc:creator>broccliman</dc:creator>
      <dc:date>2015-02-20T01:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146809#M29906</link>
      <description>&lt;P&gt;Makes sense. I do hope we come back to this project for a refresh. Adding a reminder for myself to look into it.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 03:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146809#M29906</guid>
      <dc:creator>halr9000</dc:creator>
      <dc:date>2015-02-20T03:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.2.1 with Splunk PowerShell Resource Kit: How to automate the creation of an index using New-SplunkIndex?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146810#M29907</link>
      <description>&lt;P&gt;Just checked out the code and confirmed the bug. I created an issue to track this as well: &lt;A href="https://github.com/splunk/splunk-reskit-powershell/issues/13"&gt;https://github.com/splunk/splunk-reskit-powershell/issues/13&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 16:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-6-2-1-with-Splunk-PowerShell-Resource-Kit-How-to-automate/m-p/146810#M29907</guid>
      <dc:creator>halr9000</dc:creator>
      <dc:date>2015-02-20T16:16:36Z</dc:date>
    </item>
  </channel>
</rss>

