From 3a944bdb750ab3de2e3888162bd47b48a49f2e6a Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 13 Oct 2023 08:52:17 -0500 Subject: [PATCH] out_loki: add new option 'uri' to customize HTTP URI endpoint This patch implementes a new configuration property called 'uri' that allows to define a custom HTTP URI. The default one is always set to '/loki/api/v1/push', this option allows to override that value. Signed-off-by: Eduardo Silva --- plugins/out_loki/loki.c | 9 ++++++++- plugins/out_loki/loki.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/out_loki/loki.c b/plugins/out_loki/loki.c index d93a3f9aad6..b10a4f1d306 100644 --- a/plugins/out_loki/loki.c +++ b/plugins/out_loki/loki.c @@ -1578,7 +1578,7 @@ static void cb_loki_flush(struct flb_event_chunk *event_chunk, } /* Create HTTP client context */ - c = flb_http_client(u_conn, FLB_HTTP_POST, FLB_LOKI_URI, + c = flb_http_client(u_conn, FLB_HTTP_POST, ctx->uri, out_buf, out_size, ctx->tcp_host, ctx->tcp_port, NULL, 0); @@ -1726,6 +1726,12 @@ static int cb_loki_exit(void *data, struct flb_config *config) /* Configuration properties map */ static struct flb_config_map config_map[] = { + { + FLB_CONFIG_MAP_STR, "uri", FLB_LOKI_URI, + 0, FLB_TRUE, offsetof(struct flb_loki, uri), + "Specify a custom HTTP URI. It must start with forward slash." + }, + { FLB_CONFIG_MAP_STR, "tenant_id", NULL, 0, FLB_TRUE, offsetof(struct flb_loki, tenant_id), @@ -1733,6 +1739,7 @@ static struct flb_config_map config_map[] = { "it assumes Loki is running in single-tenant mode and no X-Scope-OrgID " "header is sent." }, + { FLB_CONFIG_MAP_STR, "tenant_id_key", NULL, 0, FLB_TRUE, offsetof(struct flb_loki, tenant_id_key_config), diff --git a/plugins/out_loki/loki.h b/plugins/out_loki/loki.h index 2011cee3ded..6d7e8c33741 100644 --- a/plugins/out_loki/loki.h +++ b/plugins/out_loki/loki.h @@ -55,6 +55,8 @@ struct flb_loki { /* Public configuration properties */ int auto_kubernetes_labels; int drop_single_key; + + flb_sds_t uri; flb_sds_t line_format; flb_sds_t tenant_id; flb_sds_t tenant_id_key_config;