Sha256: d286dc6c178f0c16b5a24635ea648c1350b7fe8f5b6f88d94de89bb36ab6795b

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 Bytes

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/plugin"
require "logstash/filters/elasticsearch"

describe LogStash::Filters::Elasticsearch, :integration => true do

  let(:config) do
    {
      "hosts" => ["localhost:9200"],
      "query" => "response: 404",
      "fields" => [ ["response", "code"] ],
    }
  end
  let(:plugin) { described_class.new(config) }
  let(:event)  { LogStash::Event.new({}) }

  before(:each) do
    plugin.register
  end

  it "should enhance the current event with new data" do
    plugin.filter(event)
    expect(event["code"]).to eq(404)
  end

  context "when retrieving a list of elements" do

    let(:config) do
      {
        "hosts" => ["localhost:9200"],
        "query" => "response: 404",
        "fields" => [ ["response", "code"] ],
        "result_size" => 10
      }
    end

    it "should enhance the current event with new data" do
      plugin.filter(event)
      expect(event["code"]).to eq([404]*10)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-filter-elasticsearch-2.1.1 spec/filters/integration/elasticsearch_spec.rb
logstash-filter-elasticsearch-2.1.0 spec/filters/integration/elasticsearch_spec.rb