Skip to content

Commit 3d423f1

Browse files
committed
http_server/health: Implement throughput health check
Signed-off-by: Thiago Padilha <[email protected]>
1 parent 0397d01 commit 3d423f1

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
@@ -177,6 +177,11 @@ struct flb_config {
177177
int hc_errors_count; /* health check error counts as unhealthy*/
178178
int hc_retry_failure_count; /* health check retry failures count as unhealthy*/
179179
int health_check_period; /* period by second for health status check */
180+
int hc_throughput; /* if throughput check is enabled */
181+
char *hc_throughput_input_plugins; /* which input plugins should be considered for checking throughput */
182+
char *hc_throughput_output_plugins;/* which output plugins should be considered for checking throughput */
183+
double hc_throughput_ratio_threshold; /* output/input ratio threshold to consider a failure */
184+
int hc_throughput_min_failures; /* minimum amount of failures to cause error condition */
180185
#endif
181186

182187
/*
@@ -317,6 +322,11 @@ enum conf_type {
317322
#define FLB_CONF_STR_HC_ERRORS_COUNT "HC_Errors_Count"
318323
#define FLB_CONF_STR_HC_RETRIES_FAILURE_COUNT "HC_Retry_Failure_Count"
319324
#define FLB_CONF_STR_HC_PERIOD "HC_Period"
325+
#define FLB_CONF_STR_HC_THROUGHPUT "HC_Throughput"
326+
#define FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS "HC_Throughput_Input_Plugins"
327+
#define FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS "HC_Throughput_Output_Plugins"
328+
#define FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD "HC_Throughput_Ratio_Threshold"
329+
#define FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES "HC_Throughput_Min_Failures"
320330
#endif /* !FLB_HAVE_HTTP_SERVER */
321331

322332
#ifdef FLB_HAVE_CHUNK_TRACE

include/fluent-bit/flb_time.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int flb_time_msleep(uint32_t ms);
9090
double flb_time_to_double(struct flb_time *tm);
9191
uint64_t flb_time_to_nanosec(struct flb_time *tm);
9292
uint64_t flb_time_to_millisec(struct flb_time *tm);
93+
uint64_t flb_time_to_seconds(struct flb_time *tm);
9394
int flb_time_add(struct flb_time *base, struct flb_time *duration,
9495
struct flb_time *result);
9596
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
@@ -110,6 +110,25 @@ struct flb_service_config service_configs[] = {
110110
FLB_CONF_TYPE_INT,
111111
offsetof(struct flb_config, health_check_period)},
112112

113+
{FLB_CONF_STR_HC_THROUGHPUT,
114+
FLB_CONF_TYPE_BOOL,
115+
offsetof(struct flb_config, hc_throughput)},
116+
117+
{FLB_CONF_STR_HC_THROUGHPUT_IN_PLUGINS,
118+
FLB_CONF_TYPE_STR,
119+
offsetof(struct flb_config, hc_throughput_input_plugins)},
120+
121+
{FLB_CONF_STR_HC_THROUGHPUT_OUT_PLUGINS,
122+
FLB_CONF_TYPE_STR,
123+
offsetof(struct flb_config, hc_throughput_output_plugins)},
124+
125+
{FLB_CONF_STR_HC_THROUGHPUT_RATIO_THRESHOLD,
126+
FLB_CONF_TYPE_DOUBLE,
127+
offsetof(struct flb_config, hc_throughput_ratio_threshold)},
128+
129+
{FLB_CONF_STR_HC_THROUGHPUT_MIN_FAILURES,
130+
FLB_CONF_TYPE_INT,
131+
offsetof(struct flb_config, hc_throughput_min_failures)},
113132
#endif
114133
/* DNS*/
115134
{FLB_CONF_DNS_MODE,

src/flb_time.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ uint64_t flb_time_to_millisec(struct flb_time *tm)
101101
return (((uint64_t)tm->tm.tv_sec * 1000L) + tm->tm.tv_nsec / 1000000L);
102102
}
103103

104+
uint64_t flb_time_to_seconds(struct flb_time *tm)
105+
{
106+
return (uint64_t)tm->tm.tv_sec;
107+
}
108+
104109
int flb_time_add(struct flb_time *base, struct flb_time *duration, struct flb_time *result)
105110
{
106111
if (base == NULL || duration == NULL|| result == NULL) {

0 commit comments

Comments
 (0)