Electron spin resonance (ESR) describes a suite of techniques for characterizing electronic systems with applications in physics, chemistry, and biology. However, the requirement for large electron spin ensembles in conventional ESR techniques limits their spatial resolution. Here we present a method for measuring ESR spectra of nanoscale electronic environments by measuring the longitudinal relaxation time of a single-spin probe as it is systematically tuned into resonance with the target electronic system. As a proof of concept, we extracted the spectral distribution for the P1 electronic spin bath in diamond by using an ensemble of nitrogen-vacancy centres, and demonstrated excellent agreement with theoretical expectations. As the response of each nitrogen-vacancy spin in this experiment is dominated by a single P1 spin at a mean distance of 2.7 nm, the application of this technique to the single nitrogen-vacancy case will enable nanoscale ESR spectroscopy of atomic and molecular spin systems.