Skip to content

http_server/health: Implement throughput health check #5773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/fluent-bit/flb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ struct flb_config {
int hc_errors_count; /* health check error counts as unhealthy*/
int hc_retry_failure_count; /* health check retry failures count as unhealthy*/
int health_check_period; /* period by second for health status check */
int hc_throughput; /* if throughput check is enabled */
char *hc_throughput_input_plugins; /* which input plugins should be considered for checking throughput */
char *hc_throughput_output_plugins;/* which output plugins should be considered for checking throughput */
double hc_throughput_ratio_threshold; /* output/input ratio threshold to consider a failure */
int hc_throughput_min_failures; /* minimum amount of failures to cause error condition */
#endif

/*
Expand Down Expand Up @@ -317,6 +322,11 @@ enum conf_type {
#define FLB_CONF_STR_HC_ERRORS_COUNT "HC_Errors_Count"
#define FLB_CONF_STR_HC_RETRIES_FAILURE_COUNT "HC_Retry_Failure_Count"
#define FLB_CONF_STR_HC_PERIOD "HC_Period"
#define FLB_CONF_STR_HC_THROUGHPUT "HC_Throughput"
#define FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS "HC_Throughput_Input_Plugins"
#define FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS "HC_Throughput_Output_Plugins"
#define FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD "HC_Throughput_Ratio_Threshold"
#define FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES "HC_Throughput_Min_Failures"
#endif /* !FLB_HAVE_HTTP_SERVER */

#ifdef FLB_HAVE_CHUNK_TRACE
Expand Down
1 change: 1 addition & 0 deletions include/fluent-bit/flb_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int flb_time_msleep(uint32_t ms);
double flb_time_to_double(struct flb_time *tm);
uint64_t flb_time_to_nanosec(struct flb_time *tm);
uint64_t flb_time_to_millisec(struct flb_time *tm);
uint64_t flb_time_to_seconds(struct flb_time *tm);
int flb_time_add(struct flb_time *base, struct flb_time *duration,
struct flb_time *result);
int flb_time_diff(struct flb_time *time1,
Expand Down
19 changes: 19 additions & 0 deletions src/flb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ struct flb_service_config service_configs[] = {
FLB_CONF_TYPE_INT,
offsetof(struct flb_config, health_check_period)},

{FLB_CONF_STR_HC_THROUGHPUT,
FLB_CONF_TYPE_BOOL,
offsetof(struct flb_config, hc_throughput)},

{FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS,
FLB_CONF_TYPE_STR,
offsetof(struct flb_config, hc_throughput_input_plugins)},

{FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS,
FLB_CONF_TYPE_STR,
offsetof(struct flb_config, hc_throughput_output_plugins)},

{FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD,
FLB_CONF_TYPE_DOUBLE,
offsetof(struct flb_config, hc_throughput_ratio_threshold)},

{FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES,
FLB_CONF_TYPE_INT,
offsetof(struct flb_config, hc_throughput_min_failures)},
#endif
/* DNS*/
{FLB_CONF_DNS_MODE,
Expand Down
5 changes: 5 additions & 0 deletions src/flb_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ uint64_t flb_time_to_millisec(struct flb_time *tm)
return (((uint64_t)tm->tm.tv_sec * 1000L) + tm->tm.tv_nsec / 1000000L);
}

uint64_t flb_time_to_seconds(struct flb_time *tm)
{
return (uint64_t)tm->tm.tv_sec;
}

int flb_time_add(struct flb_time *base, struct flb_time *duration, struct flb_time *result)
{
if (base == NULL || duration == NULL|| result == NULL) {
Expand Down
Loading