Skip to content

Commit

Permalink
Fields renamed on redis 5.0 (#8167) (#8202)
Browse files Browse the repository at this point in the history
Some fields are renamed on future redis 5.0, use the new terminology on
these fields and deprecate the old ones. While old fields are not
removed, both are filled with the same value.

Tests executed also on redis 4 and 5.

(cherry picked from commit b5f225f)
  • Loading branch information
jsoriano authored Sep 3, 2018
1 parent 3154262 commit aa646e3
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ https://github.com/elastic/beats/compare/v6.4.0...6.x[Check the HEAD diff]
- Move common kafka fields (broker, topic and partition.id) to the module level to facilitate events correlation {pull}7767[7767]
- Add fields for memory fragmentation, memory allocator stats, copy on write, master-slave status, and active defragmentation to `info` metricset of Redis module. {pull}7695[7695]
- Increase ignore_above for system.process.cmdline to 2048. {pull}8101[8100]
- Add support to renamed fields planned for redis 5.0. {pull}8167[8167]


- Add `metrics` metricset to MongoDB module. {pull}7611[7611]
Expand All @@ -110,6 +111,7 @@ https://github.com/elastic/beats/compare/v6.4.0...6.x[Check the HEAD diff]

*Metricbeat*
- Redis `info` `replication.master_offset` has been deprecated in favor of `replication.master.offset`.{pull}7695[7695]
- Redis `info` clients fields `longest_output_list` and `biggest_input_buf` have been renamed to `max_output_buffer` and `max_input_buffer` based on the names they will have in Redis 5.0, both fields will coexist during a time with the same value {pull}8167[8167].

- Move common kafka fields (broker, topic and partition.id) to the module level {pull}7767[7767].

Expand Down
12 changes: 12 additions & 0 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ services:
redis:
build: ./module/redis/_meta

redis_4:
build:
context: ./module/redis/_meta
args:
REDIS_VERSION: 4.0.11

redis_5:
build:
context: ./module/redis/_meta
args:
REDIS_VERSION: 5.0-rc4

traefik:
build: ./module/traefik/_meta

Expand Down
28 changes: 27 additions & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16083,6 +16083,19 @@ Number of client connections (excluding connections from slaves).
*`redis.info.clients.longest_output_list`*::
+
--
deprecated[6.5.0]
type: long
Longest output list among current client connections (replaced by max_output_buffer).
--
*`redis.info.clients.max_output_buffer`*::
+
--
type: long
Longest output list among current client connections.
Expand All @@ -16093,9 +16106,22 @@ Longest output list among current client connections.
*`redis.info.clients.biggest_input_buf`*::
+
--
deprecated[6.5.0]
type: long
Biggest input buffer among current client connections (replaced by max_input_buffer).
--
*`redis.info.clients.max_input_buffer`*::
+
--
type: long
Biggest input buffer among current client connections.
Biggest input buffer among current client connections (on redis 5.0).
--
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/docs/modules/redis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The Redis module has these additional config options:
[float]
=== Compatibility

The Redis metricsets were tested with Redis 3.2.4 and are expected to work with all version
>= 3.0.
The Redis metricsets were tested with Redis 3.2.12, 4.0.11 and 5.0-rc4, and are expected
to work with all versions >= 3.0.


[float]
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/redis/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM redis:3.2.4-alpine
ARG REDIS_VERSION=3.2.12
FROM redis:${REDIS_VERSION}-alpine
HEALTHCHECK --interval=1s --retries=90 CMD nc -z localhost 6379
4 changes: 2 additions & 2 deletions metricbeat/module/redis/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ The Redis module has these additional config options:
[float]
=== Compatibility

The Redis metricsets were tested with Redis 3.2.4 and are expected to work with all version
>= 3.0.
The Redis metricsets were tested with Redis 3.2.12, 4.0.11 and 5.0-rc4, and are expected
to work with all versions >= 3.0.
2 changes: 1 addition & 1 deletion metricbeat/module/redis/fields.go

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

4 changes: 3 additions & 1 deletion metricbeat/module/redis/info/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"biggest_input_buf": 0,
"blocked": 0,
"connected": 1,
"longest_output_list": 0
"longest_output_list": 0,
"max_input_buffer": 0,
"max_output_buffer": 0
},
"cluster": {
"enabled": false
Expand Down
12 changes: 11 additions & 1 deletion metricbeat/module/redis/info/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@
description: >
Number of client connections (excluding connections from slaves).
- name: longest_output_list
type: long
deprecated: "6.5.0"
description: >
Longest output list among current client connections (replaced by max_output_buffer).
- name: max_output_buffer
type: long
description: >
Longest output list among current client connections.
- name: biggest_input_buf
type: long
deprecated: "6.5.0"
description: >
Biggest input buffer among current client connections (replaced by max_input_buffer).
- name: max_input_buffer
type: long
description: >
Biggest input buffer among current client connections.
Biggest input buffer among current client connections (on redis 5.0).
- name: blocked
type: long
description: >
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/module/redis/info/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var (
"connected": c.Int("connected_clients"),
"longest_output_list": c.Int("client_longest_output_list"),
"biggest_input_buf": c.Int("client_biggest_input_buf"),
"max_output_buffer": c.Int("client_recent_max_output_buffer"),
"max_input_buffer": c.Int("client_recent_max_input_buffer"),
"blocked": c.Int("blocked_clients"),
},
"cluster": s.Object{
Expand Down
15 changes: 15 additions & 0 deletions metricbeat/module/redis/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ func (m *MetricSet) Fetch() (common.MapStr, error) {
return nil, err
}

// In 5.0 some fields are renamed, maintain both names, old ones will be deprecated
renamings := []struct {
old, new string
}{
{"client_longest_output_list", "client_recent_max_output_buffer"},
{"client_biggest_input_buf", "client_recent_max_input_buffer"},
}
for _, r := range renamings {
if v, ok := info[r.new]; ok {
info[r.old] = v
} else {
info[r.new] = info[r.old]
}
}

slowLogLength, err := redis.FetchSlowLogLength(m.pool.Get())
if err != nil {
return nil, err
Expand Down
18 changes: 15 additions & 3 deletions metricbeat/tests/system/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"used.user_children"]

CLIENTS_FIELDS = ["blocked", "biggest_input_buf",
"longest_output_list", "connected"]
"longest_output_list", "connected",
"max_input_buffer", "max_output_buffer"]


class Test(metricbeat.BaseTest):
Expand Down Expand Up @@ -58,7 +59,10 @@ def test_keyspace(self):
"""

# At least one event must be inserted so db stats exist
r = redis.StrictRedis(host=os.getenv('REDIS_HOST', 'localhost'), port=os.getenv('REDIS_PORT', '6379'), db=0)
r = redis.StrictRedis(
host=self.compose_hosts()[0],
port=os.getenv('REDIS_PORT', '6379'),
db=0)
r.set('foo', 'bar')

self.render_config_template(modules=[{
Expand Down Expand Up @@ -116,5 +120,13 @@ def test_module_processors(self):
self.assertItemsEqual(self.de_dot(CPU_FIELDS), redis_info["cpu"].keys())

def get_hosts(self):
return [os.getenv('REDIS_HOST', 'localhost') + ':' +
return [self.compose_hosts()[0] + ':' +
os.getenv('REDIS_PORT', '6379')]


class TestRedis4(Test):
COMPOSE_SERVICES = ['redis_4']


class TestRedis5(Test):
COMPOSE_SERVICES = ['redis_5']

0 comments on commit aa646e3

Please sign in to comment.