Skip to content

Commit

Permalink
Fields renamed on redis 5.0
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.
  • Loading branch information
jsoriano committed Aug 30, 2018
1 parent 0884236 commit dc97fd0
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 12 deletions.
12 changes: 12 additions & 0 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,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 @@ -16093,6 +16093,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 @@ -16103,9 +16116,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
15 changes: 12 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,7 @@ 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=os.getenv('REDIS_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 +117,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 [os.getenv('REDIS_HOST', 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 dc97fd0

Please sign in to comment.