Ruby Filter URI Request

Hi Guys,

I have a little problem here and I just really don't know what I'm missing because it's my first time using ruby filter. No result is coming from the output stdout. Hope you can help me.

Here's my only data.

{
  "took" : 41,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "name" : "ruby_test"
        }
      }
    ]
  }
}

My goal is to get request one of our indices. Here's my logstash pipeline I've created.

filter {
	ruby {
			init => '
				
				uri = URI.parse("
					https://username:password@localhost:9200/test_index/_search?q=name=ruby_test&filter_path=hits.hits._source
					
					")
				req_options = {
					use_ssl:uri.scheme == "https",
				}
				
				response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
                                http.request(request)
				
				end
			'
	}
}
output {
        stdout {}
}

Thanks,
Ruru anne

Did you leave it out in your post or does your pipeline not have an input section? Without an input there is no data to filter, so I would expect it to do nothing.

And is there a specific reason why you are trying to query ES with a Ruby filter instead of using an ES input plugin (if the answer to my first question is that there is no input) or an ES filter (if there is an input that you had not mentioned)?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.