Please check the suggestions made by @richgalloway, however one way to check if the data is duplicate you can use stats as follows too:
If the events are duplicate then their time value in logs shall also be repeating for the duplicate events. Doing a stats on minimal fields, including time field, can prove duplicate events and can be done as follows :
your query to return events
| stats count by Time, TaskId, Measure1, Measure2, GlobalContextVariable, GlobalContextVariable2, LocalContextVariable ....
| sort TaskId
That shall tell you the duplicates if the count field value is more than one any of the table rows. The ... in the above query should be updated with all the remaining fields you might have or want to use to see the duplicate events.
Once you know you are getting the counts as you had hoped, you can remove the count field by appending | fields - count and get the de-duplicated data.
... View more