# How can i increment cursor by one for each run in httpjson

**URL:** <https://discuss.elastic.co/t/how-can-i-increment-cursor-by-one-for-each-run-in-httpjson/345421>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 19, 2023, 10:16pm UTC](https://discuss.elastic.co/t/how-can-i-increment-cursor-by-one-for-each-run-in-httpjson/345421 "2023-10-19T22:16:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![German\_Bravo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/german_bravo/32/102396_2.png) [@German\_Bravo](https://discuss.elastic.co/u/German_Bravo)\
**Post date:** [October 19, 2023, 10:16pm UTC](https://discuss.elastic.co/t/how-can-i-increment-cursor-by-one-for-each-run-in-httpjson/345421/1 "2023-10-19T22:16:54Z")

</div>

Hi im using the httpjson input module in filebeat and im trying to achieve the following without any luck

In words:

1. I need to fetch an API every 10s
2. In the first run i need to set query param page = 0
3. In the following runs i need to set query param page to page+1 if .last\_response.body.meta.has\_next\_results equals true, else page

I tried to achieve this using a cursor and request.transform but it always goes to the default.  
Below is the YAML:

```auto
  filebeat.inputs:
  - type: httpjson
    interval: 5s
    request.method: GET
    request.url: https://api.com
    cursor:
      page:
        value: '[[if eq .last_response.body.meta.has_next_results true]][[add .cursor.page 1]][[else]][[.cursor.page]][[end]]'
        default: '0'
    request.transforms:
      - set:
          target: url.params.per_page
          value: '10'
      - set:
          target: url.params.order_key
          value: 'created_at'
      - set:
          target: url.params.order_direction
          value: 'asc'
      - set:
          target: url.params.page
          value: '[[.cursor.page]]'
          default: '0'
    response.split:
      target: body.activities
      ignore_empty_value: true

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 17, 2023, 12:17am UTC](https://discuss.elastic.co/t/how-can-i-increment-cursor-by-one-for-each-run-in-httpjson/345421/2 "2023-11-17T00:17:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
