简体   繁体   中英

Logstash Add Extra Space on a particular field based on the config

I have a particular requirement where I have extracted out a field based on the GROK patterns. And based on the length of the attribute, i have to add space at the end of the string.

For example:

Attribute:

PartA: test
PartB: abc

Output Should be like:

test#####abc##          

Where the requirement says partA should be of length 10 and partB should be of length 5 . So if you see, I have added extra space ( # ) based on the current length of the attribute.

I am currently trying to create a new line based on the output above requirement,

here is the attempt (logstash.conf):

file {
   path => "/Users/Smit/Downloads/chrome/observability/logstash_dump.txt"
   codec => line { format => "%{PartA}#####${PartB}###"}
  }
 }

Is there a way to dynamically append space ( # used this for clarity) instead of hardcoding.

Here is the full Logstash file: https://dpaste.org/dsuH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM