Skip to content

Commit

Permalink
add dns retry, connection timeout (#2)
Browse files Browse the repository at this point in the history
* update timeouts

* update timeouts fix build

Signed-off-by: AdheipSingh <[email protected]>
  • Loading branch information
AdheipSingh committed Jan 26, 2025
1 parent 702b92e commit 025ea47
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
40 changes: 34 additions & 6 deletions plugins/out_parseable/parseable.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ static int cb_parseable_init(struct flb_output_instance *ins,
ctx->upstream = flb_upstream_create(config,
ctx->server_host,
ctx->server_port,
FLB_IO_TCP,
FLB_IO_TCP | FLB_IO_ASYNC,
NULL);

ctx->upstream->base.net.connect_timeout = ctx->connect_timeout;
ctx->upstream->base.net.accept_timeout = ctx->accept_timeout;

flb_plg_info(ctx->ins, "Timeouts - Connect: %ds, Accept: %ds", ctx->connect_timeout, ctx->accept_timeout);

/* Set retry limit */
char retry_limit_str[16];
snprintf(retry_limit_str, sizeof(retry_limit_str), "%d", ctx->retry_limit);
flb_output_set_property(ins, "Retry_Limit", retry_limit_str);

flb_plg_info(ctx->ins, "Retry limit set to: %d", ctx->retry_limit);

if (!ctx->upstream) {
flb_free(ctx);
return -1;
Expand Down Expand Up @@ -308,6 +320,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_out_parseable, server_host),
"The host of the server to send logs to."
},
{
FLB_CONFIG_MAP_INT, "server_port", "443", // Default port is 443 for HTTPS
0, FLB_TRUE, offsetof(struct flb_out_parseable, server_port),
"The port on the host to send logs to."
},
{
FLB_CONFIG_MAP_STR, "username", NULL,
0, FLB_TRUE, offsetof(struct flb_out_parseable, username),
Expand All @@ -323,20 +340,31 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_out_parseable, stream),
"The stream name to send logs to. Using $NAMESPACE will dynamically create a namespace."
},
{
FLB_CONFIG_MAP_INT, "server_port", NULL,
0, FLB_TRUE, offsetof(struct flb_out_parseable, server_port),
"The port on the host to send logs to."
},
{
FLB_CONFIG_MAP_CLIST, "Exclude_Namespaces", NULL,
0, FLB_TRUE, offsetof(struct flb_out_parseable, exclude_namespaces),
"A space-separated list of Kubernetes namespaces to exclude from log forwarding."
},
{
FLB_CONFIG_MAP_INT, "connect_timeout", "600", // Default to 600 seconds
0, FLB_TRUE, offsetof(struct flb_out_parseable, connect_timeout),
"Timeout in seconds for establishing connections."
},
{
FLB_CONFIG_MAP_INT, "accept_timeout", "600", // Default to 600 seconds
0, FLB_TRUE, offsetof(struct flb_out_parseable, accept_timeout),
"Timeout in seconds for accepting connections."
},
{
FLB_CONFIG_MAP_INT, "retry_limit", "5", // Default to 5 retries
0, FLB_TRUE, offsetof(struct flb_out_parseable, retry_limit),
"Maximum number of retries for sending logs."
},
/* EOF */
{0}
};


/* Plugin registration */
struct flb_output_plugin out_parseable_plugin = {
.name = "parseable",
Expand Down
4 changes: 4 additions & 0 deletions plugins/out_parseable/parseable.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ struct flb_out_parseable {
flb_sds_t password;
flb_sds_t stream;
struct cfl_list *exclude_namespaces; // Use cfl_list for namespace exclusion
int connect_timeout;
int accept_timeout;
int retry_limit;
struct flb_upstream *upstream;
struct flb_output_instance *ins;
};


#endif

0 comments on commit 025ea47

Please sign in to comment.