Range query through custom window time

I have this query in Dev Tools that I do when my boss asks that counts how many cards were used in 90 days window:

GET transactions/_search
{
  "size": 0,
  "query": {
"range": {
  "timestamp": {
    "gte": "now-90d/d",
    "lte": "now"
  }
}
  },
  "aggs": {
    "by_client": {
      "terms": {
        "field": "clients.keyword"
      },
      "aggs": {
        "active_cards": {
          "cardinality": {
            "field": "card_number.keyword"
          }
        }
      }
    }
  }
}
  }
}

I need to run this for every month of my data that we have (about 3 years), so I can show in a Dashboard (example of buckets: 2021-03-01 to 2020-12-01, going back 2021-02-01 to 2020-11-01, and so on).
I will gladly give more information, but I am having some difficult to synthesize the idea.

Thank you guys in advance!

Something like this?

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