Extend 'type' field with information from icinga api
This commit is contained in:
parent
02d6e58153
commit
5fda97545f
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue