logstash - Trim field value, or remove part of the value -
i trying adjust path name no longer has time stamp attached end. input many different logs impractical write conditional filter every possible log. if possible trim last 9 characters of value.
for example "random.log-20140827" become "random.log".
so if know it's going random.log-something --
if [path] =~ /random.log/ { mutate { replace => ["path", "random.log"] } } if want "fix" has date in it:
if [path] =~ /-\d\d\d\d\d\d\d\d/ { grok { match => [ "path", "^(?<pathprefix>[^-]+)-" ] } mutate { replace => ["path", "%{pathprefix}"] remove_field => "pathprefix" } } of two, first going less compute intensive.
i haven't tested either of these, should work.
Comments
Post a Comment