get rule node (#1042)

This commit is contained in:
zheng 2022-07-11 13:06:11 +08:00 committed by GitHub
parent cbd416495c
commit 94847d9059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -92,6 +92,7 @@ func configRoute(r *gin.Engine, version string) {
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()))

View File

@ -6,6 +6,7 @@ import (
"github.com/didi/nightingale/v5/src/server/idents"
"github.com/didi/nightingale/v5/src/server/memsto"
"github.com/didi/nightingale/v5/src/server/naming"
)
func alertRuleGet(c *gin.Context) {
@ -43,3 +44,9 @@ func userGroupGet(c *gin.Context) {
ug := memsto.UserGroupCache.GetByUserGroupId(id)
c.JSON(200, gin.H{"id": id, "user_group": ug})
}
func alertRuleNodeGet(c *gin.Context) {
id := ginx.QueryStr(c, "id")
node, _ := naming.HashRing.GetNode(id)
c.JSON(200, gin.H{"id": id, "node": node})
}