For the Pickled Red Onions:
Place red onions in a 1-quart jar and cover them with water. Pour off the water into a measuring cup. Note the volume, pour off half the water and replace it with vinegar. Pour the liquid into a saucepan and add 2 tablespoons sugar and 2 tablespoons salt for every 3 cups of liquid. Add the mustard seeds, red pepper flakes, coriander seeds, peppercorns, garlic and bay leaves. Bring to a boil over high heat. Boil for 2 minutes then remove from heat.
Layer the onions into a 1-quart sterilized jar, cover the onions with the hot liquid and seal the jar. Refrigerate for 2 weeks before using. The pickled onions will keep refrigerated for up to one year.
For the Spicy Ketchup:
Heat oil in a nonreactive 2-quart saucepan over medium heat. Add the onion, garlic and a three-finger pinch of salt and sweat until the onion is translucent, about 2 minutes. Add the Fresno chiles, ancho or chipotle, and red pepper flakes. Cook for a minute or two. Stir in the brown sugar, cumin, cinnamon, tomato paste and vinegar, and simmer for 10 minutes. Stir in 3 cups of water, bring to a gentle simmer and cook over low heat for 2 hours.
Remove from heat and let cook for 15 minutes. Discard the cinnamon stick. Purée the mixture in a blender and strain through a sieve, pushing any solids through. Let cool, then cover and refrigerate for up to 1 month.