Add configuration for event stream types

This commit is contained in:
Blerim Sheqa 2016-12-30 13:37:43 +01:00
parent f33c3da190
commit 18b5d87dc6
5 changed files with 103 additions and 30 deletions

View File

@ -3,13 +3,35 @@
############################# Icingabeat ######################################
icingabeat:
# Defines how often an event is sent to the output
period: 1s
# Icinga 2 API endpoint
# Defines the Icina API endpoint
host: "localhost"
# Port of Icinga 2 API
# Defines the port of the API endpoint
port: 5665
# User for Icinga 2 API
# A user with sufficient permissions
user: "icinga"
# Password for the Icinga 2 API user
# Password of the user
password: "icinga"
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange

View File

@ -4,6 +4,7 @@ import (
"bufio"
"encoding/json"
"io"
"strings"
"sync"
"time"
@ -35,10 +36,15 @@ func NewEventstream(bt *Icingabeat, cfg config.Config) *Eventstream {
// Run evenstream receiver
func (es *Eventstream) Run() error {
types := strings.Join(es.icingabeat.config.EventTypes, "&types=")
for {
ticker := time.NewTicker(es.config.RetryInterval)
response, responseErr := requestURL(es.icingabeat, "POST", "/v1/events?queue=icingabeat&types=CheckResult")
response, responseErr := requestURL(
es.icingabeat,
"POST",
"/v1/events?queue=icingabeat&types="+types)
if responseErr == nil {
reader := bufio.NewReader(response.Body)

View File

@ -7,16 +7,17 @@ import "time"
// Config options
type Config struct {
Period time.Duration `config:"period"`
Host string `config:"host"`
Port int `config:"port"`
User string `config:"user"`
Password string `config:"password"`
Host string `config:"host"`
Port int `config:"port"`
User string `config:"user"`
Password string `config:"password"`
RetryInterval time.Duration `config:"retry_interval"`
EventTypes []string `config:"event_types"`
}
// DefaultConfig values
var DefaultConfig = Config{
Period: 1 * time.Second,
Host: "localhost",
Port: 5665,
RetryInterval: 1 * time.Second,
Host: "localhost",
Port: 5665,
}

View File

@ -3,17 +3,39 @@
############################# Icingabeat ######################################
icingabeat:
# Defines how often an event is sent to the output
period: 1s
# Icinga 2 API endpoint
# Defines the Icina API endpoint
host: "localhost"
# Port of Icinga 2 API
# Defines the port of the API endpoint
port: 5665
# User for Icinga 2 API
# A user with sufficient permissions
user: "icinga"
# Password for the Icinga 2 API user
# Password of the user
password: "icinga"
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange
#================================ General ======================================
# The name of the shipper that publishes the network data. It can be used to group

View File

@ -3,17 +3,39 @@
############################# Icingabeat ######################################
icingabeat:
# Defines how often an event is sent to the output
period: 1s
# Icinga 2 API endpoint
host: "demo.icinga.com"
# Port of Icinga 2 API
# Defines the Icina API endpoint
host: "demo"
# Defines the port of the API endpoint
port: 5665
# User for Icinga 2 API
user: "root"
# Password for the Icinga 2 API user
# A user with sufficient permissions
user: "rooto"
# Password of the user
password: "icinga"
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange
#================================ General =====================================
# The name of the shipper that publishes the network data. It can be used to group
@ -37,7 +59,7 @@ icingabeat:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["demo.icinga.com:9200"]
hosts: ["demo:9200"]
# Optional protocol and basic auth credentials.
#protocol: "https"