@@ -810,6 +810,10 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
810810 struct flb_http_client * c ;
811811 flb_sds_t signature = NULL ;
812812 int compressed = FLB_FALSE ;
813+ struct mk_list * head ;
814+ struct flb_config_map_val * mv ;
815+ struct flb_slist_entry * key = NULL ;
816+ struct flb_slist_entry * val = NULL ;
813817
814818 /* Get upstream connection */
815819 u_conn = flb_upstream_conn_get (ctx -> u );
@@ -867,6 +871,16 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
867871
868872 flb_http_add_header (c , "Content-Type" , 12 , "application/x-ndjson" , 20 );
869873
874+ /* Arbitrary additional headers */
875+ flb_config_map_foreach (head , mv , ctx -> headers ) {
876+ key = mk_list_entry_first (mv -> val .list , struct flb_slist_entry , _head );
877+ val = mk_list_entry_last (mv -> val .list , struct flb_slist_entry , _head );
878+
879+ flb_http_add_header (c ,
880+ key -> str , flb_sds_len (key -> str ),
881+ val -> str , flb_sds_len (val -> str ));
882+ }
883+
870884 if (ctx -> http_user && ctx -> http_passwd ) {
871885 flb_http_basic_auth (c , ctx -> http_user , ctx -> http_passwd );
872886 }
@@ -1016,6 +1030,14 @@ static struct flb_config_map config_map[] = {
10161030 "Password for user defined in HTTP_User"
10171031 },
10181032
1033+ /* Arbitrary HTTP headers */
1034+ {
1035+ FLB_CONFIG_MAP_SLIST_1 , "header" , NULL ,
1036+ FLB_CONFIG_MAP_MULT , FLB_TRUE , offsetof(struct flb_elasticsearch , headers ),
1037+ "Add a HTTP header key/value pair. Multiple headers can be set"
1038+ },
1039+
1040+
10191041 /* HTTP Compression */
10201042 {
10211043 FLB_CONFIG_MAP_STR , "compress" , NULL ,
0 commit comments