From 108621dba2f1ba75ed33e8af399a7a99fe6933f5 Mon Sep 17 00:00:00 2001 From: mikael <13247629622@163.com> Date: Fri, 18 Mar 2022 20:02:02 +0800 Subject: [PATCH] =?UTF-8?q?add=20es=20optional=20=20username=E3=80=81passw?= =?UTF-8?q?ord?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stash/config/config.go | 2 ++ stash/es/writer.go | 1 + stash/stash.go | 1 + 3 files changed, 4 insertions(+) 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)