-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Filebeat Redis prospector type #4180
Conversation
filebeat/prospector/redis/config.go
Outdated
Password: "", | ||
} | ||
|
||
type Config struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type Config should have comment or be unexported
filebeat/prospector/redis/doc.go
Outdated
@@ -0,0 +1,14 @@ | |||
// Redis package contains prospector and harvester to read the redis slow log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
package comment should be of the form "Package redis ..."
rd "github.com/garyburd/redigo/redis" | ||
) | ||
|
||
type Harvester struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type Harvester should have comment or be unexported
args []string | ||
} | ||
|
||
func (h *Harvester) Start(conn rd.Conn) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Harvester.Start should have comment or be unexported
rd "github.com/garyburd/redigo/redis" | ||
) | ||
|
||
// Stdin is a prospector for stdin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported type Prospector should be of the form "Prospector ..." (with optional leading article)
config Config | ||
} | ||
|
||
// NewStdin creates a new stdin prospector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function NewProspector should be of the form "NewProspector ..."
filebeat/_meta/common.full.p2.yml
Outdated
@@ -215,6 +215,14 @@ filebeat.prospectors: | |||
# Configuration to use stdin input | |||
#- input_type: stdin | |||
|
|||
#----------------------------- Redis prospector ------------------------------- | |||
#- input_type: redis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest somehow making it more clear that this is strictly about slow logs. People might assume that it's a general Redis input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a tricky one. Thinking more about the prospectors I get the impression we will have prospector with multiple harvester types potentially (similar to what we have in metricbeat). For example in file there could be file.csv
or file.xml
. What if we not only have slowlog for redis? But TBH I'm not sure yet what we should do here. This could also well be overengineered and we will not need it.
For the moment I think I fix the above with call it Redis slowlog prospector
in the docs but still redis
as the prospector type.
filebeat/prospector/redis/doc.go
Outdated
// | ||
// CONFIG SET slowlog-log-slower-than 100 | ||
// | ||
// This sets the value of the slow log to 100 micro seconds. All queries taking longer will be reported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use 2s or 5s as an example. 100 micros might affect the Redis performance, so we should be careful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
filebeat/prospector/redis/doc.go
Outdated
// | ||
// This sets the value of the slow log to 100 micro seconds. All queries taking longer will be reported. | ||
// | ||
// As the slow log is in memory, in can be configured how many items it consists: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo: "it can be configured"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
data := util.NewData() | ||
data.Event = common.MapStr{ | ||
// TODO: Should we still send the "fetching" timestamp or overwrite it by timestamp? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good question. In the end it needs to be the event timestamp, but I see two options:
- live it like that here, but replace it in the FB redis module
- already set it hear and also set
beat.read_timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided for option 2 for the moment. The reasons is that I think it most cases that is what people expect in @timestamp
here. So also without postprocessing in ingest, the data is already correct.
if argsLen >= 2 { | ||
log.key = args[1] | ||
} | ||
// TODO: Could args contain confidential data? Should it be optional? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess people can use drop_fields
if they don't want it.
456e2e0
to
9ba6162
Compare
filebeat/harvester/forwarder.go
Outdated
Processors processors.PluginConfig `config:"processors"` | ||
} | ||
|
||
// updateState updates the prospector state and forwards the event to the spooler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Forwarder.Forward should be of the form "Forward ..."
"github.com/satori/go.uuid" | ||
) | ||
|
||
type Harvester struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type Harvester should have comment or be unexported
args []string | ||
} | ||
|
||
func NewHarvester(outlet channel.Outleter, conn rd.Conn) *Harvester { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewHarvester should have comment or be unexported
} | ||
} | ||
|
||
func (h *Harvester) Start() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Harvester.Start should have comment or be unexported
return nil | ||
} | ||
|
||
func (h *Harvester) Stop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Harvester.Stop should have comment or be unexported
|
||
} | ||
|
||
func (h *Harvester) ID() uuid.UUID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Harvester.ID should have comment or be unexported
} | ||
} | ||
|
||
func (p *Prospector) Stop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Prospector.Stop should have comment or be unexported
|
||
} | ||
|
||
func (p *Prospector) Wait() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Prospector.Wait should have comment or be unexported
4a55634
to
36be381
Compare
@tsg Ready for an other look. I think we are at the point now where we have to decide on what to do with it :-) |
filebeat/harvester/util.go
Outdated
) | ||
|
||
// ValidType is a list of all valid input types | ||
// List of valid input types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ValidType should be of the form "ValidType ..."
} | ||
} | ||
|
||
// Start starts a new redis harvester |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Harvester.Run should be of the form "Run ..."
e021c74
to
8a8caba
Compare
@dedemorton So far I only added the minimial options of docs for this = almost nothing. The reason is that this kind of challenges our existing doc structure we have for prospectors. So far the 2 prospectors shared 95% of the config options. With this change, they can be very different. I'm thinking if we should start to organise docs similar to what we do with the modules and have a block for each prospector type. I will need your help here and suggest we will only tackle this after merging the PR. |
@ruflin I remember you mentioned this problem awhile back ago in an email, but I haven't had a chance to follow up with you. What release are we targeting for this PR? |
@dedemorton Not sure if I mentioned that before (but could be). It's not urgent. If it happens, somewhere around 6.0 |
filebeat/filebeat.full.yml
Outdated
@@ -379,6 +379,27 @@ filebeat.prospectors: | |||
# Configuration to use stdin input | |||
#- type: stdin | |||
|
|||
#------------------------- Redis slowlog prospector --------------------------- | |||
# Experimental: Config options ofr the redis slow log prospector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo on "ofr".
This PR adds a new prospector type which reads the slowlog from redis. This slowlog is not in a file but in memory in redis. Because of this filebeat connects to redis and reads out the slowlog. It is important to note that the slow log size is limited in redis that is why after fetching the events from the slowlog filebeat resets the slow log. Example event looks as following: ``` { "@timestamp": "2017-05-16T06:27:17.000Z", "beat": { "hostname": "ruflin", "name": "ruflin", "read_timestamp": "2017-05-16T06:27:19.275Z", "version": "6.0.0-alpha2" }, "message": "SET hello world", "redis": { "slowlog": { "args": [ "world" ], "cmd": "SET", "duration": { "us": 11 }, "id": 38, "key": "hello" } } } ``` All args are combined in the "message" field output for easy retrieval.
@tsg New version pushed |
This PR adds a new prospector type which reads the slowlog from redis. This slowlog is not in a file but in memory in redis. Because of this filebeat connects to redis and reads out the slowlog. It is important to note that the slow log size is limited in redis that is why after fetching the events from the slowlog filebeat resets the slow log.
Example event looks as following:
All args are combined in the "message" field output for easy retrieval.