Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
556dfa5
http_server: unify core listener API and built-in server
edsiper Mar 11, 2026
328b3f1
input: add shared HTTP server integration
edsiper Mar 11, 2026
f7016b7
output: add shared HTTP server integration
edsiper Mar 11, 2026
9de25f9
in_http: unify HTTP server path
edsiper Mar 11, 2026
cd2ba1d
in_prometheus_remote_write: unify HTTP server path
edsiper Mar 11, 2026
d4d82ed
in_splunk: unify HTTP server path
edsiper Mar 11, 2026
993b758
in_elasticsearch: unify HTTP server path
edsiper Mar 11, 2026
224a899
in_opentelemetry: unify HTTP server path
edsiper Mar 11, 2026
5689976
out_prometheus_exporter: unify HTTP server path
edsiper Mar 11, 2026
8ebe51c
out_vivo_exporter: unify HTTP server path
edsiper Mar 11, 2026
1f07d9c
tests: internal: add HTTP server coverage
edsiper Mar 11, 2026
e274c26
help: expose HTTP server options
edsiper Mar 11, 2026
59d1da7
http_server: fix ALPN fallback for HTTP/1 TLS listeners
edsiper Mar 11, 2026
f8000fb
in_http: accept parameterized form content types
edsiper Mar 11, 2026
213d481
in_prometheus_remote_write: fix ingest error handling
edsiper Mar 11, 2026
352c3ce
in_splunk: return 400 on missing host header
edsiper Mar 11, 2026
77f2bb9
out_prometheus_exporter: return empty metrics payload before first sn…
edsiper Mar 11, 2026
7881357
help: fix HTTP server option map handling
edsiper Mar 11, 2026
8ccb603
input: free http server config on ring buffer init failure
edsiper Mar 11, 2026
a8b20e3
http_server: fix endpoint registration and response handling
edsiper Mar 11, 2026
2b62a25
tests: internal: destroy HTTP server test instance
edsiper Mar 11, 2026
b93e63a
lib: monkey: upgrade to v1.8.7
edsiper Mar 11, 2026
623b463
in_prometheus_remote_write: delay context assignment until server sta…
edsiper Mar 11, 2026
d28ce0b
in_http: accept JSON content types with optional whitespace
edsiper Mar 11, 2026
b83aba2
out_prometheus_exporter: propagate metrics response errors
edsiper Mar 11, 2026
e9d318f
input: fix early cleanup in HTTP server property and instance setup p…
edsiper Mar 11, 2026
4dac9f6
http_server: fix trace and reload error handling
edsiper Mar 11, 2026
bfc799e
http_server: harden cached buffer lifetime and endpoint registration
edsiper Mar 11, 2026
e2f4d14
tests: internal: stop on HTTP server init failure
edsiper Mar 11, 2026
e13d4be
http_server: add JSON health endpoint to API v2
edsiper Mar 11, 2026
a5183b8
github: linter: allow http_server umbrella prefix for HTTP server paths
edsiper Mar 11, 2026
6dbf820
tests: internal: chunk_router: initialize HTTP server properties
edsiper Mar 11, 2026
a66434b
input: clean up resources on host setup failure
edsiper Mar 11, 2026
cee1c4e
http_server: validate trace request bodies before parsing
edsiper Mar 11, 2026
3634e34
http_server: free endpoint state on monitoring init failure
edsiper Mar 11, 2026
ae4736b
http_server: return 405 for unsupported reload methods
edsiper Mar 11, 2026
ee53f62
http_server: use pthread portability wrapper
edsiper Mar 11, 2026
18df4e8
http_server: fix retries_failed field length in v2 health
edsiper Mar 11, 2026
8b7bc23
http_server: remove GCC-only unused function attribute
edsiper Mar 12, 2026
bf537f3
out_prometheus_exporter: use pthread portability wrapper
edsiper Mar 12, 2026
c919a65
out_vivo_exporter: use pthread portability wrapper
edsiper Mar 12, 2026
877e961
tests: internal: use pthread portability wrapper in http server test
edsiper Mar 12, 2026
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
23 changes: 22 additions & 1 deletion .github/scripts/commit_prefix_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ def infer_prefix_from_paths(paths):
return prefixes, build_optional


def is_http_server_interface_path(path):
p = path.replace(os.sep, "/")

return (
p.startswith("src/http_server/")
or p == "src/flb_http_common.c"
or p.startswith("include/fluent-bit/http_server/")
or p == "include/fluent-bit/flb_http_common.h"
or p == "HTTP_SERVER_API.md"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.


# ------------------------------------------------
# detect_bad_squash() must satisfy the tests EXACTLY
# ------------------------------------------------
Expand Down Expand Up @@ -243,7 +255,7 @@ def validate_commit(commit):
}

