From 8348709e551b2b97701c6c8a2d9ef56e5e0d7cd5 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Fri, 31 May 2024 14:24:15 +0200 Subject: [PATCH] out_es: Allow Logstash_Prefix_Key with prefix The option Logstash_Prefix_Key should be a record accessor. There is a convenience feature that automatically prefixes a $ when the value is just a static string (since that is expected to be set as Logstash_Prefix instead). However, record accessor can contain the $ not just at the beginning. One example would be containers-$kubernetes['namespace_name'] This patch thus makes the autodetection look for a $ in the whole value, not just the first character. Signed-off-by: Jan-Philipp Litza --- plugins/out_es/es_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_es/es_conf.c b/plugins/out_es/es_conf.c index 4bc2977c5eb..3800d51e40e 100644 --- a/plugins/out_es/es_conf.c +++ b/plugins/out_es/es_conf.c @@ -326,7 +326,7 @@ struct flb_elasticsearch *flb_es_conf_create(struct flb_output_instance *ins, } if (ctx->logstash_prefix_key) { - if (ctx->logstash_prefix_key[0] != '$') { + if (strchr(ctx->logstash_prefix_key, '$') == NULL) { len = flb_sds_len(ctx->logstash_prefix_key); buf = flb_malloc(len + 2); if (!buf) {