All Apps and Add-ons

Error on attempting to use Splunk SDK for Ruby

ashishnarmen
New Member

I am getting the following error on trying to create a one shot search using the SPLUNK SDK for Ruby

NoMethodError in MyControllerController#my_method
undefined method hostname' for #<URI::HTTPS:0x007fb38d0179d8>
Application Trace | Framework Trace | Full Trace
splunk-sdk-ruby (0.1.0) lib/splunk-sdk-ruby/context.rb:398:in
request_by_url'
splunk-sdk-ruby (0.1.0) lib/splunk-sdk-ruby/context.rb:318:in request'
splunk-sdk-ruby (0.1.0) lib/splunk-sdk-ruby/context.rb:201:in
login'
splunk-sdk-ruby (0.1.0) lib/splunk-sdk-ruby/service.rb:78:in `connect'

The following is the code that I am using

 config = {
          :scheme => :https,
          :host => "servername",
          :port => 8089,
          :username => "username",
          :password => "password"
      }
service = Splunk::Service.new(config).login()

Has someone run into something similar. Could this be occurring because, I am hosting my application on http and attempting to connect to https.

Tags (1)
0 Karma

splunkedyou
New Member

You need to upgrade to ruby 1.9.3 since the host method is not available in ruby versions before that. Also, I had to use the :protocol parameter instead of the :scheme for it to work. Hope it helps! Good Luck!

0 Karma

ashishnarmen
New Member

Thanks, let me try that out.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...