mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
Elsasticsearch notification: add test cases Elasticsearch notification: make timeout configurable Elsasticsearch notification: add @timestamp field to JSON data Elsasticsearch notification: improve error handling use context.WithTimeoutCause Co-authored-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> better comment the elaticsearch api endpoint add screenshot to documentation
40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/crazy-max/diun/v4/pkg/utl"
|
|
)
|
|
|
|
type NotifElasticsearch struct {
|
|
Scheme string `yaml:"scheme,omitempty" json:"scheme,omitempty" validate:"required,oneof=http https"`
|
|
Host string `yaml:"host,omitempty" json:"host,omitempty" validate:"required"`
|
|
Port int `yaml:"port,omitempty" json:"port,omitempty" validate:"required,min=1"`
|
|
Username string `yaml:"username,omitempty" json:"username,omitempty" validate:"omitempty"`
|
|
UsernameFile string `yaml:"usernameFile,omitempty" json:"usernameFile,omitempty" validate:"omitempty,file"`
|
|
Password string `yaml:"password,omitempty" json:"password,omitempty" validate:"omitempty"`
|
|
PasswordFile string `yaml:"passwordFile,omitempty" json:"passwordFile,omitempty" validate:"omitempty,file"`
|
|
Client string `yaml:"client,omitempty" json:"client,omitempty" validate:"required"`
|
|
Index string `yaml:"index,omitempty" json:"index,omitempty" validate:"required"`
|
|
Timeout *time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" validate:"required"`
|
|
InsecureSkipVerify bool `yaml:"insecureSkipVerify,omitempty" json:"insecureSkipVerify,omitempty" validate:"omitempty"`
|
|
}
|
|
|
|
// GetDefaults gets the default values
|
|
func (s *NotifElasticsearch) GetDefaults() *NotifElasticsearch {
|
|
n := &NotifElasticsearch{}
|
|
n.SetDefaults()
|
|
return n
|
|
}
|
|
|
|
// SetDefaults sets the default values
|
|
func (s *NotifElasticsearch) SetDefaults() {
|
|
s.Scheme = "http"
|
|
s.Host = "localhost"
|
|
s.Port = 9200
|
|
s.Client = "diun"
|
|
s.Index = "diun-notifications"
|
|
s.Timeout = utl.NewDuration(10 * time.Second)
|
|
s.InsecureSkipVerify = false
|
|
}
|