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

[feat:filebeat/input/redis/slowlog] Add client address and name to submitted slowlogs #41507

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- The performance of ingesting SQS data with the S3 input has improved by up to 60x for queues with many small events. `max_number_of_messages` config for SQS mode is now ignored, as the new design no longer needs a manual cap on messages. Instead, use `number_of_workers` to scale ingestion rate in both S3 and SQS modes. The increased efficiency may increase network bandwidth consumption, which can be throttled by lowering `number_of_workers`. It may also increase number of events stored in memory, which can be throttled by lowering the configured size of the internal queue. {pull}40699[40699]

- Add kafka compression support for ZSTD.
- Redis: Add client address and name to submitted slowlogs

*Heartbeat*

Expand Down
20 changes: 13 additions & 7 deletions filebeat/input/redis/harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ type Harvester struct {
// 4) 1) "slowlog"
// 2) "get"
// 3) "100"
// 5) "100.1.1.1:12345"
// 6) "client-name"
type log struct {
id int64
timestamp int64
duration int
cmd string
key string
args []string
id int64
timestamp int64
duration int
cmd string
key string
args []string
clientAddr string
clientName string
}

// NewHarvester creates a new harvester with the given connection
Expand Down Expand Up @@ -128,7 +132,7 @@ func (h *Harvester) Run() error {

var log log
var args []string
_, err = rd.Scan(entry, &log.id, &log.timestamp, &log.duration, &args)
_, err = rd.Scan(entry, &log.id, &log.timestamp, &log.duration, &args, &log.clientAddr, &log.clientName)
if err != nil {
logp.Err("Error scanning slowlog entry: %s", err)
continue
Expand Down Expand Up @@ -156,6 +160,8 @@ func (h *Harvester) Run() error {
"us": log.duration,
},
"role": role,
"clientAddr": log.clientAddr,
"clientName": log.clientName,
}

if log.args != nil {
Expand Down
2 changes: 2 additions & 0 deletions filebeat/tests/system/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def test_input(self):
assert output["input.type"] == "redis"
assert "redis.slowlog.cmd" in output
assert "redis.slowlog.role" in output
assert "redis.slowlog.clientAddr" in output
assert "redis.slowlog.clientName" in output

def get_host(self):
return os.getenv('REDIS_HOST', 'localhost')
Expand Down
Loading