First, cut the top and bottoms off of your onions and then chop them in half. Lay the onion pieces flat-side down and make 1/4-1/2in (.6-1.2cm) slices all the way across. Don’t worry if they aren’t exactly even. It will all cook down by the end. Repeat this process with the shallot, but make finer slices (1/16-1/8in or .16-.3 cm)
Now that your alliums are sliced. Place your preferred cooking vessel on the stove top and turn the heat to medium-high. After the pan heats up a bit, add in 1 tablespoon (14g) of butter and the beef fat. Let that melt and begin to foam. Dump the sliced onions into your pan and toss them around in the fat. After a minute or so, sprinkle the salt over the onions and continue moving everything around in the pan, until the onions release their liquid and start turning translucent, this should only take between 5-7 minutes.
At this point, turn the heat down to medium, medium low heat. You do not want to unevenly cook the onions. This is all about browning (caramelizing) without burning or charring. Cook your onions, low and slow stirring every 5-10 minutes for the next 45 minutes. They will continue to lose liquid as they cook.
About 30 minutes into cooking the onions, take your cheese out of the refrigerator to sit at room temperature.
Also around this time, enough liquid will have evaporated that you can add in the beef stock and deglaze the pan a little bit. After adding the stock, stir in the marmite, roasted garlic, black pepper, and mushroom powder. Continue cooking the onions until the liquid has, again, mostly evaporated and they have turned a warm brown color.
Back to the onions. When done, the liquid surrounding the strands of onion will be creamy, like a thick gravy and the onions will be a deep brown. 2-3 minutes before taking the pan off the heat, mix in the thyme and the sherry vinegar. Set the pan aside and turn off the stove.
Next, prepare the rest of the ingredients for sandwich making. Grate the cheeses and mix them together into a pile. Butter your brioche slices, with the remaining butter, and setup your workstation. Place one slice of the brioche, butter side down, onto a medium-hot, non-stick pan. Take 1/4 of the cheese pile and spread it over the first piece of bread. Half of the onions get spread over the cheese, and then a second layer (another 1/4 of the pile) of cheese tops the onions. Add the second slice of brioche butter-side up and let it cook until you start to see some browning on the bottom slice of bread.
Flip the sandwich over and let the other side begin to crisp. Don’t worry about trying to perfectly brown each side in one flip, the first two turns are about making sure the cheese melts enough to fuse the whole grilled cheese sandwich together. Once you see the cheese melting, turn the heat up and then toast the outside of your sandwich to your preferred level of brown.
When you have reached a desired amount of toasting and melting, on your grilled cheese sandwich, plate it and make your second sandwich with the rest of the cheese and caramelized onions.
Slice and enjoy.