magneticio / vamp

Vamp - canary releasing and autoscaling for microservice systems
http://vamp.io
Apache License 2.0
625 stars 55 forks source link

Pagination on /events endpoint does not work #1071

Open tnolet opened 6 years ago

tnolet commented 6 years ago

It is impossible to get more than 30 items from the /events endpoint due to pagination not working as described in https://vamp.io/documentation/api/v0.9.5/using-the-api/#pagination. The per_page and page parameters seem to be completely ignored.

Easy to reproduce with the following bash command or just by counting items.

http GET "localhost/service/vamp/api/v1/events?per_page=40" | jq '.[].id' | wc -l
      30

Using Vamp 0.9.5 on DC/OS but this is most probably unrelated to orchestrator.

dragoslav commented 6 years ago

Can't reproduce it:

$ http GET "http://localhost:8080/api/v1/events?per_page=2&page=1" | jq '.[].id'
"41574765743355396c78326132764f514a496e73"
"41574765743355356c78326132764f514a496e72"
$ http GET "http://localhost:8080/api/v1/events?per_page=2&page=2" | jq '.[].id'
"41574765743355426c78326132764f514a496e71"
"41574765743236626c78326132764f514a496e70"
$ http GET "http://localhost:8080/api/v1/events?per_page=2&page=3" | jq '.[].id'
"41574765743257316c78326132764f514a496e6f"
"41574765743249516c78326132764f514a496e6e"
$ http GET "http://localhost:8080/api/v1/events?page=3&per_page=2" | jq '.[].id'
"41574765743257316c78326132764f514a496e6f"
"41574765743249516c78326132764f514a496e6e"
$ http GET "http://localhost:8080/api/v1/events?per_page=2" | jq '.[].id'
"41574765743355396c78326132764f514a496e73"
"41574765743355356c78326132764f514a496e72"
dragoslav commented 6 years ago

Ok, what I can find is that max number of events is 30 (e.g. if you use ?per_page=40) - this is just a hard-coded limit. Still you should be able to use page parameter.

tnolet commented 6 years ago

@dragoslav Yeah, so we should fix the per_page parameter to behave as expected

dragoslav commented 6 years ago

@tnolet you mean without hard limit? Reason for this is that Vamp sends request to Elasticsearch or whatever handles the events. Let's say you want last 100000 events, you could do that by sending many requests (page=...) or single per_page=100000 if there is no limit. In this case either Vamp asks for 100000 (if that is supported by 3rd party, e.g. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html) or handles for you multiple requests in the background. Then you could also you could add some conditions to request (per type, date etc.). All of this complicates Vamp implementation instead to be (as it is now) just simple 1 on 1 request to 3rd party. Of course hard limit of 30 could be changed (even configurable) but there should be an upper limit.

olafmol commented 6 years ago

@tnolet could you describe how you would expect it to behave? tnx!