Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_datadog: Add support for setting a static hostname #8988

Merged
merged 1 commit into from
Jun 25, 2024
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
16 changes: 16 additions & 0 deletions plugins/out_datadog/datadog.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ static int datadog_format(struct flb_config *config,
ctx->dd_service, flb_sds_len(ctx->dd_service));
}

/* dd_hostname */
if (ctx->dd_hostname != NULL) {
dd_msgpack_pack_key_value_str(&mp_pck,
FLB_DATADOG_DD_HOSTNAME_KEY,
sizeof(FLB_DATADOG_DD_HOSTNAME_KEY) -1,
ctx->dd_hostname, flb_sds_len(ctx->dd_hostname));
}

/* Append initial object k/v */
ind = 0;
for (i = 0; i < map_size; i++) {
Expand Down Expand Up @@ -514,6 +522,14 @@ static struct flb_config_map config_map[] = {
"The tags you want to assign to your logs in Datadog. If unset, Datadog "
"will expect the tags in the `ddtags` attribute."
},
{
FLB_CONFIG_MAP_STR, "dd_hostname", NULL,
0, FLB_TRUE, offsetof(struct flb_out_datadog, dd_hostname),
"The host that emitted logs should be associated with. If unset, Datadog "
"will expect the host to be set as `host`, `hostname`, or `syslog.hostname` "
"attributes. See Datadog Logs preprocessor documentation for up-to-date "
"of recognized attributes."
},

{
FLB_CONFIG_MAP_STR, "proxy", NULL,
Expand Down
2 changes: 2 additions & 0 deletions plugins/out_datadog/datadog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define FLB_DATADOG_DEFAULT_PORT 443
#define FLB_DATADOG_DEFAULT_TIME_KEY "timestamp"
#define FLB_DATADOG_DEFAULT_TAG_KEY "tagkey"
#define FLB_DATADOG_DD_HOSTNAME_KEY "hostname"
#define FLB_DATADOG_DD_SOURCE_KEY "ddsource"
#define FLB_DATADOG_DD_SERVICE_KEY "service"
#define FLB_DATADOG_DD_TAGS_KEY "ddtags"
Expand Down Expand Up @@ -65,6 +66,7 @@ struct flb_out_datadog {
int nb_additional_entries;
flb_sds_t dd_source;
flb_sds_t dd_service;
flb_sds_t dd_hostname;
flb_sds_t dd_tags;
flb_sds_t dd_message_key;

Expand Down
Loading