Skip to content

Commit 6c5a321

Browse files
authored
Merge pull request #11 from Mikaelemmmm/master
add es optional username、password
2 parents e6cee8e + 108621d commit 6c5a321

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

stash/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type (
2121
TimeZone string `json:",optional"`
2222
MaxChunkBytes int `json:",default=15728640"` // default 15M
2323
Compress bool `json:",default=false"`
24+
Username string `json:",optional"`
25+
Password string `json:",optional"`
2426
}
2527

2628
Filter struct {

stash/es/writer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func NewWriter(c config.ElasticSearchConf) (*Writer, error) {
2727
elastic.SetSniff(false),
2828
elastic.SetURL(c.Hosts...),
2929
elastic.SetGzip(c.Compress),
30+
elastic.SetBasicAuth(c.Username,c.Password),
3031
)
3132
if err != nil {
3233
return nil, err

stash/stash.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func main() {
5353
client, err := elastic.NewClient(
5454
elastic.SetSniff(false),
5555
elastic.SetURL(processor.Output.ElasticSearch.Hosts...),
56+
elastic.SetBasicAuth(processor.Output.ElasticSearch.Username,processor.Output.ElasticSearch.Password),
5657
)
5758
logx.Must(err)
5859

0 commit comments

Comments
 (0)