* add GetMeta to *types.Event

Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
This commit is contained in:
Manuel Sabban 2022-09-07 10:11:39 +02:00 committed by GitHub
parent 9d199fd4a9
commit b2130b1593
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View file

@ -41,6 +41,15 @@ func (e *Event) GetMeta(key string) string {
return ""
}
func (a *Alert) GetMeta(key string) string {
for _, meta := range a.Meta {
if meta.Key == key {
return meta.Value
}
}
return ""
}
func (s Source) GetValue() string {
if s.Value == nil {
return ""

View file

@ -52,6 +52,25 @@ func (e *Event) GetType() string {
}
}
func (e *Event) GetMeta(key string) string {
if e.Type == OVFLW {
for _, alert := range e.Overflow.APIAlerts {
for _, event := range alert.Events {
if event.GetMeta(key) != "" {
return event.GetMeta(key)
}
}
}
} else if e.Type == LOG {
for k, v := range e.Meta {
if k == key {
return v
}
}
}
return ""
}
//Move in leakybuckets
const (
Undefined = ""