magneticio/vamp

Pagination on /events endpoint does not work

tnolet opened this issue · 5 comments

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.

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"

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.

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

@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.

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