-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
If index 3 is not a list, assume Redis Enterprise and return index 4 as slowlog command #1352
Conversation
@ian28223 The command is never the last item in Redis server 4.0 or later. I'm not sure what extra entires (if any) Redis Labs returns, but this change won't work for the open source version. |
Hi @ian28223, It seems Redis Enterprise injects another entry at index [3], which has the complexity info (i.e. the value of N in case the command has an O(N) complexity). For now, I'm creating a new issue to support the |
I think the right way to work around this incompatibility of RE (until it gets fixed), is to look at the entry at [3] and see if it's an array or a string. |
It's not clear why it doesn't work, maybe redis/redis-py#1352 So disable it (pkg/collector/runner/runner.go:292 in work) | Error running check redisdb: [{"message": "sequence item 0: expected a bytes-like object, int found", "traceback": "Traceback (most recent call last): File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/base/checks/base.py\", line 876, in run self.check(instance) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/redisdb/redisdb.py\", line 501, in check self._check_slowlog() File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/redisdb/redisdb.py\", line 452, in _check_slowlog slowlogs = conn.slowlog_get(max_slow_entries) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 1466, in slowlog_get return self.execute_command(*args, decode_responses=decode_responses) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 901, in execute_command return self.parse_response(conn, command_name, **options) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 921, in parse_response return self.response_callbacks[command_name](response, **options) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 415, in parse_slowlog_get return [{ File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 419, in <listcomp> 'command': space.join(item[3]) TypeError: sequence item 0: expected a bytes-like object, int found "}]
It's not clear why it doesn't work, maybe redis/redis-py#1352 So disable it (pkg/collector/runner/runner.go:292 in work) | Error running check redisdb: [{"message": "sequence item 0: expected a bytes-like object, int found", "traceback": "Traceback (most recent call last): File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/base/checks/base.py\", line 876, in run self.check(instance) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/redisdb/redisdb.py\", line 501, in check self._check_slowlog() File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/redisdb/redisdb.py\", line 452, in _check_slowlog slowlogs = conn.slowlog_get(max_slow_entries) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 1466, in slowlog_get return self.execute_command(*args, decode_responses=decode_responses) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 901, in execute_command return self.parse_response(conn, command_name, **options) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 921, in parse_response return self.response_callbacks[command_name](response, **options) File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 415, in parse_slowlog_get return [{ File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.8/site-packages/redis/client.py\", line 419, in <listcomp> 'command': space.join(item[3]) TypeError: sequence item 0: expected a bytes-like object, int found "}]
I think in case of Redis Enterprise the field is an int as @ RoeyPrat said
In either case checking if it's a string might still be the solution |
by [3] i meant 0 based. the output posted above is from redis-cli which is 1 based. |
I've applied the suggestion which is to return index 4 as the command if index 3 is not a list. |
Seems the build has failed due to a pull limit. Is there a way to rerun it? |
@ian28223 Nit-picky, but can you fix the flake8 error please? Looks like the line is too long now. |
The error that Travis is reporting doesn't seem related to this PR. It looks like a test case that mixes mocks and threading is failing on PyPy3 suddenly. Not sure why off the top of my head, but I'll look into it this afternoon. |
Any updates as to why the unrelated test is failing? |
Codecov Report
@@ Coverage Diff @@
## master #1352 +/- ##
==========================================
+ Coverage 85.90% 86.58% +0.68%
==========================================
Files 6 7 +1
Lines 2894 2914 +20
==========================================
+ Hits 2486 2523 +37
+ Misses 408 391 -17
Continue to review full report at Codecov.
|
Seems builds are green now. Can we get this in? |
@ian28223 Can you rebase your PR off of the latest master? Thanks. |
command is always a list. If index 3 is not a list, assume Redis Enterprise and return index 4 instead
Seems an unrelated test is failing after rebasing? |
I haven't tracked down the PyPy error yet, but it's definitely not related to this change. Thanks for putting this together. |
Much appreciated for the merge! Any chance we can get a new release including it? A 3.5.4 perchance? |
When is next release planed? It's been a year since the latest |
Pull Request check-list
Please make sure to review and check all of these items:
$ tox
pass with this change (including linting)?NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
Some redis instances, Redislabs for example, return slowlog entries with the commands at
item[4]
instead ofitem[3]
.command
is always a list; return item[4] if item[3] is not a list.Example: