Sharding based on time

Hi,
I have a mongodb cluster with 2 shards. for the time being let’s call it shard1 and shard2. I have a source which generates large amount of data. id, amount, quantity and event_date are the document fields. I just want to shard using event_key. if event_date is falls between the month of january to june, I want to save the event into shard1. if the event_date is falling between july to december, I should store in shard2.

note: year may vary(2021, 2022, etc).all I care about is the month which event happens.

any idea about how to do this?

You may have to store the month value in a separate field, then specify it as the shard key.

But given all your writes will go to the same shard, you may get performance issue on writes (assume the event_date is like time.now())