mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
avoid resetting inexisting tags field back to empty array plus specs
Fixes #6477
This commit is contained in:
parent
733a546e9e
commit
eb00b0da4c
2 changed files with 18 additions and 3 deletions
|
@ -34,8 +34,9 @@ module LogStash::Util
|
|||
|
||||
# tags is an array of string. sprintf syntax can be used.
|
||||
def add_tags(new_tags, event, pluginname)
|
||||
tags = event.get("tags")
|
||||
tags = tags.nil? ? [] : Array(tags)
|
||||
return if new_tags.empty?
|
||||
|
||||
tags = Array(event.get("tags")) # note that Array(nil) => []
|
||||
|
||||
new_tags.each do |new_tag|
|
||||
new_tag = event.sprintf(new_tag)
|
||||
|
|
|
@ -248,7 +248,21 @@ describe LogStash::Filters::NOOP do
|
|||
end
|
||||
end
|
||||
|
||||
describe "remove_field on deep objects" do
|
||||
describe "remove_field on tags" do
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
noop {
|
||||
remove_field => ["tags"]
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
sample("tags" => "foo") do
|
||||
reject { subject }.include?("tags")
|
||||
end
|
||||
end
|
||||
|
||||
describe "remove_field on deep objects" do
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
noop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue