Heat olive oil in a pan on medium heat and add about 2 tablespoons of red onion slivers. Allow onions to soften and caramelize for about 15 to 20 minutes, stirring occasionally.
Grate about ½ cup of gruyere cheese, enough to generously cover one slice of bread. Add the shredded gruyere to the small mixing bowl. Add fresh thyme and a dash of salt and pepper to the mixing bowl.
When the onions have caramelized, add them to the small mixing bowl and use a spoon to combine the gruyere and onions. Add the mixture to one slice of sourdough, spreading evenly. Top with the second slice of bread.
Add a couple pats of butter to the hot skillet. Once the butter has melted, lay the gruyere sandwich in the pan and turn the heat to medium low. Grill the sandwich until the bottom is golden brown, about 3 to 4 minutes. Use a spatula to gently flip the grilled cheese and cook the other side until golden, another 3 to 4 minutes.
Transfer the gruyere grilled cheese to a plate and cut on a diagonal. Serve hot.