Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion plugins/out_datadog/datadog.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ static void cb_datadog_flush(struct flb_event_chunk *event_chunk,
size_t b_sent;
int ret = FLB_ERROR;
int compressed = FLB_FALSE;
struct mk_list *head;
struct flb_config_map_val *mv;
struct flb_slist_entry *key = NULL;
struct flb_slist_entry *val = NULL;

/* Get upstream connection */
upstream_conn = flb_upstream_conn_get(ctx->upstream);
Expand Down Expand Up @@ -427,7 +431,15 @@ static void cb_datadog_flush(struct flb_event_chunk *event_chunk,
if (compressed == FLB_TRUE) {
flb_http_set_content_encoding_gzip(client);
}
/* TODO: Append other headers if needed*/

flb_config_map_foreach(head, mv, ctx->headers) {
key = mk_list_entry_first(mv->val.list, struct flb_slist_entry, _head);
val = mk_list_entry_last(mv->val.list, struct flb_slist_entry, _head);

flb_http_add_header(client,
key->str, flb_sds_len(key->str),
val->str, flb_sds_len(val->str));
}

/* finaly send the query */
ret = flb_http_do(client, &b_sent);
Expand Down Expand Up @@ -493,6 +505,11 @@ static struct flb_config_map config_map[] = {
"compresses the payload in GZIP format, "
"Datadog supports and recommends setting this to 'gzip'."
},
{
FLB_CONFIG_MAP_SLIST_1, "header", NULL,
FLB_CONFIG_MAP_MULT, FLB_TRUE, offsetof(struct flb_out_datadog, headers),
"Add a HTTP header key/value pair. Multiple headers can be set"
},
{
FLB_CONFIG_MAP_STR, "apikey", NULL,
0, FLB_TRUE, offsetof(struct flb_out_datadog, api_key),
Expand Down
1 change: 1 addition & 0 deletions plugins/out_datadog/datadog.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct flb_out_datadog {
flb_sds_t api_key;
int include_tag_key;
flb_sds_t tag_key;
struct mk_list *headers;
bool remap;

/* final result */
Expand Down
Loading