Simplify redis access event format to faciliate parsing (#9046)

This commit is contained in:
Hamid 2020-02-26 17:23:32 +00:00 committed by GitHub
parent 6f66f1a910
commit 5b8975bf4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -61,6 +61,12 @@ type RedisArgs struct {
QueueLimit uint64 `json:"queueLimit"` QueueLimit uint64 `json:"queueLimit"`
} }
// RedisAccessEvent holds event log data and timestamp
type RedisAccessEvent struct {
Event []event.Event
EventTime string
}
// Validate RedisArgs fields // Validate RedisArgs fields
func (r RedisArgs) Validate() error { func (r RedisArgs) Validate() error {
if !r.Enable { if !r.Enable {
@ -185,7 +191,7 @@ func (target *RedisTarget) send(eventData event.Event) error {
} }
if target.args.Format == event.AccessFormat { if target.args.Format == event.AccessFormat {
data, err := json.Marshal([]interface{}{eventData.EventTime, []event.Event{eventData}}) data, err := json.Marshal([]RedisAccessEvent{{Event: []event.Event{eventData}, EventTime: eventData.EventTime}})
if err != nil { if err != nil {
return err return err
} }