diff --git a/plugin/api/index_management/elasticsearch.go b/plugin/api/index_management/elasticsearch.go index 345898f1..ece5704e 100644 --- a/plugin/api/index_management/elasticsearch.go +++ b/plugin/api/index_management/elasticsearch.go @@ -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) diff --git a/plugin/api/index_management/indices.go b/plugin/api/index_management/indices.go index 271378e3..7ab92ccd 100644 --- a/plugin/api/index_management/indices.go +++ b/plugin/api/index_management/indices.go @@ -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 }