Repository: fluent/fluent-bit (C)

Issue:
Allow you to specify the port when working with the kinesis plugin.
Fluentbit has a [Kinesis](https://docs.fluentbit.io/manual/pipeline/outputs/kinesis ) output plugin.

However, in the Fluentbit code, the port 443 is [directly](https://github.com/fluent/fluent-bit/blob/master/plugins/out_kinesis_streams/kinesis.c#L258.) specified. 

My cloud provider, which is not AWS, supports the Kinesis protocol, but the endpoint uses port 8443. 
Unfortunately, I cannot specify the port number in the Fluent Bit configuration for the Kinesis plugin, so I am unable to use Fluentbit in this scenario. 
Could you please allow me to configure the port number for the Kinesis plugin?

**Describe the solution you'd like**
```
[OUTPUT]
    Name kinesis_streams
    ...
    stream          /topic
    endpoint      https://some-endpoint
    port              8443
```



Discussion: Hey guys
I guess i can work on this quick,
Will create PR soon for the same

@azalio I have created the PR and it compiles successfully
I need your help in testing
Can you test the code using the PR?




Fix (patch):
diff --git a/plugins/out_kinesis_streams/kinesis.c b/plugins/out_kinesis_streams/kinesis.c
index 2fb46dc6295..a225f6007f7 100644
--- a/plugins/out_kinesis_streams/kinesis.c
+++ b/plugins/out_kinesis_streams/kinesis.c
@@ -117,7 +117,30 @@ static int cb_kinesis_init(struct flb_output_instance *ins,
     if (tmp) {
         ctx->sts_endpoint = (char *) tmp;
     }
-
+    /*
+     * Sets the port number for the Kinesis output plugin.
+     *
+     * This function uses the port number already set in the output instance's host structure.
+     * If the port is not set (0), the default HTTPS port is used.
+     *
+     * @param ins The output instance.
+     * @param ctx The Kinesis output plugin context.
+     */
+    flb_plg_debug(ins, "Retrieved port from ins->host.port: %d", ins->host.port);
+    
+    if (ins->host.port >= FLB_KINESIS_MIN_PORT && ins->host.port <= FLB_KINESIS_MAX_PORT) {
+        ctx->port = ins->host.port;
+        flb_plg_debug(ins, "Setting port to: %d", ctx->port);
+    }
+    else if (ins->host.port == 0) {
+        ctx->port = FLB_KINESIS_DEFAULT_HTTPS_PORT;
+        flb_plg_debug(ins, "Port not set. Using default HTTPS port: %d", ctx->port);
+    }
+    else {
+        flb_plg_error(ins, "Invalid port number: %d. Must be between %d and %d", 
+                      ins->host.port, FLB_KINESIS_MIN_PORT, FLB_KINESIS_MAX_PORT);
+        goto error;
+    }
 
     tmp = flb_output_get_property("log_key", ins);
     if (tmp) {
@@ -255,14 +278,14 @@ static int cb_kinesis_init(struct flb_output_instance *ins,
     ctx->kinesis_client->region = (char *) ctx->region;
     ctx->kinesis_client->retry_requests = ctx->retry_requests;
     ctx->kinesis_client->service = "kinesis";
-    ctx->kinesis_client->port = 443;
+    ctx->kinesis_client->port = ctx->port;
     ctx->kinesis_client->flags = 0;
     ctx->kinesis_client->proxy = NULL;
     ctx->kinesis_client->static_headers = &content_type_header;
     ctx->kinesis_client->static_headers_len = 1;
 
     struct flb_upstream *upstream = flb_upstream_create(config, ctx->endpoint,
-                                                        443, FLB_IO_TLS,
+                                                        ctx->port, FLB_IO_TLS,
                                                         ctx->client_tls);
     if (!upstream) {
         flb_plg_error(ctx->ins, "Connection initialization error");
diff --git a/plugins/out_kinesis_streams/kinesis.h b/plugins/out_kinesis_streams/kinesis.h
index 72c6b976b07..57a72166617 100644
--- a/plugins/out_kinesis_streams/kinesis.h
+++ b/plugins/out_kinesis_streams/kinesis.h
@@ -29,6 +29,10 @@
 
 #define DEFAULT_TIME_KEY_FORMAT "%Y-%m-%dT%H:%M:%S"
 
+#define FLB_KINESIS_DEFAULT_HTTPS_PORT    443
+#define FLB_KINESIS_MIN_PORT              1
+#define FLB_KINESIS_MAX_PORT              65535
+
 /* buffers used for each flush */
 struct flush {
     /* temporary buffer for storing the serialized event messages */
@@ -92,6 +96,7 @@ struct flb_kinesis {
     int retry_requests;
     char *sts_endpoint;
     int custom_endpoint;
+    int port;
     char *profile;
 
     /* in this plugin the 'random' partition key is a uuid + fluent tag + timestamp */