Add support for POSTing to /series endpoint (#5422)

* Add support for POSTing to /series endpoint
* Document query API POST support

Signed-off-by: Bob Shannon <bob.m.shannon@gmail.com>
This commit is contained in:
Bob Shannon 2019-04-02 13:00:29 -04:00 committed by Brian Brazil
parent e5a427f2ef
commit 8c8bb82d04
3 changed files with 18 additions and 2 deletions

View File

@ -74,6 +74,7 @@ The following endpoint evaluates an instant query at a single point in time:
```
GET /api/v1/query
POST /api/v1/query
```
URL query parameters:
@ -85,6 +86,10 @@ URL query parameters:
The current server time is used if the `time` parameter is omitted.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
or dynamic number of series selectors that may breach server-side URL character limits.
The `data` section of the query result has the following format:
```
@ -135,6 +140,7 @@ The following endpoint evaluates an expression query over a range of time:
```
GET /api/v1/query_range
POST /api/v1/query_range
```
URL query parameters:
@ -146,6 +152,10 @@ URL query parameters:
- `timeout=<duration>`: Evaluation timeout. Optional. Defaults to and
is capped by the value of the `-query.timeout` flag.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
or dynamic number of series selectors that may breach server-side URL character limits.
The `data` section of the query result has the following format:
```
@ -205,6 +215,7 @@ The following endpoint returns the list of time series that match a certain labe
```
GET /api/v1/series
POST /api/v1/series
```
URL query parameters:
@ -214,6 +225,10 @@ URL query parameters:
- `start=<rfc3339 | unix_timestamp>`: Start timestamp.
- `end=<rfc3339 | unix_timestamp>`: End timestamp.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
or dynamic number of series selectors that may breach server-side URL character limits.
The `data` section of the query result consists of a list of objects that
contain the label name/value pairs which identify each series.
@ -221,7 +236,7 @@ The following example returns all series that match either of the selectors
`up` or `process_start_time_seconds{job="prometheus"}`:
```json
$ curl -g 'http://localhost:9090/api/v1/series?match[]=up&match[]=process_start_time_seconds{job="prometheus"}'
$ curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode='match[]=up' --data-urlencode='match[]=process_start_time_seconds{job="prometheus"}'
{
"status" : "success",
"data" : [

View File

@ -231,6 +231,7 @@ func (api *API) Register(r *route.Router) {
r.Get("/label/:name/values", wrap(api.labelValues))
r.Get("/series", wrap(api.series))
r.Post("/series", wrap(api.series))
r.Del("/series", wrap(api.dropSeries))
r.Get("/targets", wrap(api.targets))

View File

@ -835,7 +835,7 @@ func testEndpoints(t *testing.T, api *API, testLabelAPI bool) {
methods := func(f apiFunc) []string {
fp := reflect.ValueOf(f).Pointer()
if fp == reflect.ValueOf(api.query).Pointer() || fp == reflect.ValueOf(api.queryRange).Pointer() {
if fp == reflect.ValueOf(api.query).Pointer() || fp == reflect.ValueOf(api.queryRange).Pointer() || fp == reflect.ValueOf(api.series).Pointer() {
return []string{http.MethodGet, http.MethodPost}
}
return []string{http.MethodGet}