I'm trying to manipulate a bunch of fields that have names with special characters (e.g. @ or dots).
This is a usual case if someone uses Logstash-logback-encoder for shipping logs from an application to logstash.
Unfortunately, neither mutate nor ruby seems to do the trick.
Snippets of codes that I have tried:
def filter(event)
unless event.get("@fields.request_headers.user-agent").nil?
if event.get("@fields.request_headers.user-agent").include? "ndroid"
event.set('andoid', true)
event.remove('@fields.request_headers.user-agent')
end
end
return [event]
end
In the past I have successfully utilized both methods for fields having proper names.
So, I was wondering if this is a known issue for logstash or ruby filter.
The aforementioned example makes all messages to drop.
It seems that Logstash has trouble evaluating any type of expression (either at branch level or at mutation level) that contains field names with special characters (such as dots).
I believe the if statement is correct since there is a field with name: @fields.request_headers.user-agent and it contains "ndroid".
I can see it both via the Search API of Elasticsearch and the Discover tab of Kibana (see the screenshot: https://imgur.com/a/pkw56EB).
I'll try that and revert with an update.
However, please not that this is not a typical case of nested fields; it's a case of a field name following a bad practice when it comes to naming conventions.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.