elastic / elastic/logstash

Default value for sprintf interpolation (Feature)

Open
#4,416 21 comments 37 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.