提交 7d774562 编写于 作者: 7 710leo

Add delete index by endpoint api

上级 a45ca89e
......@@ -133,3 +133,10 @@ func (e *EndpointIndexMap) GetEndpoints() []string {
}
return ret
}
func (e *EndpointIndexMap) DelByEndpoint(endpoint string) {
e.Lock()
defer e.Unlock()
delete(e.M, endpoint)
}
......@@ -40,6 +40,21 @@ func GetMetrics(c *gin.Context) {
render.Data(c, resp, nil)
}
type EndpointRecv struct {
Endpoints []string `json:"endpoints"`
}
func DelIdxByEndpoint(c *gin.Context) {
recv := EndpointRecv{}
errors.Dangerous(c.ShouldBindJSON(&recv))
for _, endpoint := range recv.Endpoints {
cache.IndexDB.DelByEndpoint(endpoint)
}
render.Data(c, "ok", nil)
}
type EndpointMetricRecv struct {
Endpoints []string `json:"endpoints"`
Metrics []string `json:"metrics"`
......
......@@ -16,6 +16,7 @@ func Config(r *gin.Engine) {
sys.POST("/metrics", GetMetrics)
sys.DELETE("/metrics", DelMetrics)
sys.DELETE("/endpoints", DelIdxByEndpoint)
sys.DELETE("/counter", DelCounter)
sys.POST("/tagkv", GetTagPairs)
sys.POST("/counter/fullmatch", GetIndexByFullTags)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册