mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Support non POST methods for Lifecycle and Admin APIs (#5376)
Signed-off-by: Bharath Thiruveedula <bharath_ves@hotmail.com>
This commit is contained in:
parent
2833ad490b
commit
91306bdf24
|
@ -694,6 +694,7 @@ It will optionally skip snapshotting data that is only present in the head block
|
|||
|
||||
```
|
||||
POST /api/v1/admin/tsdb/snapshot?skip_head=<bool>
|
||||
PUT /api/v1/admin/tsdb/snapshot?skip_head=<bool>
|
||||
```
|
||||
|
||||
```json
|
||||
|
@ -705,10 +706,9 @@ $ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/snapshot
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
The snapshot now exists at `<data-dir>/snapshots/20171210T211224Z-2be650b6d019eb54`
|
||||
|
||||
*New in v2.1*
|
||||
*New in v2.1 and supports PUT from v2.9*
|
||||
|
||||
### Delete Series
|
||||
DeleteSeries deletes data for a selection of series in a time range. The actual data still exists on disk and is cleaned up in future compactions or can be explicitly cleaned up by hitting the Clean Tombstones endpoint.
|
||||
|
@ -717,6 +717,7 @@ If successful, a `204` is returned.
|
|||
|
||||
```
|
||||
POST /api/v1/admin/tsdb/delete_series
|
||||
PUT /api/v1/admin/tsdb/delete_series
|
||||
```
|
||||
|
||||
URL query parameters:
|
||||
|
@ -733,7 +734,7 @@ Example:
|
|||
$ curl -X POST \
|
||||
-g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=up&match[]=process_start_time_seconds{job="prometheus"}'
|
||||
```
|
||||
*New in v2.1*
|
||||
*New in v2.1 and supports PUT from v2.9*
|
||||
|
||||
### Clean Tombstones
|
||||
CleanTombstones removes the deleted data from disk and cleans up the existing tombstones. This can be used after deleting series to free up space.
|
||||
|
@ -742,6 +743,7 @@ If successful, a `204` is returned.
|
|||
|
||||
```
|
||||
POST /api/v1/admin/tsdb/clean_tombstones
|
||||
PUT /api/v1/admin/tsdb/clean_tombstones
|
||||
```
|
||||
|
||||
This takes no parameters or body.
|
||||
|
@ -750,4 +752,4 @@ This takes no parameters or body.
|
|||
$ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/clean_tombstones
|
||||
```
|
||||
|
||||
*New in v2.1*
|
||||
*New in v2.1 and supports PUT from v2.9*
|
|
@ -248,6 +248,11 @@ func (api *API) Register(r *route.Router) {
|
|||
r.Post("/admin/tsdb/delete_series", wrap(api.deleteSeries))
|
||||
r.Post("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
|
||||
r.Post("/admin/tsdb/snapshot", wrap(api.snapshot))
|
||||
|
||||
r.Put("/admin/tsdb/delete_series", wrap(api.deleteSeries))
|
||||
r.Put("/admin/tsdb/clean_tombstones", wrap(api.cleanTombstones))
|
||||
r.Put("/admin/tsdb/snapshot", wrap(api.snapshot))
|
||||
|
||||
}
|
||||
|
||||
type queryData struct {
|
||||
|
|
|
@ -307,7 +307,9 @@ func New(logger log.Logger, o *Options) *Handler {
|
|||
|
||||
if o.EnableLifecycle {
|
||||
router.Post("/-/quit", h.quit)
|
||||
router.Put("/-/quit", h.quit)
|
||||
router.Post("/-/reload", h.reload)
|
||||
router.Put("/-/reload", h.reload)
|
||||
} else {
|
||||
router.Post("/-/quit", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
|
@ -320,11 +322,11 @@ func New(logger log.Logger, o *Options) *Handler {
|
|||
}
|
||||
router.Get("/-/quit", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
w.Write([]byte("Only POST requests allowed"))
|
||||
w.Write([]byte("Only POST or PUT requests allowed"))
|
||||
})
|
||||
router.Get("/-/reload", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
w.Write([]byte("Only POST requests allowed"))
|
||||
w.Write([]byte("Only POST or PUT requests allowed"))
|
||||
})
|
||||
|
||||
router.Get("/debug/*subpath", serveDebug)
|
||||
|
|
Loading…
Reference in a new issue