From 571569961df4932a8f133f6f248aa2a38e5406a9 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Wed, 20 Mar 2024 11:37:37 -0400 Subject: [PATCH] metricbeat/module/rabbitmq/queue: Fix data type for `consumers.utilisation.pct` (#38436) 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 (https://github.com/stretchr/testify/pull/1531). This PR removes the temporary testify v1.8.4 pin. --- CHANGELOG.next.asciidoc | 3 ++- NOTICE.txt | 4 ++-- go.mod | 1 - go.sum | 4 ++-- metricbeat/docs/fields.asciidoc | 2 +- metricbeat/module/rabbitmq/fields.go | 2 +- metricbeat/module/rabbitmq/queue/_meta/data.json | 4 ++-- metricbeat/module/rabbitmq/queue/_meta/fields.yml | 3 ++- metricbeat/module/rabbitmq/queue/data.go | 2 +- metricbeat/module/rabbitmq/queue/queue_test.go | 2 +- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index f3bb1acc9a3..675c3cad1bb 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -109,12 +109,13 @@ 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 Azure Monitor 429 error by causing metricbeat to retry the request again. {pull}38294[38294] - Fix fields not being parsed correctly in postgresql/database {issue}25301[25301] {pull}37720[37720] +- rabbitmq/queue - Change the mapping type of `rabbitmq.queue.consumers.utilisation.pct` to `scaled_float` from `long` because the values fall within the range of `[0.0, 1.0]`. Previously, conversion to integer resulted in reporting either `0` or `1`. *Osquerybeat* diff --git a/NOTICE.txt b/NOTICE.txt index f2e34a27813..bc542437a72 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -22892,11 +22892,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Dependency : github.com/stretchr/testify -Version: v1.8.4 +Version: v1.9.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.8.4/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.9.0/LICENSE: MIT License diff --git a/go.mod b/go.mod index cb6342852c4..f8404d4c3c7 100644 --- a/go.mod +++ b/go.mod @@ -420,7 +420,6 @@ replace ( github.com/google/gopacket => github.com/elastic/gopacket v1.1.20-0.20211202005954-d412fca7f83a github.com/insomniacslk/dhcp => github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3 // indirect github.com/snowflakedb/gosnowflake => github.com/snowflakedb/gosnowflake v1.6.19 - github.com/stretchr/testify v1.9.0 => github.com/stretchr/testify v1.8.4 // Temporary fix for https://github.com/elastic/beats/pull/38436. github.com/tonistiigi/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c k8s.io/kubernetes v1.13.0 => k8s.io/kubernetes v1.24.15 ) diff --git a/go.sum b/go.sum index 709e6f12d53..75b7cbc2c0f 100644 --- a/go.sum +++ b/go.sum @@ -1847,8 +1847,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 435760b7406..6694528df13 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -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 diff --git a/metricbeat/module/rabbitmq/fields.go b/metricbeat/module/rabbitmq/fields.go index 95345f6b335..a2d590d8109 100644 --- a/metricbeat/module/rabbitmq/fields.go +++ b/metricbeat/module/rabbitmq/fields.go @@ -32,5 +32,5 @@ func init() { // AssetRabbitmq returns asset data. // This is the base64 encoded zlib format compressed contents of module/rabbitmq. func AssetRabbitmq() string { - return "eJzsW1+PG7kNf99PQezL5oDNIH3dhwLXvev1HjbINbn2oSgWtER7VGukiaixd1r0uxeUxv9n1vbuOLm28UOA2DPk70dSFElp38Kc2jsIOJmYWH2+AogmWrqD6z+nrx5+ub4C0MQqmDoa7+7g91cAAKufofK6sXQFEMgSMt3BDK8AmGI0bsZ38LdrZnt9C9dljPX1368Apoas5rsk5y04rGgHgXxiW4uk4Ju6+6YHw66kbWmL0nNcf7sSN6d26YPe+r5XaP78xYTYoAWRlKTC0sQSnHdvv/94//PPoEoMqCIFBmKFNWlABuPgvjjAo7xzpETNAahtjkcg9UrZNfvqs2+YbTDy784Pw/Y5Akg+n0rK5vFTiCVtgXyJwZ5z4gYoWoO890uNsdyEUdH3cmVmATOPGJp9GxzhOUo8bNNrmMKZ7OSVosd9ryL2K1NIkPphOq/7o+UEJ8i7o+N97zU9g5cjxhHD+34Tzklyv1JVonNk982R9VrvZi9YU001oSCraiUcvNtbYc+CeazwaUQ8FT6Zqqn6cKG1fkn6VHzTgBWNiO6hQ1ZTqAyzmVgCNv9MGQmzNnhjHEzaSPwdRA+OZj4ajN0aVtaQi1zsSZ76UGG8y+/1MhHEI2bStu7Jov02HEyNL9L8kcKCQhKaU/kkonGkYWEQAi0oMMEP7z/egg9gIsPPHwC1DsQMZrr9BEzRWAmFAEtk0IZxYkn3k6iJQjEukw90ER7ORyD3HBUf+lmcH86dM0TiM2YbUWGy2TPqUM0pPirfuFgwubHUvl8nkqyBQYSfmkR2UAVSZBa0HyvjIVspeBG6mpw2BxjGA9fJPxWbV/Gy7kwKzvPmNqaLObPDda4v8+7wWAe/MJp0Xz3zioSVqi+uSZmpIb1dPe+WOCs09CTb7oxe00f0yPitdRGfG2peXWH/jzcQugmyI/USnHhvCd15CP9aUixlrYS04W38wE1YmAX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CBtsRj5KrTOGVdeXcO0jVDjUhzi8p+8dMq48hruuUyHev+6BDPbtYesqYJ3ho0rC/hVnq9aBAwE1qt0muwdiOEihWQOzs2ZrFBtCOSiXYL2C7f2R67y/2IFmOC3LPivZNHVwI4JZVunO6A1Pk6aYHwwcXm2wn/FACzNyXJK6hvdRA/cNsMX8pR33NYU+Ez12Yb+EfZtNNZw8uWiUf1AWKElPek7PZVXxpWTGarowy38cHMzMH5pKKjDm2rH6pWQ+/yV70oihzdTigtpPW+Km9Ro/FDcvM0eteOcqdaKHkxdkzYYSZyMrJHgu25no99SBnyuDINCJy5oiZOfOqEvnr9el13b1EZce7oER3Hhw4MsKIkz3gBNoBlFVeXj4SPH2KnyHNUXPrV1LtRRL3M75lA9OL+wpEvSGw28yQrT1MRqIITuwTzHOfvOKfsWojNegUiqOfe4JOs/+i7JivPlq0G9F9YHMJ5d4erg0kbGfT7l73rjua3Qp/mU7aREW1KEHTAnIf96thnawGe8JESBDUdy4x74fpYosp1K12w2QnXocyR4k8oCtAtcsmykm5xtAzoWU+ZVPBi8ah+Wp832h88Mjgr3/+k2QHK+dADQZY2UKESi3fkEILNXJhVJqdpZC30NxinbplvhHFE9XENF2KRQvrqFCBxDq2IbhuaOacgtW3ncOmPfgJKWedshD4fZ6QJNUoHhVUNknCIwEVIfNLTvkgh5bP9tZNgacZ0kxLqer/yc7NE5w3p4MKWIz5s/HFD+dqOGDOX7rOFJ8b53orudaHaa4VZU+dZqifdXaXPJCymsryKF2jiJmQOt4Mh/01fleeU+7J9NGlAIuGhUhqaXDmujroqLfwcAAP//9NY4nA==" } diff --git a/metricbeat/module/rabbitmq/queue/_meta/data.json b/metricbeat/module/rabbitmq/queue/_meta/data.json index 51f8696f24b..42992de9967 100644 --- a/metricbeat/module/rabbitmq/queue/_meta/data.json +++ b/metricbeat/module/rabbitmq/queue/_meta/data.json @@ -20,7 +20,7 @@ "consumers": { "count": 3, "utilisation": { - "pct": 0 + "pct": 0.7 } }, "disk": { @@ -68,4 +68,4 @@ "address": "127.0.0.1:55555", "type": "rabbitmq" } -} \ No newline at end of file +} diff --git a/metricbeat/module/rabbitmq/queue/_meta/fields.yml b/metricbeat/module/rabbitmq/queue/_meta/fields.yml index 93a496d5926..0376de9d367 100644 --- a/metricbeat/module/rabbitmq/queue/_meta/fields.yml +++ b/metricbeat/module/rabbitmq/queue/_meta/fields.yml @@ -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. diff --git a/metricbeat/module/rabbitmq/queue/data.go b/metricbeat/module/rabbitmq/queue/data.go index 682abcbc194..35a4a772c0e 100644 --- a/metricbeat/module/rabbitmq/queue/data.go +++ b/metricbeat/module/rabbitmq/queue/data.go @@ -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{ diff --git a/metricbeat/module/rabbitmq/queue/queue_test.go b/metricbeat/module/rabbitmq/queue/queue_test.go index 4e0d08aba6f..41f0fd61b20 100644 --- a/metricbeat/module/rabbitmq/queue/queue_test.go +++ b/metricbeat/module/rabbitmq/queue/queue_test.go @@ -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"])