Dear Jakob,
This is a pretty sophisticated question!
Scientists try to calculate the energy released in a flare by look at all the light that comes from the flare..x-rays, ultraviolet light as well as visible light. Then they try estimate all the energy is all the energetic particles (electrons and ions) that are also released into space by the flare.
We know that the energy for a flare comes from changes in the magnetic field of the Sun. Some scientist also try to estimate the energy released by calculating how much energy was released by the changes in the magnetic field.
Of course, if the flare has a coronal mass ejection associated with it, then you need to try to calculate all the energy of this big moving mass!
Paulett