Search code examples
logstashlogstash-configuration

Logstash: how to mutate all text fields so that they are shorter than N


I have log messages from some server and some of fields in these messages might be too long, so I would like to truncate them to 10000 symbols for example? Truncate filter seems like a filter I need, however i don't know how to make this filter affect all text fields. I cannot modify log messages before they get to Logstash and I don't know all the field names in advance.


Solution

  • If the list of fields the truncate filter should act on "is not specified, the default behavior will be to attempt truncation on all strings in the event". It will recursively iterate over any arrays or hashes that it finds and truncate strings within them. "This default behavior could be computationally expensive".