Skip to content

Commit 0c81ebd

Browse files
[out_es] fail on missing index
fail plugin initialization if the index is set to null and the logstash_format and generate_id options are disabled. Signed-off-by: Todd Kennedy <[email protected]>
1 parent 97f4915 commit 0c81ebd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plugins/out_es/es.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "es.h"
3737
#include "es_conf.h"
3838
#include "es_bulk.h"
39+
#include "fluent-bit/flb_macros.h"
3940
#include "murmur3.h"
4041

4142
struct flb_output_plugin out_es_plugin;
@@ -357,9 +358,6 @@ static int elasticsearch_format(struct flb_config *config,
357358
* this payload.
358359
*/
359360
if (ctx->logstash_format == FLB_FALSE && ctx->generate_id == FLB_FALSE) {
360-
if (ctx->index == NULL) {
361-
return -1;
362-
}
363361
flb_time_get(&tms);
364362
gmtime_r(&tms.tm.tv_sec, &tm);
365363
strftime(index_formatted, sizeof(index_formatted) - 1,
@@ -630,6 +628,11 @@ static int cb_es_init(struct flb_output_instance *ins,
630628
return -1;
631629
}
632630

631+
if (ctx->index == NULL && ctx->logstash_format == FLB_FALSE && ctx->generate_id == FLB_FALSE) {
632+
flb_plg_error(ins, "cannot initialize plugin, index is not set and logstash_format and generate_id are both off");
633+
return -1;
634+
}
635+
633636
flb_plg_debug(ctx->ins, "host=%s port=%i uri=%s index=%s type=%s",
634637
ins->host.name, ins->host.port, ctx->uri,
635638
ctx->index, ctx->type);

0 commit comments

Comments
 (0)