Skip to content

Commit

Permalink
out_loki: add new option 'uri' to customize HTTP URI endpoint
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
edsiper committed Oct 13, 2023
1 parent 3f93f98 commit 3a944bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/out_loki/loki.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1726,13 +1726,20 @@ 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),
"Tenant ID used by default to push logs to Loki. If omitted or empty "
"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),
Expand Down
2 changes: 2 additions & 0 deletions plugins/out_loki/loki.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3a944bd

Please sign in to comment.