@@ -19,11 +19,12 @@ import (
1919
2020type ElasticsearchConfig struct {
2121 // Connection specific
22- Hosts []string `yaml:"hosts"`
23- Username string `yaml:"username"`
24- Password string `yaml:"password"`
25- CloudID string `yaml:"cloudID"`
26- APIKey string `yaml:"apiKey"`
22+ Hosts []string `yaml:"hosts"`
23+ Username string `yaml:"username"`
24+ Password string `yaml:"password"`
25+ CloudID string `yaml:"cloudID"`
26+ APIKey string `yaml:"apiKey"`
27+ Headers map [string ]string `yaml:"headers"` // Can be used to append additional key value pairs into the request headers
2728 // Indexing preferences
2829 UseEventID bool `yaml:"useEventID"`
2930 // DeDot all labels and annotations in the event. For both the event and the involvedObject
@@ -42,10 +43,18 @@ func NewElasticsearch(cfg *ElasticsearchConfig) (*Elasticsearch, error) {
4243 return nil , fmt .Errorf ("failed to setup TLS: %w" , err )
4344 }
4445
46+ var header = http.Header {}
47+ if len (cfg .Headers ) > 0 {
48+ for k , v := range cfg .Headers {
49+ header .Add (k , v )
50+ }
51+ }
52+
4553 client , err := elasticsearch .NewClient (elasticsearch.Config {
4654 Addresses : cfg .Hosts ,
4755 Username : cfg .Username ,
4856 Password : cfg .Password ,
57+ Header : header ,
4958 CloudID : cfg .CloudID ,
5059 APIKey : cfg .APIKey ,
5160 Transport : & http.Transport {
0 commit comments