Preheat the broiler. Toss the onion slices with the olive oil and broil them until charred, about 8 minutes on each side.
Put the onions and all the remaining ingredients in a deep heavy nonreactive pot. Simmer uncovered over low heat for about 3 hours, stirring every 15 minutes to break up the tomatoes and to keep the ketchup from sticking to the bottom of the pot. The mixture will thicken.
Puree the ketchup in batches in a food processor or blender. If the puree seems too thin, return it to the pot and simmer until it is as thick as you like it. This ketchup keeps well refrigerated for up to 4 weeks.
Heat a skillet over medium heat until hot. Add the cumin seeds and toss occasionally until lightly toasted, about 1 minute. Transfer to a plate to cool, and repeat with the coriander seeds and then the mustard seeds. Be careful that the spices don't burn. You'll know that they're done when a toasty, nutty aroma rises out of the pan. When the seeds are cool, coarsely grind them together in a spice grinder or in a mortar with pestle. Yield: 3/4 cup