Saving metrics into db