2626#include <fluent-bit/flb_processor_plugin.h>
2727#include <fluent-bit/flb_filter.h>
2828#include <fluent-bit/flb_kv.h>
29+ #include <fluent-bit/flb_sds.h>
2930#include <fluent-bit/flb_mp_chunk.h>
3031#include <fluent-bit/flb_log_event_decoder.h>
3132#include <fluent-bit/flb_log_event_encoder.h>
@@ -579,9 +580,11 @@ static int flb_processor_unit_set_condition(struct flb_processor_unit *pu, struc
579580
580581int flb_processor_unit_set_property (struct flb_processor_unit * pu , const char * k , struct cfl_variant * v )
581582{
582- struct cfl_variant * val ;
583583 int i ;
584584 int ret ;
585+ char buf [64 ];
586+ flb_sds_t str_val ;
587+ struct cfl_variant * val ;
585588
586589 /* Handle the "condition" property for processor units */
587590 if (strcasecmp (k , "condition" ) == 0 ) {
@@ -596,7 +599,33 @@ int flb_processor_unit_set_property(struct flb_processor_unit *pu, const char *k
596599 else if (v -> type == CFL_VARIANT_ARRAY ) {
597600 for (i = 0 ; i < v -> data .as_array -> entry_count ; i ++ ) {
598601 val = v -> data .as_array -> entries [i ];
599- ret = flb_filter_set_property (pu -> ctx , k , val -> data .as_string );
602+
603+ if (val -> type == CFL_VARIANT_STRING ) {
604+ ret = flb_filter_set_property (pu -> ctx , k , val -> data .as_string );
605+ }
606+ else if (val -> type == CFL_VARIANT_INT ) {
607+ snprintf (buf , sizeof (buf ), "%" PRId64 , val -> data .as_int64 );
608+ str_val = flb_sds_create (buf );
609+ ret = (str_val != NULL ) ? flb_filter_set_property (pu -> ctx , k , str_val ) : -1 ;
610+ flb_sds_destroy (str_val );
611+ }
612+ else if (val -> type == CFL_VARIANT_UINT ) {
613+ snprintf (buf , sizeof (buf ), "%" PRIu64 , val -> data .as_uint64 );
614+ str_val = flb_sds_create (buf );
615+ ret = (str_val != NULL ) ? flb_filter_set_property (pu -> ctx , k , str_val ) : -1 ;
616+ flb_sds_destroy (str_val );
617+ }
618+ else if (val -> type == CFL_VARIANT_DOUBLE ) {
619+ snprintf (buf , sizeof (buf ), "%g" , val -> data .as_double );
620+ str_val = flb_sds_create (buf );
621+ ret = (str_val != NULL ) ? flb_filter_set_property (pu -> ctx , k , str_val ) : -1 ;
622+ flb_sds_destroy (str_val );
623+ }
624+ else {
625+ flb_error ("[processor] property '%s': array element type %d not supported for filter" ,
626+ k , val -> type );
627+ return -1 ;
628+ }
600629
601630 if (ret == -1 ) {
602631 return ret ;
0 commit comments