initialize bug fixed

This commit is contained in:
liugq 2023-02-10 18:13:56 +08:00
parent 844969c5c1
commit 31e314ec87
2 changed files with 11 additions and 2 deletions

View File

@ -86,7 +86,7 @@ func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req
if err != nil{
log.Error(err)
}
if v, ok := hostCount.(float64); ok && v == 0 {
if v, ok := hostCount.(float64); (ok && v == 0) || hostCount == nil {
hostCount, err = handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "metadata.host", clusterIDs)
if err != nil{
log.Error(err)

View File

@ -399,7 +399,16 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
if dslWriteSuccess{
lines := util.FileGetLines(dslFile)
_,err,_:=replay.ReplayLines(pipeline.AcquireContext(),lines,cfg.Schema,cfg.Host)
ctx := pipeline.AcquireContext()
var (
username string
password string
)
if cfg.BasicAuth != nil {
username = cfg.BasicAuth.Username
password = cfg.BasicAuth.Password
}
_,err,_:=replay.ReplayLines(ctx,lines,cfg.Schema,cfg.Host,username,password)
if err!=nil{
log.Error(err)
}