The energy of a photon of characteristic X-ray from a Coolidge tube comes from
The electron striking the metal can knock off electrons from the shells of the target atoms. These electrons are then filled by the subsequent energy levels. During the transition of electrons from higher energy level to the newly created vacant space, the difference of the energy between the two energy levels is given off as photons forming characteristic x-rays.