diff --git a/stash/config/config.go b/stash/config/config.go index d6ed949..c558aff 100644 --- a/stash/config/config.go +++ b/stash/config/config.go @@ -21,6 +21,8 @@ type ( TimeZone string `json:",optional"` MaxChunkBytes int `json:",default=15728640"` // default 15M Compress bool `json:",default=false"` + Username string `json:",optional"` + Password string `json:",optional"` } Filter struct { diff --git a/stash/es/writer.go b/stash/es/writer.go index 1f67eee..266bbe5 100644 --- a/stash/es/writer.go +++ b/stash/es/writer.go @@ -27,6 +27,7 @@ func NewWriter(c config.ElasticSearchConf) (*Writer, error) { elastic.SetSniff(false), elastic.SetURL(c.Hosts...), elastic.SetGzip(c.Compress), + elastic.SetBasicAuth(c.Username,c.Password), ) if err != nil { return nil, err diff --git a/stash/stash.go b/stash/stash.go index 465d21f..b23d307 100644 --- a/stash/stash.go +++ b/stash/stash.go @@ -53,6 +53,7 @@ func main() { client, err := elastic.NewClient( elastic.SetSniff(false), elastic.SetURL(processor.Output.ElasticSearch.Hosts...), + elastic.SetBasicAuth(processor.Output.ElasticSearch.Username,processor.Output.ElasticSearch.Password), ) logx.Must(err)