# Prefixes that are allowed to cover multiple subcomponents
umbrella_prefixes = {"lib:", "tests:"}
umbrella_prefixes = {"lib:", "tests:", "http_server:"}

# If more than one non-build prefix is inferred AND the subject is not an umbrella
# prefix, check if the subject prefix is in the expected list. If it is, allow it
Expand Down Expand Up @@ -271,6 +283,15 @@ def validate_commit(commit):
f"Expected one of: {expected_str}"
)

elif subj_lower == "http_server:":
if not all(is_http_server_interface_path(p) for p in norm_paths):
expected_list = sorted(expected)
expected_str = ", ".join(expected_list)
return False, (
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
f"Expected one of: {expected_str}"
)

else:
expected_list = sorted(expected)
expected_str = ", ".join(expected_list)
Expand Down
25 changes: 25 additions & 0 deletions .github/scripts/tests/test_commit_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,31 @@ def test_error_multiple_prefixes_inferred_from_files():
assert "does not match files changed" in msg


def test_valid_http_server_umbrella_prefix():
"""
Commits touching only the HTTP server interface boundary may use http_server:.
"""
commit = make_commit(
"http_server: unify listener startup\n\nSigned-off-by: User",
["src/http_server/flb_hs.c", "src/flb_http_common.c"]
)
ok, _ = validate_commit(commit)
assert ok is True


def test_error_http_server_umbrella_with_unrelated_component():
"""
http_server: must not cover unrelated core files outside the HTTP interface.
"""
commit = make_commit(
"http_server: adjust startup\n\nSigned-off-by: User",
["src/http_server/flb_hs.c", "src/flb_input.c"]
)
ok, msg = validate_commit(commit)
assert ok is False
assert "does not match files changed" in msg



# -----------------------------------------------------------
# Edge Cases
Expand Down
5 changes: 5 additions & 0 deletions include/fluent-bit/flb_http_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct flb_http_stream {
};

struct flb_aws_provider;
struct flb_connection;

/* HTTP REQUEST */

Expand All @@ -155,6 +156,8 @@ int flb_http_request_commit(struct flb_http_request *request);
char *flb_http_request_get_header(struct flb_http_request *request,
char *name);

const char *flb_http_request_get_remote_address(struct flb_http_request *request);

int flb_http_request_set_header(struct flb_http_request *request,
char *name, size_t name_length,
char *value, size_t value_length);
Expand Down Expand Up @@ -196,6 +199,8 @@ int flb_http_request_set_body(struct flb_http_request *request,
unsigned char *body, size_t body_length,
char *compression_algorithm);

int flb_http_request_normalize(struct flb_http_request *request);

int flb_http_request_set_authorization(struct flb_http_request *request,
int type, ...);

Expand Down
17 changes: 16 additions & 1 deletion include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@
* In addition, if TLS is enabled then a
* private key and certificate are required.
*/
#define FLB_INPUT_HTTP_SERVER 4096 /* input uses the generic HTTP server */

/* Input status */
#define FLB_INPUT_RUNNING 1
#define FLB_INPUT_PAUSED 0

struct flb_input_instance;
struct flb_http_server_config;

/*
* Tests callbacks
Expand Down Expand Up @@ -162,7 +164,6 @@ struct flb_input_plugin {
char *description;

struct flb_config_map *config_map;

/* Initialization */
int (*cb_init) (struct flb_input_instance *, struct flb_config *, void *);

Expand Down Expand Up @@ -471,6 +472,10 @@ struct flb_input_instance {
struct mk_list *net_config_map;
struct mk_list net_properties;

struct mk_list *http_server_config_map;
struct flb_http_server_config *http_server_config;
struct mk_list http_server_properties;

struct mk_list *oauth2_jwt_config_map;
struct mk_list oauth2_jwt_properties;

Expand Down Expand Up @@ -742,6 +747,16 @@ static inline int flb_input_config_map_set(struct flb_input_instance *ins,
}
}

/* HTTP server properties */
if (ins->http_server_config_map && ins->http_server_config) {
ret = flb_config_map_set(&ins->http_server_properties,
ins->http_server_config_map,
ins->http_server_config);
if (ret == -1) {
return -1;
}
}

return ret;
}

