Melt 1 tablespoon of butter in a large skillet over medium heat. Add the sliced onions and cook, stirring often, until they turn deep golden brown, about 20 minutes. Remove half the onions and set them aside for the gravy.
In a mixing bowl, combine the ground beef, breadcrumbs, egg, thyme, salt, pepper, and the remaining caramelized onions. Mix until just blended, then shape into 12 meatballs.
Return the skillet to medium heat and add the meatballs. Cook, turning occasionally, until browned on all sides and cooked through, about 10 minutes. Transfer the meatballs to a plate.
While the meatballs cook, place the potatoes in a large pot and cover with water. Bring to a boil and cook until tender, about 15 minutes. Drain, then mash with the remaining 2 tablespoons butter and the milk until smooth. Season with salt and pepper.
In the same skillet used for the meatballs, sprinkle the flour over the leftover onions and stir for 1 minute. Slowly whisk in the beef broth and cook until the gravy thickens, about 5 minutes. Season with salt and pepper.
Spoon the mashed potatoes onto plates, top with the meatballs, and pour the onion gravy over everything. Finish with a sprinkle of shredded Gruyere cheese.