1234567891011121314151617181920 |
- package utils
- import (
- "github.com/olivere/elastic/v7"
- )
- var EsClient *elastic.Client
- func initEs() {
- client, err := elastic.NewClient(
- elastic.SetURL(ES_URL),
- elastic.SetBasicAuth(ES_USERNAME, ES_PASSWORD),
- elastic.SetSniff(false))
- EsClient = client
- if err != nil {
- panic("ElasticSearch连接失败,Err:" + err.Error())
- //go alarm_msg.SendAlarmMsg("ElasticSearch连接失败", 2)
- }
- return
- }
|