@@ -368,6 +368,10 @@ static void cb_datadog_flush(struct flb_event_chunk *event_chunk,
368368 size_t b_sent ;
369369 int ret = FLB_ERROR ;
370370 int compressed = FLB_FALSE ;
371+ struct mk_list * head ;
372+ struct flb_config_map_val * mv ;
373+ struct flb_slist_entry * key = NULL ;
374+ struct flb_slist_entry * val = NULL ;
371375
372376 /* Get upstream connection */
373377 upstream_conn = flb_upstream_conn_get (ctx -> upstream );
@@ -427,7 +431,15 @@ static void cb_datadog_flush(struct flb_event_chunk *event_chunk,
427431 if (compressed == FLB_TRUE ) {
428432 flb_http_set_content_encoding_gzip (client );
429433 }
430- /* TODO: Append other headers if needed*/
434+
435+ flb_config_map_foreach (head , mv , ctx -> headers ) {
436+ key = mk_list_entry_first (mv -> val .list , struct flb_slist_entry , _head );
437+ val = mk_list_entry_last (mv -> val .list , struct flb_slist_entry , _head );
438+
439+ flb_http_add_header (client ,
440+ key -> str , flb_sds_len (key -> str ),
441+ val -> str , flb_sds_len (val -> str ));
442+ }
431443
432444 /* finaly send the query */
433445 ret = flb_http_do (client , & b_sent );
@@ -493,6 +505,11 @@ static struct flb_config_map config_map[] = {
493505 "compresses the payload in GZIP format, "
494506 "Datadog supports and recommends setting this to 'gzip'."
495507 },
508+ {
509+ FLB_CONFIG_MAP_SLIST_1 , "header" , NULL ,
510+ FLB_CONFIG_MAP_MULT , FLB_TRUE , offsetof(struct flb_out_datadog , headers ),
511+ "Add a HTTP header key/value pair. Multiple headers can be set"
512+ },
496513 {
497514 FLB_CONFIG_MAP_STR , "apikey" , NULL ,
498515 0 , FLB_TRUE , offsetof(struct flb_out_datadog , api_key ),
0 commit comments