Skip to content

Default value for sprintf interpolation (Feature) #4416

@breml

Description

@breml

In a lot places, Logstash allows to reference fields with the sprintf format(https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#sprintf). Unfortunately if the referenced field does not exist, sprintf defaults to leave the the reference untouched, which may lead to very unsatisfactory results. Therefore I suggest to allow a default value for the sprintf interpolation, e.g.

output {
  file {
    path => "/var/log/%{type:-default}.%{+yyyy.MM.dd.HH}"
  }
}

As delimiter between the field reference and the default value I suggest :- (taken from bash, unlikely to exist in a Logstash event field name).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions