I realize that it would be very difficult to accurately estimate this but I’m curious around how much of economy went to the military budget.
So this would depend on the exact medieval period you're talking about (as in those from the 500s-800s would vastly differ to those in later periods such as around the crusades or during the 1300s/1400s. As a baseline the Roman Empire, as noted by James Lacey, spent approximately 450 million sesterces on their military expenditure, or about 1-2% of their total national product. I'll focus on the earlier middle ages here, and how vassalage and fiefdom paid for military expenditure, as well as a bit of how GDP and military expenditure don't exactly fit the Medieval period.
However, once we go past the fall of the Western Roman Empire, there isn't a clear marker in either GDP or military expenditure. And that's because these earlier kingdoms, such as the Merovingians, were not taxing and expending income in the same way that the Romans were. Chris Wickham in Framing the early Middle Ages notes that the Frankish kings specifically only taxed their Roman populace during the 6th century, and that by the 7th-century taxation was halted due to how unpopular it was. This left the Merovingian Kings with little ability to expend coin for military service, and as such the concept of benefice or fiefs, in which warriors or soldiers were given royal lands (later ecclesiastical lands were also provided as noted by the Concilium Germanicum for monetary concession) as payment for their services, was created. This concept of fiefdom continued throughout the medieval period, with the Carolingian kings cementing this practice through the Concilium Germanicum, and at the same time, they turned away from presenting individual knights with land, and rather provided loyal vassals large estates, from which "these vassals would use the revenues from their estates to equip and train a force of soldiers that had to answer the mayors’ call to arms".
At the most extreme end of the early medieval period, Alfred the Great does begin to represent the more modernized idea of military spending. Due to the invasion of the Vikings, Alfred the Great had both established a sort of standing army, as well as a fortified system of towns, called burhs. These measures were paid for through the Heregeld, an annual land tax. However, the exact amounts collected by Alfred's taxes are unknown, though the tax was explicitly designed to pay for defense against Viking invasion.
The main issue is that many of these earlier kingdoms did not have either the sufficient coin or infrastructure to facilitate a proper taxation system as existed in either Rome or the Modern era. Even later medieval kingdoms did not have exact GDPs or taxation systems, as the debasing of silver and encouragement of lending from banks and banking families complicate the matter. Most Medieval Kingdoms, at least up until the end of the crusading period, did not expend GDP as modern countries do, and rather military expenditure was based on either the feudal obligations of vassals who had been provided land, or the income which was with generated through specific taxation or lending for the purpose of warfare. So while the answer to your question isn't easily defined, it can be noted that Medieval kingdoms were often drained by warfare, with Lacey noting that the Crusades forced "almost every noble..to sell his estate or pawn whatever property he owned" and that so much money left Western Medieval Europe that many mints were forced to close. So, to conclude, while there are no exact numbers or percentages, Medieval societies often had to focus their spending on the military if they were going to war, as they lacked the complex infrastructure needed to tax their populace for multi-faceted needs.
Sources:
Lacey, James. Gold, Blood, and Power: Finance and War through the Ages. Strategic Studies Institute, US Army War College, 2015.
Wareham, Andrew. "Fiscal Policies and the Institution of a Tax State in Anglo-Saxon England within a Comparative Context." The Economic History Review 65, no. 3 (2012): 910-31.
Wickham, Chris. Framing the early Middle Ages: Europe and the Mediterranean, 400-800. Oxford: Oxford University Press, 2006
Spufford, Peter. Money and its use in Medieval Europe. Cambridge: Cambridge University Press, 1988