Skip to content

Instantly share code, notes, and snippets.

@mattgray
Last active December 28, 2015 16:09
Show Gist options
  • Save mattgray/7526622 to your computer and use it in GitHub Desktop.
Save mattgray/7526622 to your computer and use it in GitHub Desktop.
Logstash spec generator with nested fields
describe "can handle fields that are are objects" do
tmpfile = Tempfile.new('logstash-spec-output-csv')
config <<-CONFIG
input {
generator {
message => "{\"foo\":{\"one\":\"two\"},\"baz\": \"quux\"}"
count => 1
}
}
output {
csv {
path => "#{tmpfile.path}"
fields => ["foo", "baz"]
}
}
CONFIG
agent do
lines = CSV.read(tmpfile.path)
insist {lines.count} == 1
insist {lines[0][0]} == "one\ntwo"
end
end
Failures:
1) LogStash::Outputs::CSV can handle fields that are are objects agent(/home/mattg/logstash/spec/outputs/csv.rb:147:in) runs
Failure/Error: pipeline = LogStash::Pipeline.new(config)
LogStash::ConfigurationError:
Expected one of #, {, } at line 3, column 25 (byte 59) after input {
generator {
message => "{"
# ./lib/logstash/pipeline.rb:16:in `initialize'
# ./spec/test_utils.rb:108:in `agent'
# ./lib/logstash/runner.rb:149:in `run'
Finished in 15.47 seconds
6 examples, 1 failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment