From 6922518cc821b5ca9b0ce19895844e2ae861ca90 Mon Sep 17 00:00:00 2001 From: Zach McGrath Date: Fri, 15 Oct 2021 09:39:48 -0600 Subject: [PATCH 1/4] amqps updates --- Dockerfile | 3 +-- README.md | 23 ++++++++++++----------- out_rabbitmq.go | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e461db..eef05fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,7 @@ FROM fluent/fluent-bit:1.3 LABEL maintainer="Björn Franke" COPY --from=building-stage /go/src/out_rabbitmq.so /fluent-bit/bin/ -COPY ./conf/fluent-bit-docker.conf /fluent-bit/etc EXPOSE 2020 -CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit-docker.conf","-e","/fluent-bit/bin/out_rabbitmq.so"] +CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf","-e","/fluent-bit/bin/out_rabbitmq.so"] diff --git a/README.md b/README.md index 1a9df1d..b402b90 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,18 @@ build ### Configuration-Parameter -| Parameter | Description | Default-Value | -|------------------------------|-------------------------------------------------------------------------------------------------|---------------| -| RabbitHost | The hostname of the Rabbit-MQ server | "" | -| RabbitPort | The port under which the Rabbit-MQ is reachable | "" | -| RabbitUser | The user of the Rabbit-MQ host | "" | -| RabbitPassword | The username of the user which connects to the Rabbit-MQ server | "" | -| ExchangeName | The exchange to which fluent-bit send its logs | "" | -| ExchangeType | The exchange-type | "" | -| RoutingKey | The routing-key pattern | "" | -| RoutingKeyDelimiter | The Delemiter which seperates the routing-key parts | "." | -| RemoveRkValuesFromRecord | If enabled fluentd deletes the values of the record, which have been stored in the routing-key | "" | +| Parameter | Description | Default-Value | +|------------------------------|--------------------------------------------------------------------------------------------------|---------------| +| RabbitHost | The hostname of the Rabbit-MQ server | "" | +| RabbitPort | The port under which the Rabbit-MQ is reachable | "" | +| RabbitUser | The user of the Rabbit-MQ host | "" | +| RabbitPassword | The username of the user which connects to the Rabbit-MQ server | "" | +| ExchangeName | The exchange to which fluent-bit send its logs | "" | +| ExchangeType | The exchange-type | "" | +| RoutingKey | The routing-key pattern | "" | +| RoutingKeyDelimiter | The Delemiter which seperates the routing-key parts | "." | +| RemoveRkValuesFromRecord | If enabled fluentd deletes the values of the record, which have been stored in the routing-key | "" | +| AMQPS | If enabled fluent bit will attempt to connecto to RabbitMQ via the amqps protocol instead of amqp| "false" | ### Routing-Key pattern diff --git a/out_rabbitmq.go b/out_rabbitmq.go index 340ea38..e7ace2b 100755 --- a/out_rabbitmq.go +++ b/out_rabbitmq.go @@ -20,6 +20,7 @@ var ( removeRkValuesFromRecord bool addTagToRecord bool addTimestampToRecord bool + amqps bool ) //export FLBPluginRegister @@ -44,6 +45,9 @@ func FLBPluginInit(plugin unsafe.Pointer) int { removeRkValuesFromRecordStr := output.FLBPluginConfigKey(plugin, "RemoveRkValuesFromRecord") addTagToRecordStr := output.FLBPluginConfigKey(plugin, "AddTagToRecord") addTimestampToRecordStr := output.FLBPluginConfigKey(plugin, "AddTimestampToRecord") + amqpsStr := output.FLBPluginConfigKey(plugin, "AMQPS") + + var urlPrefix = "amqp" if len(routingKeyDelimiter) < 1 { routingKeyDelimiter = "." @@ -74,7 +78,18 @@ func FLBPluginInit(plugin unsafe.Pointer) int { return output.FLB_ERROR } - connection, err = amqp.Dial("amqp://" + user + ":" + password + "@" + host + ":" + port + "/") + amqps, err = strconv.ParseBool(amqpsStr) + if len(amqpsStr) == 0 { + logInfo("The AMQPS value was not, using default value of 'false', amqp protocol") + } + if err != nil { + logInfo("Couldn't parse amqps to boolean, using amqp") + } + if err == nil && amqps { + urlPrefix = "amqps" + } + + connection, err = amqp.Dial(urlPrefix + "://" + user + ":" + password + "@" + host + ":" + port + "/") if err != nil { logError("Failed to establish a connection to RabbitMQ: ", err) return output.FLB_ERROR From ce88e63e1c494900a844bf99c0d4aa32b620ac59 Mon Sep 17 00:00:00 2001 From: Zach McGrath Date: Fri, 15 Oct 2021 09:54:20 -0600 Subject: [PATCH 2/4] dockerfile back to original --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eef05fd..8e461db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ FROM fluent/fluent-bit:1.3 LABEL maintainer="Björn Franke" COPY --from=building-stage /go/src/out_rabbitmq.so /fluent-bit/bin/ +COPY ./conf/fluent-bit-docker.conf /fluent-bit/etc EXPOSE 2020 -CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf","-e","/fluent-bit/bin/out_rabbitmq.so"] +CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit-docker.conf","-e","/fluent-bit/bin/out_rabbitmq.so"] From 1117c2a2db7eeafb5e065155d16285f045e16317 Mon Sep 17 00:00:00 2001 From: Zachary McGrath Date: Fri, 15 Oct 2021 10:58:11 -0600 Subject: [PATCH 3/4] Update README.md Co-authored-by: Tim Furlong --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b402b90..ebf7950 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ build | RoutingKey | The routing-key pattern | "" | | RoutingKeyDelimiter | The Delemiter which seperates the routing-key parts | "." | | RemoveRkValuesFromRecord | If enabled fluentd deletes the values of the record, which have been stored in the routing-key | "" | -| AMQPS | If enabled fluent bit will attempt to connecto to RabbitMQ via the amqps protocol instead of amqp| "false" | +| AMQPS | If enabled fluent bit will attempt to connect to RabbitMQ via the amqps protocol instead of amqp| "false" | ### Routing-Key pattern From 56a7375c834bc446370bd4264cfcd61998557687 Mon Sep 17 00:00:00 2001 From: Zachary McGrath Date: Fri, 15 Oct 2021 10:59:27 -0600 Subject: [PATCH 4/4] make spacing consistent --- out_rabbitmq.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/out_rabbitmq.go b/out_rabbitmq.go index e7ace2b..5bf3f69 100755 --- a/out_rabbitmq.go +++ b/out_rabbitmq.go @@ -20,7 +20,7 @@ var ( removeRkValuesFromRecord bool addTagToRecord bool addTimestampToRecord bool - amqps bool + amqps bool ) //export FLBPluginRegister