Expand Down
16 changes: 16 additions & 0 deletions include/fluent-bit/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ int flb_chunk_trace_output(struct flb_chunk_trace *trace, struct flb_output_inst
#define FLB_OUTPUT_NO_MULTIPLEX 512 /* run one task at a time, one task per flush */
#define FLB_OUTPUT_PRIVATE 1024
#define FLB_OUTPUT_SYNCHRONOUS 2048 /* run one task at a time, no flush cycle limit */
#define FLB_OUTPUT_HTTP_SERVER 4096 /* output uses the generic HTTP server */


/*
Expand All @@ -106,6 +107,7 @@ int flb_chunk_trace_output(struct flb_chunk_trace *trace, struct flb_output_inst
const char *tag = event_chunk->tag;

struct flb_output_flush;
struct flb_http_server_config;

/*
* Tests callbacks
Expand Down Expand Up @@ -434,6 +436,10 @@ struct flb_output_instance {
struct mk_list *net_config_map;
struct mk_list net_properties;

struct mk_list *http_server_config_map;
struct flb_http_server_config *http_server_config;
struct mk_list http_server_properties;

struct mk_list *oauth2_config_map;
struct mk_list oauth2_properties;

Expand Down Expand Up @@ -1325,6 +1331,16 @@ static inline int flb_output_config_map_set(struct flb_output_instance *ins,
}
}

/* HTTP server properties */
if (ins->http_server_config_map && ins->http_server_config) {
ret = flb_config_map_set(&ins->http_server_properties,
ins->http_server_config_map,
ins->http_server_config);
if (ret == -1) {
return -1;
}
}

/* OAuth2 properties are validated but not automatically applied here.
* Plugins should call flb_config_map_set() with &ctx->oauth2_config
* in their init callback after calling flb_output_config_map_set(). */
Expand Down
63 changes: 54 additions & 9 deletions include/fluent-bit/http_server/flb_hs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,70 @@

#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_config.h>
#include <fluent-bit/flb_network.h>
#include <fluent-bit/flb_sds.h>
#include <monkey/mk_lib.h>
#include <fluent-bit/http_server/flb_http_server.h>
#include <monkey/mk_core.h>

/*
* HTTP buffers that contains certain cached data to be used
* by end-points.
*/
struct flb_hs_buf {
int users;
int pending_free;
flb_sds_t data;
void *raw_data;
size_t raw_size;
struct mk_list _head;
};

struct flb_health_check_metrics_counter {
int error_limit;
int error_counter;
int retry_failure_limit;
int retry_failure_counter;
int period_limit;
int period_counter;
};

struct flb_hs_hc_buf {
int users;
int error_count;
int retry_failure_count;
struct mk_list _head;
};

enum flb_hs_route_match_type {
FLB_HS_ROUTE_EXACT = 0,
FLB_HS_ROUTE_PREFIX = 1
};

struct flb_hs;

typedef int (*flb_hs_endpoint_callback)(
struct flb_hs *hs,
struct flb_http_request *request,
struct flb_http_response *response);

struct flb_hs_route {
const char *path;
int match_type;
flb_hs_endpoint_callback callback;
struct mk_list _head;
};

struct flb_hs {
mk_ctx_t *ctx; /* Monkey HTTP Context */
int vid; /* Virtual Host ID */
int qid_metrics; /* Metrics Message Queue ID */
int qid_metrics_v2; /* Metrics Message Queue ID for /api/v2 */
int qid_storage; /* Storage Message Queue ID */
int qid_health; /* health Message Queue ID */
struct flb_http_server server;
struct flb_net_setup net_setup;
struct flb_config *config;
struct mk_list routes;
struct mk_list health_metrics;
struct flb_health_check_metrics_counter health_counter;

pthread_t tid; /* Server Thread */
struct flb_config *config; /* Fluent Bit context */
struct flb_hs_buf metrics;
struct flb_hs_buf metrics_v2;
struct flb_hs_buf storage_metrics;

/* end-point: root */
size_t ep_root_size;
Expand All @@ -62,5 +101,11 @@ int flb_hs_push_storage_metrics(struct flb_hs *hs, void *data, size_t size);

int flb_hs_destroy(struct flb_hs *ctx);
int flb_hs_start(struct flb_hs *hs);
void flb_hs_cmt_buffer_destroy(void *data);
void flb_hs_buf_release(struct flb_hs_buf *buffer, void (*raw_free)(void *));
int flb_hs_register_endpoint(struct flb_hs *hs,
const char *path,
int match_type,
flb_hs_endpoint_callback callback);

#endif
11 changes: 11 additions & 0 deletions include/fluent-bit/http_server/flb_hs_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@
#define FLB_HS_UTIL_H

#include <monkey/mk_lib.h>
#include <fluent-bit/http_server/flb_hs.h>

int flb_hs_add_content_type_to_req(mk_request_t *request, int type);
int flb_hs_response_set_content_type(struct flb_http_response *response, int type);
int flb_hs_response_set_payload(struct flb_http_response *response,
int status,
int type,
const void *payload,
size_t payload_size);
int flb_hs_response_send_string(struct flb_http_response *response,
int status,
int type,
const char *payload);

/* Content-type */
enum content_type {
Expand Down
Loading
Loading