Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
da12c647
Commit
da12c647
authored
7 years ago
by
Ildar Svetlov
Committed by
Daniel Nelson
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to select which queues will be gathered to rabbitmq input (#3702)
parent
de03ee3c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/inputs/rabbitmq/README.md
+5
-0
5 additions, 0 deletions
plugins/inputs/rabbitmq/README.md
plugins/inputs/rabbitmq/rabbitmq.go
+40
-8
40 additions, 8 deletions
plugins/inputs/rabbitmq/rabbitmq.go
with
45 additions
and
8 deletions
plugins/inputs/rabbitmq/README.md
+
5
−
0
View file @
da12c647
...
@@ -44,6 +44,11 @@ For additional details reference the [RabbitMQ Management HTTP Stats](https://cd
...
@@ -44,6 +44,11 @@ For additional details reference the [RabbitMQ Management HTTP Stats](https://cd
## A list of exchanges to gather as the rabbitmq_exchange measurement. If not
## A list of exchanges to gather as the rabbitmq_exchange measurement. If not
## specified, metrics for all exchanges are gathered.
## specified, metrics for all exchanges are gathered.
# exchanges = ["telegraf"]
# exchanges = ["telegraf"]
## Queues to include and exclude. Globs accepted.
## Note that an empty array for both will include all queues
# queue_name_include = []
# queue_name_exclude = []
```
```
### Measurements & Fields:
### Measurements & Fields:
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/rabbitmq/rabbitmq.go
+
40
−
8
View file @
da12c647
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"time"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/filter"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/inputs"
)
)
...
@@ -52,7 +53,14 @@ type RabbitMQ struct {
...
@@ -52,7 +53,14 @@ type RabbitMQ struct {
Queues
[]
string
Queues
[]
string
Exchanges
[]
string
Exchanges
[]
string
QueueInclude
[]
string
`toml:"queue_name_include"`
QueueExclude
[]
string
`toml:"queue_name_exclude"`
Client
*
http
.
Client
Client
*
http
.
Client
filterCreated
bool
excludeEveryQueue
bool
queueFilter
filter
.
Filter
}
}
// OverviewResponse ...
// OverviewResponse ...
...
@@ -195,6 +203,11 @@ var sampleConfig = `
...
@@ -195,6 +203,11 @@ var sampleConfig = `
## A list of exchanges to gather as the rabbitmq_exchange measurement. If not
## A list of exchanges to gather as the rabbitmq_exchange measurement. If not
## specified, metrics for all exchanges are gathered.
## specified, metrics for all exchanges are gathered.
# exchanges = ["telegraf"]
# exchanges = ["telegraf"]
## Queues to include and exclude. Globs accepted.
## Note that an empty array for both will include all queues
queue_name_include = []
queue_name_exclude = []
`
`
// SampleConfig ...
// SampleConfig ...
...
@@ -225,6 +238,15 @@ func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
...
@@ -225,6 +238,15 @@ func (r *RabbitMQ) Gather(acc telegraf.Accumulator) error {
}
}
}
}
// Create queue filter if not already created
if
!
r
.
filterCreated
{
err
:=
r
.
createQueueFilter
()
if
err
!=
nil
{
return
err
}
r
.
filterCreated
=
true
}
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
wg
.
Add
(
len
(
gatherFunctions
))
wg
.
Add
(
len
(
gatherFunctions
))
for
_
,
f
:=
range
gatherFunctions
{
for
_
,
f
:=
range
gatherFunctions
{
...
@@ -361,6 +383,9 @@ func gatherNodes(r *RabbitMQ, acc telegraf.Accumulator) {
...
@@ -361,6 +383,9 @@ func gatherNodes(r *RabbitMQ, acc telegraf.Accumulator) {
}
}
func
gatherQueues
(
r
*
RabbitMQ
,
acc
telegraf
.
Accumulator
)
{
func
gatherQueues
(
r
*
RabbitMQ
,
acc
telegraf
.
Accumulator
)
{
if
r
.
excludeEveryQueue
{
return
}
// Gather information about queues
// Gather information about queues
queues
:=
make
([]
Queue
,
0
)
queues
:=
make
([]
Queue
,
0
)
err
:=
r
.
requestJSON
(
"/api/queues"
,
&
queues
)
err
:=
r
.
requestJSON
(
"/api/queues"
,
&
queues
)
...
@@ -370,7 +395,7 @@ func gatherQueues(r *RabbitMQ, acc telegraf.Accumulator) {
...
@@ -370,7 +395,7 @@ func gatherQueues(r *RabbitMQ, acc telegraf.Accumulator) {
}
}
for
_
,
queue
:=
range
queues
{
for
_
,
queue
:=
range
queues
{
if
!
r
.
shouldGatherQueue
(
queu
e
)
{
if
!
r
.
queueFilter
.
Match
(
queue
.
Nam
e
)
{
continue
continue
}
}
tags
:=
map
[
string
]
string
{
tags
:=
map
[
string
]
string
{
...
@@ -463,18 +488,25 @@ func (r *RabbitMQ) shouldGatherNode(node Node) bool {
...
@@ -463,18 +488,25 @@ func (r *RabbitMQ) shouldGatherNode(node Node) bool {
return
false
return
false
}
}
func
(
r
*
RabbitMQ
)
shouldGatherQueue
(
queue
Queue
)
bool
{
func
(
r
*
RabbitMQ
)
createQueueFilter
()
error
{
if
len
(
r
.
Queues
)
==
0
{
// Backwards compatibility for deprecated `queues` parameter.
return
true
if
len
(
r
.
Queues
)
>
0
{
r
.
QueueInclude
=
append
(
r
.
QueueInclude
,
r
.
Queues
...
)
}
}
for
_
,
name
:=
range
r
.
Queues
{
filter
,
err
:=
filter
.
NewIncludeExcludeFilter
(
r
.
QueueInclude
,
r
.
QueueExclude
)
if
name
==
queue
.
Name
{
if
err
!=
nil
{
return
true
return
err
}
r
.
queueFilter
=
filter
for
_
,
q
:=
range
r
.
QueueExclude
{
if
q
==
"*"
{
r
.
excludeEveryQueue
=
true
}
}
}
}
return
false
return
nil
}
}
func
(
r
*
RabbitMQ
)
shouldGatherExchange
(
exchange
Exchange
)
bool
{
func
(
r
*
RabbitMQ
)
shouldGatherExchange
(
exchange
Exchange
)
bool
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment