Thinly slice all onions, reserving 2 cups of the sweet onions.
Heat a large skillet over low heat. Add olive oil, leeks, and onions, except for the 2 cups reserved sweet onions. Sprinkle with a large pinch of salt. Cook slowly over low heat, stirring often, so that onions caramelize, about 30 minutes. If the onions start to burn, add a little water to the pan to slow the cooking.
Once the onions are nicely caramelized, deglaze pan with balsamic vinegar, scraping up any browned bits from the bottom of the pan.
Add reserved 2 cups of sweet onions, brown sugar, and thyme. Cover the pan, and cook over low heat about 10 minutes, or until vinegar is absorbed/cooked off. Turn off heat and season to taste with salt and pepper.
Pack in a jar with a tight-fitting lid, and store in fridge for up to two weeks.