diff --git a/beater/eventstream.go b/beater/eventstream.go index ed0a537b..0dd8eb6e 100644 --- a/beater/eventstream.go +++ b/beater/eventstream.go @@ -13,6 +13,7 @@ import ( "github.com/icinga/icingabeat/config" "github.com/elastic/beats/libbeat/beat" + "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/logp" ) @@ -47,6 +48,7 @@ func BuildEventstreamEvent(e []byte) beat.Event { } event.Timestamp = time.Now() + event.Fields = common.MapStr{} for key, value := range icingaEvent { event.Fields.Put(key, value) diff --git a/beater/statuspoller.go b/beater/statuspoller.go index 0e5b1e3a..9a5aeb11 100644 --- a/beater/statuspoller.go +++ b/beater/statuspoller.go @@ -11,6 +11,7 @@ import ( "github.com/icinga/icingabeat/config" "github.com/elastic/beats/libbeat/beat" + "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/logp" ) @@ -45,6 +46,8 @@ func BuildStatusEvents(body []byte) []beat.Event { for _, status := range result.([]interface{}) { var event beat.Event + event.Fields = common.MapStr{} + event.Timestamp = time.Now() for key, value := range status.(map[string]interface{}) { switch key { @@ -53,7 +56,6 @@ func BuildStatusEvents(body []byte) []beat.Event { switch statusvalue.(type) { case map[string]interface{}: if len(statusvalue.(map[string]interface{})) > 0 { - event.Fields.Put(key, value) } @@ -88,7 +90,6 @@ func BuildStatusEvents(body []byte) []beat.Event { } if statusAvailable, _ := event.Fields.HasKey("status"); statusAvailable == true { - event.Timestamp = time.Now() statusEvents = append(statusEvents, event) } }