Beam Diagnostics and Spectroscopy at X-ray Free Electron Lasers