Add delete index by endpoint api

This commit is contained in:
710leo 2020-05-07 22:16:35 +08:00
parent a45ca89ecb
commit 7d774562c7
3 changed files with 23 additions and 0 deletions

View File

@ -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)
}

View File

@ -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"`

View File

@ -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)