diff --git a/plugins/out_prometheus_remote_write/remote_write.c b/plugins/out_prometheus_remote_write/remote_write.c index 85cfe9840cb..459f60dbd01 100644 --- a/plugins/out_prometheus_remote_write/remote_write.c +++ b/plugins/out_prometheus_remote_write/remote_write.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -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; @@ -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) { @@ -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