Extend 'type' field with information from icinga api

This commit is contained in:
Blerim Sheqa 2017-01-20 14:41:07 +01:00
parent 02d6e58153
commit 5fda97545f
4 changed files with 12 additions and 6 deletions

View File

@ -6,7 +6,7 @@
type: keyword
required: true
description: >
Type of the document. Can either be icingabeat.event or icingabet.status
Type of the document.
- name: host
type: keyword

View File

@ -6,6 +6,7 @@ import (
"io"
"net/url"
"strconv"
"strings"
"sync"
"time"
@ -101,7 +102,8 @@ func (es *Eventstream) Run() error {
}
event["@timestamp"] = common.Time(time.Now())
event["type"] = "icingabeat.event"
documentType := strings.ToLower(event["type"].(string))
event["type"] = "icingabeat.event." + documentType
es.icingabeat.client.PublishEvent(event)
logp.Info("Event sent")
}

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/url"
"strconv"
"strings"
"time"
"github.com/icinga/icingabeat/config"
@ -71,12 +72,15 @@ func (sp *Statuspoller) Run() error {
for _, status := range statustype {
statusevent := common.MapStr{
"@timestamp": common.Time(time.Now()),
"type": "icingabeat.status",
}
for key, value := range status.(map[string]interface{}) {
if key != "perfdata" {
statusevent.Put(key, value)
if key == "name" {
documentType := strings.ToLower(value.(string))
statusevent.Put("type", "icingabeat.status."+documentType)
} else {
statusevent.Put(key, value)
}
}
}

View File

@ -134,7 +134,7 @@ type: keyword
required: True
Type of the document. Can either be icingabeat.event or icingabet.status
Type of the document.
[float]