Skip to content

Commit

Permalink
out_logdna: refactored LogDNA URI formation to support configurable e…
Browse files Browse the repository at this point in the history
…ndpoints (fluent#8051)

Previously, the LogDNA URI was hardcoded to use the '/logs/ingest' endpoint.
This change introduces flexibility by allowing users to specify their own
endpoint through the 'logdna_endpoint' configuration. This can be particularly
useful for users with different LogDNA setups or those using Super Tenancy.

Signed-off-by: Mirko Lazarevic <[email protected]>
  • Loading branch information
mirko-lazarevic authored and legendary-acp committed Oct 1, 2024
1 parent 6494261 commit 2a47772
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/out_logdna/logdna.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ static void cb_logdna_flush(struct flb_event_chunk *event_chunk,
FLB_OUTPUT_RETURN(FLB_RETRY);
}
tmp = flb_sds_printf(&uri,
"/logs/ingest?hostname=%s&mac=%s&ip=%s&now=%lu&tags=%s",
"%s?hostname=%s&mac=%s&ip=%s&now=%lu&tags=%s",
ctx->logdna_endpoint,
ctx->_hostname,
ctx->mac_addr,
ctx->ip_addr,
Expand Down Expand Up @@ -532,6 +533,12 @@ static struct flb_config_map config_map[] = {
"LogDNA TCP port"
},

{
FLB_CONFIG_MAP_STR, "logdna_endpoint", FLB_LOGDNA_ENDPOINT,
0, FLB_TRUE, offsetof(struct flb_logdna, logdna_endpoint),
"LogDNA endpoint to send logs"
},

{
FLB_CONFIG_MAP_STR, "api_key", NULL,
0, FLB_TRUE, offsetof(struct flb_logdna, api_key),
Expand Down
2 changes: 2 additions & 0 deletions plugins/out_logdna/logdna.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@

#define FLB_LOGDNA_HOST "logs.logdna.com"
#define FLB_LOGDNA_PORT "443"
#define FLB_LOGDNA_ENDPOINT "/logs/ingest"
#define FLB_LOGDNA_CT "Content-Type"
#define FLB_LOGDNA_CT_JSON "application/json; charset=UTF-8"

struct flb_logdna {
/* Incoming Configuration Properties */
flb_sds_t logdna_host;
int logdna_port;
flb_sds_t logdna_endpoint;
flb_sds_t api_key;
flb_sds_t hostname;
flb_sds_t mac_addr;
Expand Down

0 comments on commit 2a47772

Please sign in to comment.