diff --git a/src/modules/index/cache/endpoint_map.go b/src/modules/index/cache/endpoint_map.go index d63dcac0..75959784 100644 --- a/src/modules/index/cache/endpoint_map.go +++ b/src/modules/index/cache/endpoint_map.go @@ -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) +} diff --git a/src/modules/index/http/routes/index_router.go b/src/modules/index/http/routes/index_router.go index dfab06e5..6188d359 100644 --- a/src/modules/index/http/routes/index_router.go +++ b/src/modules/index/http/routes/index_router.go @@ -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"` diff --git a/src/modules/index/http/routes/routes.go b/src/modules/index/http/routes/routes.go index 7bff4f7d..c99e0246 100644 --- a/src/modules/index/http/routes/routes.go +++ b/src/modules/index/http/routes/routes.go @@ -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)