count host from .infini_host priority
This commit is contained in:
parent
43b6322188
commit
320ee33390
|
@ -6,6 +6,7 @@ import (
|
|||
httprouter "infini.sh/framework/core/api/router"
|
||||
"infini.sh/framework/core/elastic"
|
||||
"infini.sh/framework/core/event"
|
||||
"infini.sh/framework/core/host"
|
||||
"infini.sh/framework/core/orm"
|
||||
"infini.sh/framework/core/util"
|
||||
"net/http"
|
||||
|
@ -80,10 +81,19 @@ func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req
|
|||
}
|
||||
}
|
||||
|
||||
hostCount, err := handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "metadata.host", clusterIDs)
|
||||
hostCount, err := handler.getMetricCount(orm.GetIndexName(host.HostInfo{}), "ip", nil)
|
||||
if err != nil{
|
||||
log.Error(err)
|
||||
}
|
||||
log.Info(hostCount)
|
||||
if v, ok := hostCount.(float64); ok && v == 0 {
|
||||
log.Error("sss")
|
||||
hostCount, err = handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "metadata.host", clusterIDs)
|
||||
if err != nil{
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
nodeCount, err := handler.getMetricCount(orm.GetIndexName(elastic.NodeConfig{}), "id", clusterIDs)
|
||||
if err != nil{
|
||||
log.Error(err)
|
||||
|
|
|
@ -22,7 +22,7 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
|
|||
_, _, idxs, err := client.GetMapping(copyAll, indexName)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
@ -91,14 +91,14 @@ func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req
|
|||
err := handler.DecodeJSON(req, &settings)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = client.UpdateIndexSettings(indexName, settings)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *ht
|
|||
err := client.DeleteIndex(indexName)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
@ -132,14 +132,14 @@ func (handler APIHandler) HandleCreateIndexAction(w http.ResponseWriter, req *ht
|
|||
err := handler.DecodeJSON(req, &config)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = client.CreateIndex(indexName, config)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
resBody["error"] = err
|
||||
resBody["error"] = err.Error()
|
||||
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue