<?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: Splunk SDK for Ruby asynchronous search fail while connecting to load balancer in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-SDK-for-Ruby-asynchronous-search-fail-while-connecting-to/m-p/243369#M72432</link>
    <description>&lt;P&gt;Currently, Splunk does not have  necessary support for cookie authentication to the Ruby SDK. You can use Basic Authentication to do it, here is an example:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://github.com/splunk/splunk-sdk-ruby/blob/master/examples/connect_load_balanced_search_heads.rb"&gt;https://github.com/splunk/splunk-sdk-ruby/blob/master/examples/connect_load_balanced_search_heads.rb&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 19:44:15 GMT</pubDate>
    <dc:creator>rbal_splunk</dc:creator>
    <dc:date>2016-08-23T19:44:15Z</dc:date>
    <item>
      <title>Splunk SDK for Ruby asynchronous search fail while connecting to load balancer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-SDK-for-Ruby-asynchronous-search-fail-while-connecting-to/m-p/243368#M72431</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Issue : We don't see run async query using Ruby SDK against a Splunk 6.4 search head cluster via a BIG-IP load balancer.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Here is the sample Code.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require 'splunk-sdk-ruby'

# How to get to the Splunk server. Edit this to match your
# own Splunk install.
config = {
:scheme =&amp;gt; :https,
:host =&amp;gt; "localtest.com",
:port =&amp;gt; 8089,
:username =&amp;gt; "splunk.sensu",
:password =&amp;gt; "redacted"
}

# First open a connection to Splunk.
service = Splunk::connect(config)

# For longer running jobs, you don't want to wait until the job finishes, as
# create_oneshot in 3_blocking_searches.rb does. In this case, use the
# create_search method of Service. Instead of returning a stream, it creates
# an asynchronous job on the server and returns a Job object referencing it.
job = service.create_search("search index=_internal | head 1",
:earliest_time =&amp;gt; "-1d",
:latest_time =&amp;gt; "now")

# Before you can do anything with a Job, you must wait for it to be ready.
# Before it is, you cannot do anything with it, even read its state.
while !job.is_ready?()
sleep(0.1)
end

# More typically you will want to wait until the job is done and its events
# ready to retrieve. For that, use the is_done? method instead. Note that a
# job is always ready before it's done.
while !job.is_done?()
sleep(0.1)
end

# If you want the transformed results (equivalent to what create_oneshot would
# return), call the results method on the Job. If you want the untransformed
# results, call events. You can optionally pass an offset and total count,
# which are useful to get hunks of large sets of results.
stream = job.results(:count =&amp;gt; 1, :offset =&amp;gt; 0)
# Or: stream = job.events(:count =&amp;gt; 3, :offset =&amp;gt; 0)
results = Splunk::ResultsReader.new(stream)
results.each do |result|
puts result["_raw"]
end

# If you want to run a real time search, it must be asynchronous, and it is
# never done, so neither results or events will work. Instead, you must call
# preview (which takes the same arguments as the other two).
rt_job = service.create_search("search index=_internal | head 1",
:earliest_time =&amp;gt; "rt-1h",
:latest_time =&amp;gt; "rt")

while !rt_job.is_ready?()
sleep(0.1)
end

stream = rt_job.preview()
results = Splunk::ResultsReader.new(stream)
results.each do |result|
puts result["_raw"]
end
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:42:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-SDK-for-Ruby-asynchronous-search-fail-while-connecting-to/m-p/243368#M72431</guid>
      <dc:creator>sat94541</dc:creator>
      <dc:date>2016-08-23T19:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk SDK for Ruby asynchronous search fail while connecting to load balancer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-SDK-for-Ruby-asynchronous-search-fail-while-connecting-to/m-p/243369#M72432</link>
      <description>&lt;P&gt;Currently, Splunk does not have  necessary support for cookie authentication to the Ruby SDK. You can use Basic Authentication to do it, here is an example:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://github.com/splunk/splunk-sdk-ruby/blob/master/examples/connect_load_balanced_search_heads.rb"&gt;https://github.com/splunk/splunk-sdk-ruby/blob/master/examples/connect_load_balanced_search_heads.rb&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:44:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-SDK-for-Ruby-asynchronous-search-fail-while-connecting-to/m-p/243369#M72432</guid>
      <dc:creator>rbal_splunk</dc:creator>
      <dc:date>2016-08-23T19:44:15Z</dc:date>
    </item>
  </channel>
</rss>

