From 9e5111b676b65d6c44dc829a65a7de6250b0a76b Mon Sep 17 00:00:00 2001 From: Mirko Lazarevic Date: Tue, 27 Aug 2024 17:04:09 +0200 Subject: [PATCH] out_logdna: refactored LogDNA URI formation to support configurable endpoints (#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 --- plugins/out_logdna/logdna.c | 9 ++++++++- plugins/out_logdna/logdna.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/out_logdna/logdna.c b/plugins/out_logdna/logdna.c index 88a0fc9814d..bc834c6017d 100644 --- a/plugins/out_logdna/logdna.c +++ b/plugins/out_logdna/logdna.c @@ -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, @@ -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), diff --git a/plugins/out_logdna/logdna.h b/plugins/out_logdna/logdna.h index b2b3a8f3d5b..b906e2563c4 100644 --- a/plugins/out_logdna/logdna.h +++ b/plugins/out_logdna/logdna.h @@ -25,6 +25,7 @@ #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" @@ -32,6 +33,7 @@ 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;