func (redis *Redis) publishTransaction(t *transaction) { if redis.results == nil { return } event := common.MapStr{} event["type"] = "redis" if !t.IsError { event["status"] = common.OK_STATUS } else { event["status"] = common.ERROR_STATUS } event["responsetime"] = t.ResponseTime if redis.SendRequest { event["request"] = t.RequestRaw } if redis.SendResponse { event["response"] = t.ResponseRaw } event["redis"] = common.MapStr(t.Redis) event["method"] = strings.ToUpper(t.Method) event["resource"] = t.Path event["query"] = t.Query event["bytes_in"] = uint64(t.BytesIn) event["bytes_out"] = uint64(t.BytesOut) event["@timestamp"] = common.Time(t.ts) event["src"] = &t.Src event["dst"] = &t.Dst redis.results.PublishEvent(event) }
func toStr(key string, data map[string]interface{}) (interface{}, error) { emptyIface, err := common.MapStr(data).GetValue(key) if err != nil { fmt.Println(err) return "", fmt.Errorf("Key %s not found", key) } str, ok := emptyIface.(string) if !ok { return "", fmt.Errorf("Expected string, found %T", emptyIface) } return str, nil }
func (c *mockConn) recvDocs(count uint32) ([]common.MapStr, error) { var docs []*message for len(docs) < int(count) { msg, err := c.recvMessage() if err != nil { return nil, err } docs = append(docs, msg.events...) } var ret []common.MapStr for _, v := range docs { ret = append(ret, common.MapStr(v.doc)) } return ret, nil }