Electron beams produced by the hollow cathode effect are studied in a compact gas filled 24-kV, 5-kA capillary discharge. The characteristics and role of electron beams on X-ray production are studied in order to better understand their impact on X-ray production. X-ray plasma emission is analyzed with a spectrometer, while wideband diodes and Faraday cup probe both electron beams and X-rays. Electron beams of >5 keV are observed early on the discharge and two types of electron beams are identified: a first beam of high energy and low current (with a speed of $\sim 5 \times 10^{7}$ m/s and a current density of $\sim 4\times 10^{\mathrm {-2}}$ A/cm $^{2})$ enhanced by larger cathode apertures, and a second beam of low energy and high current enhanced by smaller cathode apertures. The use of a simple configuration of external magnets prevents X-ray fluorescence production, caused by electron beams, from reaching electronic detectors hence confusion when evaluating X-ray yield from the plasma source is avoided. This is particularly important in extreme ultraviolet lithography and soft X-ray production applications. Furthermore, the presence of the external magnets does not modify line emission, which is detected by means of spectrometry. Therefore, the use of external magnets provides a way to discriminate X-ray diode signals produced by source emitted X-rays and X-ray fluorescence from electron beams.