From 39e52bf04155a0cd5fd686af74a556977e50c77e Mon Sep 17 00:00:00 2001 From: Mirko Lazarevic Date: Tue, 17 Oct 2023 09:48:22 +0200 Subject: [PATCH] out_logdna: refactored LogDNA URI formation to support configurable endpoints 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 e3ab9f56fa9..6725c4c47e3 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 f7ca19a4362..de189932ce4 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;