diff --git a/README.md b/README.md index 1a9df1d..ebf7950 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 connect 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..5bf3f69 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