Skip to content

Commit

Permalink
metricbeat/module/rabbitmq/queue - Fix data type for consumers.utilis…
Browse files Browse the repository at this point in the history
…ation.pct

Fix mapping type for `rabbitmq.queue.consumers.utilisation.pct` to be `scaled_float` instead of `long` because the values range on `[0, 1.0]`. Previously, truncation converted the value to an integer so it either reported zero or one.

There was a bug in the unit tests that did not catch this until we updated to testify 1.9.0 (stretchr/testify#1531).
  • Loading branch information
andrewkroh committed Mar 19, 2024
1 parent 9c9ae35 commit fa6fa56
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Expand Up @@ -107,11 +107,12 @@ fields added to events containing the Beats version. {pull}37553[37553]
- Fix panics when parsing dereferencing invalid parsed url. {pull}34702[34702]
- Fix setuid root when running under cgroups v2. {pull}37794[37794]
- Adjust State loader to only retry when response code status is 5xx {pull}37981[37981]
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]

*Metricbeat*

- Fix fields not being parsed correctly in postgresql/database {issue}25301[25301] {pull}37720[37720]
- rabbitmq/queue - Fix mapping type for `rabbitmq.queue.consumers.utilisation.pct` to be `scaled_float` instead of `long` because the values range on `[0, 1.0]`. Previously, truncation converted the value to an integer so it either reported zero or one.

*Osquerybeat*

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/fields.asciidoc
Expand Up @@ -57758,7 +57758,7 @@ type: long
Fraction of the time (between 0.0 and 1.0) that the queue is able to immediately deliver messages to consumers. This can be less than 1.0 if consumers are limited by network congestion or prefetch count.


type: long
type: scaled_float

format: percent

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions metricbeat/module/rabbitmq/queue/_meta/data.json
Expand Up @@ -20,7 +20,7 @@
"consumers": {
"count": 3,
"utilisation": {
"pct": 0
"pct": 0.7
}
},
"disk": {
Expand Down Expand Up @@ -68,4 +68,4 @@
"address": "127.0.0.1:55555",
"type": "rabbitmq"
}
}
}
3 changes: 2 additions & 1 deletion metricbeat/module/rabbitmq/queue/_meta/fields.yml
Expand Up @@ -45,7 +45,8 @@
description: >
Number of consumers.
- name: consumers.utilisation.pct
type: long
type: scaled_float
scaling_factor: 100
format: percent
description: >
Fraction of the time (between 0.0 and 1.0) that the queue is able to immediately deliver messages to consumers. This can be less than 1.0 if consumers are limited by network congestion or prefetch count.
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/queue/data.go
Expand Up @@ -43,7 +43,7 @@ var (
"consumers": s.Object{
"count": c.Int("consumers"),
"utilisation": s.Object{
"pct": c.Int("consumer_utilisation", s.IgnoreAllErrors),
"pct": c.Float("consumer_utilisation", s.IgnoreAllErrors),
},
},
"messages": s.Object{
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/queue/queue_test.go
Expand Up @@ -55,7 +55,7 @@ func TestFetchEventContents(t *testing.T) {
consumers := event["consumers"].(mapstr.M)
utilisation := consumers["utilisation"].(mapstr.M)
assert.EqualValues(t, 3, consumers["count"])
assert.EqualValues(t, 0.7, utilisation["pct"])
assert.Equal(t, 0.7, utilisation["pct"])

memory := event["memory"].(mapstr.M)
assert.EqualValues(t, 232720, memory["bytes"])
Expand Down

0 comments on commit fa6fa56

Please sign in to comment.