[英]Logstash to elasticsearch. Keys with dots
我遇到了logstash配置问题。 您可以在下面找到我的logstash配置。
Ruby过滤器删除每个点-“。” 从我的领域。 似乎每个方法都可以正常工作-数据过滤的结果是正确的,但是elasticsearch神奇地响应: "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"Field name [/ConsumerAdminWebService/getConsumerTransactions.call] cannot contain '.'"}
,其中getConsumerTransactions.call
是我的字段键之一。
input {
http_poller {
urls => {
uatBackend1 => {
method => get
url => "http://some-url/"
headers => {
Accept => "application/json"
}
}
}
request_timeout => 60
# Run every 30 seconds
schedule => { cron => "* * * * * UTC"}
codec => "json"
metadata_target => "http_poller_metadata"
}
}
filter {
ruby {
init => "
def remove_dots hash
new = Hash.new
hash.each { |k,v|
if v.is_a? Hash
v = remove_dots(v)
end
new[ k.gsub('.','_') ] = v
if v.is_a? Array
v.each { |elem|
if elem.is_a? Hash
elem = remove_dots(elem)
end
new[ k.gsub('.','_') ] = elem
} unless v.nil?
end
} unless hash.nil?
return new
end
"
code => "
event.instance_variable_set(:@data,remove_dots(event.to_hash))
"
}
}
output {
elasticsearch {
hosts => localhost
}
}
恐怕这行代码是不正确的: event.instance_variable_set(:@data,remove_dots(event.to_hash))
-结果数据以某种方式固定到该事件,但原始数据保持不变,并交付给Elasticsearch api。
我想在这里需要一些澄清:
老实说,Ruby对我来说是一种魔力:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.