diff --git a/README.md b/README.md index e601f5f5..046c88bc 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,8 @@ receivers: apiKey: # optional # If set to true, it allows updating the same document in ES (might be useful handling count) useEventID: true|false + # Type should be only used for clusters Version 6 and lower. + # type: kube-event layout: # Optional tls: # optional, advanced options for tls insecureSkipVerify: true|false # optional, if set to true, the tls cert won't be verified diff --git a/pkg/sinks/elasticsearch.go b/pkg/sinks/elasticsearch.go index 3306faa8..b6e090e9 100644 --- a/pkg/sinks/elasticsearch.go +++ b/pkg/sinks/elasticsearch.go @@ -26,6 +26,7 @@ type ElasticsearchConfig struct { UseEventID bool `yaml:"useEventID"` Index string `yaml:"index"` IndexFormat string `yaml:"indexFormat"` + Type string `yaml:"type"` TLS struct { InsecureSkipVerify bool `yaml:"insecureSkipVerify"` ServerName string `yaml:"serverName"` @@ -126,6 +127,11 @@ func (e *Elasticsearch) Send(ctx context.Context, ev *kube.EnhancedEvent) error Index: index, } + // This should not be used for clusters with ES8.0+. + if len(e.cfg.Type) > 0 { + req.DocumentType = e.cfg.Type + } + if e.cfg.UseEventID { req.DocumentID = string(ev.UID) }