mirror of
https://github.com/Icinga/icingabeat.git
synced 2025-04-08 17:15:05 +02:00
Initialize event vars before using them
This commit is contained in:
parent
5b6e720df5
commit
33d384bca8
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user