Skip to content

Commit fa6fa56

Browse files
committed
metricbeat/module/rabbitmq/queue - Fix data type for consumers.utilisation.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).
1 parent 9c9ae35 commit fa6fa56

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

CHANGELOG.next.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ fields added to events containing the Beats version. {pull}37553[37553]
107107
- Fix panics when parsing dereferencing invalid parsed url. {pull}34702[34702]
108108
- Fix setuid root when running under cgroups v2. {pull}37794[37794]
109109
- Adjust State loader to only retry when response code status is 5xx {pull}37981[37981]
110-
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]
110+
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]
111111

112112
*Metricbeat*
113113

114114
- Fix fields not being parsed correctly in postgresql/database {issue}25301[25301] {pull}37720[37720]
115+
- 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.
115116

116117
*Osquerybeat*
117118

metricbeat/docs/fields.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57758,7 +57758,7 @@ type: long
5775857758
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.
5775957759

5776057760

57761-
type: long
57761+
type: scaled_float
5776257762

5776357763
format: percent
5776457764

metricbeat/module/rabbitmq/fields.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metricbeat/module/rabbitmq/queue/_meta/data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"consumers": {
2121
"count": 3,
2222
"utilisation": {
23-
"pct": 0
23+
"pct": 0.7
2424
}
2525
},
2626
"disk": {
@@ -68,4 +68,4 @@
6868
"address": "127.0.0.1:55555",
6969
"type": "rabbitmq"
7070
}
71-
}
71+
}

metricbeat/module/rabbitmq/queue/_meta/fields.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
description: >
4646
Number of consumers.
4747
- name: consumers.utilisation.pct
48-
type: long
48+
type: scaled_float
49+
scaling_factor: 100
4950
format: percent
5051
description: >
5152
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.

metricbeat/module/rabbitmq/queue/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
"consumers": s.Object{
4444
"count": c.Int("consumers"),
4545
"utilisation": s.Object{
46-
"pct": c.Int("consumer_utilisation", s.IgnoreAllErrors),
46+
"pct": c.Float("consumer_utilisation", s.IgnoreAllErrors),
4747
},
4848
},
4949
"messages": s.Object{

metricbeat/module/rabbitmq/queue/queue_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestFetchEventContents(t *testing.T) {
5555
consumers := event["consumers"].(mapstr.M)
5656
utilisation := consumers["utilisation"].(mapstr.M)
5757
assert.EqualValues(t, 3, consumers["count"])
58-
assert.EqualValues(t, 0.7, utilisation["pct"])
58+
assert.Equal(t, 0.7, utilisation["pct"])
5959

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

0 commit comments

Comments
 (0)