Added code to write metadata for alarms to db