Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Support AMQPS protocol #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" |
zmcgrath96 marked this conversation as resolved.
Show resolved Hide resolved

### Routing-Key pattern

Expand Down
17 changes: 16 additions & 1 deletion out_rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
removeRkValuesFromRecord bool
addTagToRecord bool
addTimestampToRecord bool
amqps bool
zmcgrath96 marked this conversation as resolved.
Show resolved Hide resolved
)

//export FLBPluginRegister
Expand All @@ -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 = "."
Expand Down Expand Up @@ -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
Expand Down