Skip to content

Commit

Permalink
Add RabbitMQ slave_nodes and synchronized_slave_nodes metrics (influx…
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg authored and idohalevi committed Sep 23, 2020
1 parent 7a1cf8d commit 6e5d606
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
4 changes: 3 additions & 1 deletion plugins/inputs/rabbitmq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ For additional details reference the [RabbitMQ Management HTTP Stats][management
- messages_ready (int, count)
- messages_redeliver (int, count)
- messages_redeliver_rate (float, messages per second)
- messages_unack (integer, count)
- messages_unack (int, count)
- slave_nodes (int, count)
- synchronised_slave_nodes (int, count)

+ rabbitmq_exchange
- tags:
Expand Down
34 changes: 19 additions & 15 deletions plugins/inputs/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ type QueueTotals struct {

// Queue ...
type Queue struct {
QueueTotals // just to not repeat the same code
MessageStats `json:"message_stats"`
Memory int64
Consumers int64
ConsumerUtilisation float64 `json:"consumer_utilisation"`
Name string
Node string
Vhost string
Durable bool
AutoDelete bool `json:"auto_delete"`
IdleSince string `json:"idle_since"`
QueueTotals // just to not repeat the same code
MessageStats `json:"message_stats"`
Memory int64
Consumers int64
ConsumerUtilisation float64 `json:"consumer_utilisation"`
Name string
Node string
Vhost string
Durable bool
AutoDelete bool `json:"auto_delete"`
IdleSince string `json:"idle_since"`
SlaveNodes []string `json:"slave_nodes"`
SynchronisedSlaveNodes []string `json:"synchronised_slave_nodes"`
}

// Node ...
Expand Down Expand Up @@ -585,10 +587,12 @@ func gatherQueues(r *RabbitMQ, acc telegraf.Accumulator) {
"rabbitmq_queue",
map[string]interface{}{
// common information
"consumers": queue.Consumers,
"consumer_utilisation": queue.ConsumerUtilisation,
"idle_since": queue.IdleSince,
"memory": queue.Memory,
"consumers": queue.Consumers,
"consumer_utilisation": queue.ConsumerUtilisation,
"idle_since": queue.IdleSince,
"slave_nodes": len(queue.SlaveNodes),
"synchronised_slave_nodes": len(queue.SynchronisedSlaveNodes),
"memory": queue.Memory,
// messages information
"message_bytes": queue.MessageBytes,
"message_bytes_ready": queue.MessageBytesReady,
Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/rabbitmq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func TestRabbitMQGeneratesMetrics(t *testing.T) {
"messages_redeliver": 33,
"messages_redeliver_rate": 2.5,
"idle_since": "2015-11-01 8:22:14",
"slave_nodes": 1,
"synchronised_slave_nodes": 1,
}
compareMetrics(t, queuesMetrics, acc, "rabbitmq_queue")

Expand Down
8 changes: 7 additions & 1 deletion plugins/inputs/rabbitmq/testdata/queues.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@
"exclusive_consumer_tag": null,
"effective_policy_definition": [],
"operator_policy": null,
"policy": null
"policy": null,
"slave_nodes":[
"rabbit@ip-10-1-2-118"
],
"synchronised_slave_nodes":[
"rabbit@ip-10-1-2-118"
]
}
]

0 comments on commit 6e5d606

Please sign in to comment.