Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZooKeeper module: Adapt to ZooKeeper 3.6+ mntr response fields' changes. #30068

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3834c0c
ZooKeeper module: Adapt to ZooKeeper 3.6+ `mntr` response fields' cha…
pfcoperez Jan 27, 2022
2308a1c
`zk_learners` and `zk_followers` need to be optional in other to make…
pfcoperez Jan 27, 2022
3967840
Update ITs
pfcoperez Jan 27, 2022
24ef6e9
Test metric beats ZooKeeper module against officialZooKeeper 3.5, 3.6…
pfcoperez Feb 3, 2022
b46e16c
PR Comments: Remove unnecessary `ZOOKEEPER_VARIANT` values.
pfcoperez Feb 3, 2022
f676add
PR Comments: Add `learners` field description, update followers.
pfcoperez Feb 3, 2022
d0f443a
PR Comments: Update compatibility notes
pfcoperez Feb 4, 2022
94347e2
Add CHANGELOG entry
pfcoperez Feb 4, 2022
2379bb0
Update generated asciidoc
pfcoperez Feb 4, 2022
1868aec
Fix go integration tests by removing string quotes in ZK Docker compo…
pfcoperez Feb 4, 2022
46cb5eb
Include leader schema fields when `zk_learners` is provided instead o…
pfcoperez Feb 4, 2022
25f45fa
PR Comments: Offer a seamless migration path for Dashboards, alerts a…
pfcoperez Feb 8, 2022
93567d4
PR Comments: Removed wrong changelog annotation
pfcoperez Feb 8, 2022
9b40f02
PR Comments: Make code more idiomatic
pfcoperez Feb 9, 2022
d034056
`mntr` unit tests
pfcoperez Feb 9, 2022
93fde37
Lint style changes
pfcoperez Feb 9, 2022
77212ad
PR comments: UT, Test mntr samples against expected values
pfcoperez Feb 10, 2022
45b9b24
PR Suggestions: Make use `t.Run` to group all tests for a given version
pfcoperez Feb 10, 2022
e4c96c7
PR Suggestions: Embed mntr samples as string variable contents by loa…
pfcoperez Feb 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...main[Check the HEAD dif
- Extract correct index property in kibana.stats metricset {pull}29622[29622]
- Fixed bug with `elasticsearch/cluster_stats` metricset not recording license expiration date correctly. {pull}29711[29711]
- Enhance metricbeat on openshift documentation {pull}30054[30054]
- Fixed missing ZooKeeper metrics due compatibility issues with versions >= 3.6.0 {pull}30068[30068]

*Packetbeat*

Expand Down
12 changes: 11 additions & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63770,7 +63770,7 @@ type: long
*`zookeeper.mntr.followers`*::
+
--
Number of followers seen by the current host.
Number of followers seen by the current host (Up to ZooKeeper 3.5.9).


type: long
Expand Down Expand Up @@ -63915,6 +63915,16 @@ type: long
Number of znodes reported by the local ZooKeeper process.


type: long

--

*`zookeeper.mntr.learners`*::
+
--
Number of learners (either followers or observers) seen by the current host (From ZooKeeper 3.6.0)


type: long

--
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/docs/modules/zookeeper.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ metricsets are `mntr` and `server`.
[float]
=== Compatibility

The ZooKeeper metricsets were tested with ZooKeeper 3.4.8 and are expected to work with all version
The ZooKeeper metricsets were tested with ZooKeeper 3.4.8, 3.6.0 and 3.7.0. They are expected to work with all versions
>= 3.4.0. Versions prior to 3.4 do not support the `mntr` command.

Note that from ZooKeeper 3.6.0, `mntr` command must be explicitly enabled at ZooKeeper side using the `4lw.commands.whitelist` configuration parameter.

[float]
=== Dashboard

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/zookeeper/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ARG ZOOKEEPER_VERSION
FROM jplock/zookeeper:${ZOOKEEPER_VERSION}
FROM zookeeper:${ZOOKEEPER_VERSION}
pfcoperez marked this conversation as resolved.
Show resolved Hide resolved
HEALTHCHECK --interval=1s --retries=90 CMD nc -z localhost 2181
4 changes: 3 additions & 1 deletion metricbeat/module/zookeeper/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ metricsets are `mntr` and `server`.
[float]
=== Compatibility

The ZooKeeper metricsets were tested with ZooKeeper 3.4.8 and are expected to work with all version
The ZooKeeper metricsets were tested with ZooKeeper 3.4.8, 3.6.0 and 3.7.0. They are expected to work with all versions
>= 3.4.0. Versions prior to 3.4 do not support the `mntr` command.

Note that from ZooKeeper 3.6.0, `mntr` command must be explicitly enabled at ZooKeeper side using the `4lw.commands.whitelist` configuration parameter.

[float]
=== Dashboard

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/zookeeper/_meta/supported-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variants:
- ZOOKEEPER_VERSION: 3.5.5
- ZOOKEEPER_VERSION: 3.6.3
- ZOOKEEPER_VERSION: 3.7.0
2 changes: 2 additions & 0 deletions metricbeat/module/zookeeper/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ services:
ZOOKEEPER_VERSION: ${ZOOKEEPER_VERSION:-3.5.5}
ports:
- 2181
environment:
- ZOO_4LW_COMMANDS_WHITELIST=stat, ruok, conf, isro, cons, mntr
2 changes: 1 addition & 1 deletion metricbeat/module/zookeeper/fields.go

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

6 changes: 5 additions & 1 deletion metricbeat/module/zookeeper/mntr/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- name: followers
type: long
description: >
Number of followers seen by the current host.
Number of followers seen by the current host (Up to ZooKeeper 3.5.9).
- name: max_file_descriptor_count
type: long
description: >
Expand Down Expand Up @@ -82,3 +82,7 @@
type: long
description: >
Number of znodes reported by the local ZooKeeper process.
- name: learners
type: long
description: >
Number of learners (either followers or observers) seen by the current host (From ZooKeeper 3.6.0)
19 changes: 14 additions & 5 deletions metricbeat/module/zookeeper/mntr/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var (
schema = s.Schema{
"version": c.Str("zk_version"),
"latency": s.Object{
"avg": c.Int("zk_avg_latency"),
"min": c.Int("zk_min_latency"),
"max": c.Int("zk_max_latency"),
"avg": c.Float("zk_avg_latency"),
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
"min": c.Float("zk_min_latency"),
"max": c.Float("zk_max_latency"),
},
"packets": s.Object{
"received": c.Int("zk_packets_received"),
Expand All @@ -53,7 +53,8 @@ var (
"approximate_data_size": c.Int("zk_approximate_data_size"),
}
schemaLeader = s.Schema{
"followers": c.Int("zk_followers"),
"learners": c.Int("zk_learners", s.Optional),
pfcoperez marked this conversation as resolved.
Show resolved Hide resolved
"followers": c.Int("zk_followers", s.Optional), // Not present anymore in ZooKeeper >= 3.6 mntr responses
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
"synced_followers": c.Int("zk_synced_followers"),
"pending_syncs": c.Int("zk_pending_syncs"),
}
Expand Down Expand Up @@ -86,8 +87,16 @@ func eventMapping(serverId string, response io.Reader, r mb.ReporterV2, logger *
}

// only exposed by the Leader
if _, ok := fullEvent["zk_followers"]; ok {
if hasFollowers, hasLearners := fullEvent["zk_followers"], fullEvent["zk_learners"]; hasFollowers != nil || hasLearners != nil {
pfcoperez marked this conversation as resolved.
Show resolved Hide resolved
schemaLeader.ApplyTo(event, fullEvent)

if learners, ok := event["learners"]; ok {
// If ZK >= 3.6, keep a legacy view of the "learners" field
event.Put("followers", learners)
} else if followers, ok := event["followers"]; ok {
// If ZK < 3.6, keep a migration to recent versions view of the "followers" field
event.Put("learners", followers)
}
}

// only available on Unix platforms
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/zookeeper/mntr/mntr_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestFetch(t *testing.T) {
e, _ := events[0].BeatEvent("zookeeper", "mntr").Fields.GetValue("zookeeper.mntr")
event := e.(common.MapStr)
// Check values
avgLatency := event["latency"].(common.MapStr)["avg"].(int64)
maxLatency := event["latency"].(common.MapStr)["max"].(int64)
avgLatency := event["latency"].(common.MapStr)["avg"].(float64)
maxLatency := event["latency"].(common.MapStr)["max"].(float64)
numAliveConnections := event["num_alive_connections"].(int64)

assert.True(t, avgLatency >= 0)
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/zookeeper/test_zookeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"approximate_data_size", "num_alive_connections"]


@metricbeat.parameterized_with_supported_versions
class ZooKeeperMntrTest(metricbeat.BaseTest):

COMPOSE_SERVICES = ['zookeeper']
Expand Down