Skip to content

Commit 2240019

Browse files
committed
http_server/health: Implement throughput health check
Signed-off-by: Thiago Padilha <[email protected]>
1 parent 186b3e7 commit 2240019

File tree

5 files changed

+301
-16
lines changed

5 files changed

+301
-16
lines changed

include/fluent-bit/flb_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ struct flb_config {
171171
int hc_errors_count; /* health check error counts as unhealthy*/
172172
int hc_retry_failure_count; /* health check retry failures count as unhealthy*/
173173
int health_check_period; /* period by second for health status check */
174+
int hc_throughput; /* if throughput check is enabled */
175+
char *hc_throughput_input_plugins; /* which input plugins should be considered for checking throughput */
176+
char *hc_throughput_output_plugins;/* which output plugins should be considered for checking throughput */
177+
double hc_throughput_ratio_threshold; /* output/input ratio threshold to consider a failure */
178+
int hc_throughput_min_failures; /* minimum amount of failures to cause error condition */
174179
#endif
175180

176181
/*
@@ -298,6 +303,11 @@ enum conf_type {
298303
#define FLB_CONF_STR_HC_ERRORS_COUNT "HC_Errors_Count"
299304
#define FLB_CONF_STR_HC_RETRIES_FAILURE_COUNT "HC_Retry_Failure_Count"
300305
#define FLB_CONF_STR_HC_PERIOD "HC_Period"
306+
#define FLB_CONF_STR_HC_THROUGHPUT "HC_Throughput"
307+
#define FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS "HC_Throughput_Input_Plugins"
308+
#define FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS "HC_Throughput_Output_Plugins"
309+
#define FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD "HC_Throughput_Ratio_Threshold"
310+
#define FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES "HC_Throughput_Min_Failures"
301311
#endif /* !FLB_HAVE_HTTP_SERVER */
302312

303313
/* DNS */

include/fluent-bit/flb_time.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ int flb_time_get(struct flb_time *tm);
7676
int flb_time_msleep(uint32_t ms);
7777
double flb_time_to_double(struct flb_time *tm);
7878
uint64_t flb_time_to_nanosec(struct flb_time *tm);
79+
uint64_t flb_time_to_seconds(struct flb_time *tm);
7980
int flb_time_add(struct flb_time *base, struct flb_time *duration,
8081
struct flb_time *result);
8182
int flb_time_diff(struct flb_time *time1,

src/flb_config.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,25 @@ struct flb_service_config service_configs[] = {
106106
FLB_CONF_TYPE_INT,
107107
offsetof(struct flb_config, health_check_period)},
108108

109+
{FLB_CONF_STR_HC_THROUGHPUT,
110+
FLB_CONF_TYPE_BOOL,
111+
offsetof(struct flb_config, hc_throughput)},
112+
113+
{FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS,
114+
FLB_CONF_TYPE_STR,
115+
offsetof(struct flb_config, hc_throughput_input_plugins)},
116+
117+
{FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS,
118+
FLB_CONF_TYPE_STR,
119+
offsetof(struct flb_config, hc_throughput_output_plugins)},
120+
121+
{FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD,
122+
FLB_CONF_TYPE_DOUBLE,
123+
offsetof(struct flb_config, hc_throughput_ratio_threshold)},
124+
125+
{FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES,
126+
FLB_CONF_TYPE_INT,
127+
offsetof(struct flb_config, hc_throughput_min_failures)},
109128
#endif
110129
/* DNS*/
111130
{FLB_CONF_DNS_MODE,

src/flb_time.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ uint64_t flb_time_to_nanosec(struct flb_time *tm)
9696
return (((uint64_t)tm->tm.tv_sec * 1000000000L) + tm->tm.tv_nsec);
9797
}
9898

99+
uint64_t flb_time_to_seconds(struct flb_time *tm)
100+
{
101+
return (uint64_t)tm->tm.tv_sec;
102+
}
103+
99104
int flb_time_add(struct flb_time *base, struct flb_time *duration, struct flb_time *result)
100105
{
101106
if (base == NULL || duration == NULL|| result == NULL) {

0 commit comments

Comments
 (0)