Add delete index by endpoint api
This commit is contained in:
parent
a45ca89ecb
commit
7d774562c7
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue