How to make a row of record unique to prevent it from overwriting?

Due to the appendToExisting is turned on (set as true), I encounter an issue where two distinct records with having the same timestamp where the existing data is overwritten by the new data. I am wondering on how to make the row of record unique, so that, it can prevent from overwriting?

Hello,

I think this link will help you to solve your problem.
https://druid.apache.org/docs/latest/development/extensions-contrib/distinctcount.html

Thanks for your guidance!