Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Type support added for Elasticsearch 6 and lower. Fixes #77
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaakin-atl committed Aug 22, 2020
1 parent fb76366 commit f6a8e09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/sinks/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit f6a8e09

Please sign in to comment.