mirror of
https://github.com/Icinga/icingabeat.git
synced 2025-07-28 08:14:02 +02:00
Add configuration for event stream types
This commit is contained in:
parent
f33c3da190
commit
18b5d87dc6
@ -3,13 +3,35 @@
|
|||||||
############################# Icingabeat ######################################
|
############################# Icingabeat ######################################
|
||||||
|
|
||||||
icingabeat:
|
icingabeat:
|
||||||
# Defines how often an event is sent to the output
|
|
||||||
period: 1s
|
# Defines the Icina API endpoint
|
||||||
# Icinga 2 API endpoint
|
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
# Port of Icinga 2 API
|
|
||||||
|
# Defines the port of the API endpoint
|
||||||
port: 5665
|
port: 5665
|
||||||
# User for Icinga 2 API
|
|
||||||
|
# A user with sufficient permissions
|
||||||
user: "icinga"
|
user: "icinga"
|
||||||
# Password for the Icinga 2 API user
|
|
||||||
|
# Password of the user
|
||||||
password: "icinga"
|
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
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -35,10 +36,15 @@ func NewEventstream(bt *Icingabeat, cfg config.Config) *Eventstream {
|
|||||||
|
|
||||||
// Run evenstream receiver
|
// Run evenstream receiver
|
||||||
func (es *Eventstream) Run() error {
|
func (es *Eventstream) Run() error {
|
||||||
|
types := strings.Join(es.icingabeat.config.EventTypes, "&types=")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
ticker := time.NewTicker(es.config.RetryInterval)
|
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 {
|
if responseErr == nil {
|
||||||
reader := bufio.NewReader(response.Body)
|
reader := bufio.NewReader(response.Body)
|
||||||
|
@ -7,16 +7,17 @@ import "time"
|
|||||||
|
|
||||||
// Config options
|
// Config options
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Period time.Duration `config:"period"`
|
Host string `config:"host"`
|
||||||
Host string `config:"host"`
|
Port int `config:"port"`
|
||||||
Port int `config:"port"`
|
User string `config:"user"`
|
||||||
User string `config:"user"`
|
Password string `config:"password"`
|
||||||
Password string `config:"password"`
|
RetryInterval time.Duration `config:"retry_interval"`
|
||||||
|
EventTypes []string `config:"event_types"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultConfig values
|
// DefaultConfig values
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
Period: 1 * time.Second,
|
RetryInterval: 1 * time.Second,
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
Port: 5665,
|
Port: 5665,
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,39 @@
|
|||||||
############################# Icingabeat ######################################
|
############################# Icingabeat ######################################
|
||||||
|
|
||||||
icingabeat:
|
icingabeat:
|
||||||
# Defines how often an event is sent to the output
|
|
||||||
period: 1s
|
# Defines the Icina API endpoint
|
||||||
# Icinga 2 API endpoint
|
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
# Port of Icinga 2 API
|
|
||||||
|
# Defines the port of the API endpoint
|
||||||
port: 5665
|
port: 5665
|
||||||
# User for Icinga 2 API
|
|
||||||
|
# A user with sufficient permissions
|
||||||
user: "icinga"
|
user: "icinga"
|
||||||
# Password for the Icinga 2 API user
|
|
||||||
|
# Password of the user
|
||||||
password: "icinga"
|
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 ======================================
|
#================================ General ======================================
|
||||||
|
|
||||||
# The name of the shipper that publishes the network data. It can be used to group
|
# The name of the shipper that publishes the network data. It can be used to group
|
||||||
|
@ -3,17 +3,39 @@
|
|||||||
############################# Icingabeat ######################################
|
############################# Icingabeat ######################################
|
||||||
|
|
||||||
icingabeat:
|
icingabeat:
|
||||||
# Defines how often an event is sent to the output
|
|
||||||
period: 1s
|
# Defines the Icina API endpoint
|
||||||
# Icinga 2 API endpoint
|
host: "demo"
|
||||||
host: "demo.icinga.com"
|
|
||||||
# Port of Icinga 2 API
|
# Defines the port of the API endpoint
|
||||||
port: 5665
|
port: 5665
|
||||||
# User for Icinga 2 API
|
|
||||||
user: "root"
|
# A user with sufficient permissions
|
||||||
# Password for the Icinga 2 API user
|
user: "rooto"
|
||||||
|
|
||||||
|
# Password of the user
|
||||||
password: "icinga"
|
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 =====================================
|
#================================ General =====================================
|
||||||
|
|
||||||
# The name of the shipper that publishes the network data. It can be used to group
|
# The name of the shipper that publishes the network data. It can be used to group
|
||||||
@ -37,7 +59,7 @@ icingabeat:
|
|||||||
#-------------------------- Elasticsearch output ------------------------------
|
#-------------------------- Elasticsearch output ------------------------------
|
||||||
output.elasticsearch:
|
output.elasticsearch:
|
||||||
# Array of hosts to connect to.
|
# Array of hosts to connect to.
|
||||||
hosts: ["demo.icinga.com:9200"]
|
hosts: ["demo:9200"]
|
||||||
|
|
||||||
# Optional protocol and basic auth credentials.
|
# Optional protocol and basic auth credentials.
|
||||||
#protocol: "https"
|
#protocol: "https"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user