diff --git a/src/server/router/router.go b/src/server/router/router.go index 0f3ec907..299c1184 100644 --- a/src/server/router/router.go +++ b/src/server/router/router.go @@ -86,13 +86,13 @@ func configRoute(r *gin.Engine, version string) { r.POST("/prometheus/v1/query", stat(), queryPromql) r.GET("/memory/alert-rule", alertRuleGet) + r.GET("/memory/alert-rule-location", alertRuleLocationGet) r.GET("/memory/idents", identsGets) r.GET("/memory/alert-mutes", mutesGets) r.GET("/memory/alert-subscribes", subscribesGets) r.GET("/memory/target", targetGet) r.GET("/memory/user", userGet) r.GET("/memory/user-group", userGroupGet) - r.GET("/memory/node/alert-rule", alertRuleNodeGet) r.GET("/metrics", gin.WrapH(promhttp.Handler())) diff --git a/src/server/router/router_memsto.go b/src/server/router/router_memsto.go index f320ef39..da8a6346 100644 --- a/src/server/router/router_memsto.go +++ b/src/server/router/router_memsto.go @@ -1,6 +1,8 @@ package router import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/toolkits/pkg/ginx" @@ -45,8 +47,13 @@ func userGroupGet(c *gin.Context) { c.JSON(200, gin.H{"id": id, "user_group": ug}) } -func alertRuleNodeGet(c *gin.Context) { +func alertRuleLocationGet(c *gin.Context) { id := ginx.QueryStr(c, "id") - node, _ := naming.HashRing.GetNode(id) + node, err := naming.HashRing.GetNode(id) + if err != nil { + http.Error(c.Writer, err.Error(), http.StatusInternalServerError) + return + } + c.JSON(200, gin.H{"id": id, "node": node}) -} \ No newline at end of file +}