log: fix elastic version detection

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2019-09-26 17:28:42 +08:00
parent 31e23d73c3
commit 2b30db43af
5 changed files with 27 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/elastic/go-elasticsearch/v5"
"github.com/elastic/go-elasticsearch/v5/esapi"
"io/ioutil"
"k8s.io/klog"
"time"
)
@@ -17,9 +18,13 @@ type Elastic struct {
}
func New(address string, index string) *Elastic {
client, _ := elasticsearch.NewClient(elasticsearch.Config{
client, err := elasticsearch.NewClient(elasticsearch.Config{
Addresses: []string{address},
})
if err != nil {
klog.Error(err)
return nil
}
return &Elastic{client: client, index: index}
}