Monitor event occurrence and save it to tinyDB

i want to monitor events to occur and save with name for example "M42" to tinyDB and make one count any time envent "M42" do occur it add one more count.
eg. events counts
-------- ------------
A 6
B 8

Use the event name as a tag, and the count as a value, default 0.
Do not use any global variables for this.

OR..

Having in-house count variable, may provide ease to retrive/organise different counts.