@@ -817,6 +817,10 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
817817 struct flb_http_client * c ;
818818 flb_sds_t signature = NULL ;
819819 int compressed = FLB_FALSE ;
820+ struct mk_list * head ;
821+ struct flb_config_map_val * mv ;
822+ struct flb_slist_entry * key = NULL ;
823+ struct flb_slist_entry * val = NULL ;
820824
821825 /* Get upstream connection */
822826 u_conn = flb_upstream_conn_get (ctx -> u );
@@ -874,6 +878,16 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
874878
875879 flb_http_add_header (c , "Content-Type" , 12 , "application/x-ndjson" , 20 );
876880
881+ /* Arbitrary additional headers */
882+ flb_config_map_foreach (head , mv , ctx -> headers ) {
883+ key = mk_list_entry_first (mv -> val .list , struct flb_slist_entry , _head );
884+ val = mk_list_entry_last (mv -> val .list , struct flb_slist_entry , _head );
885+
886+ flb_http_add_header (c ,
887+ key -> str , flb_sds_len (key -> str ),
888+ val -> str , flb_sds_len (val -> str ));
889+ }
890+
877891 if (ctx -> http_user && ctx -> http_passwd ) {
878892 flb_http_basic_auth (c , ctx -> http_user , ctx -> http_passwd );
879893 }
@@ -1023,6 +1037,14 @@ static struct flb_config_map config_map[] = {
10231037 "Password for user defined in HTTP_User"
10241038 },
10251039
1040+ /* Arbitrary HTTP headers */
1041+ {
1042+ FLB_CONFIG_MAP_SLIST_1 , "header" , NULL ,
1043+ FLB_CONFIG_MAP_MULT , FLB_TRUE , offsetof(struct flb_elasticsearch , headers ),
1044+ "Add a HTTP header key/value pair. Multiple headers can be set"
1045+ },
1046+
1047+
10261048 /* HTTP Compression */
10271049 {
10281050 FLB_CONFIG_MAP_STR , "compress" , NULL ,
0 commit comments