Skip to content

out_prometheus_remote_write: support zstd compression #10587

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 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion plugins/out_prometheus_remote_write/remote_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <fluent-bit/flb_output_plugin.h>
#include <fluent-bit/flb_snappy.h>
#include <fluent-bit/flb_gzip.h>
#include <fluent-bit/flb_zstd.h>
#include <fluent-bit/flb_metrics.h>
#include <fluent-bit/flb_kv.h>

Expand Down Expand Up @@ -71,6 +72,10 @@ static int http_post(struct prometheus_remote_write_context *ctx,
ret = flb_gzip_compress((void *) body, body_len,
&payload_buf, &payload_size);
}
else if (strcasecmp(ctx->compression, "zstd") == 0) {
ret = flb_zstd_compress((void *) body, body_len,
&payload_buf, &payload_size);
}
else {
payload_buf = (void *) body;
payload_size = body_len;
Expand Down Expand Up @@ -134,6 +139,13 @@ static int http_post(struct prometheus_remote_write_context *ctx,
"gzip",
strlen("gzip"));
}
else if (strcasecmp(ctx->compression, "zstd") == 0) {
flb_http_add_header(c,
"Content-Encoding",
strlen("Content-Encoding"),
"zstd",
strlen("zstd"));
}

/* Basic Auth headers */
if (ctx->http_user && ctx->http_passwd) {
Expand Down Expand Up @@ -415,7 +427,7 @@ static struct flb_config_map config_map[] = {
{
FLB_CONFIG_MAP_STR, "compression", "snappy",
0, FLB_TRUE, offsetof(struct prometheus_remote_write_context, compression),
"Compress the payload with either snappy, gzip if set"
"Compress the payload with either snappy, gzip, zstd if set"
},

#ifdef FLB_HAVE_SIGNV4
Expand Down
Loading