Dark matter might be made of warm particles, such as sterile neutrinos in the keV mass range, which can decay into photons through mixing and are consequently detectable by X-ray telescopes. Axionlike particles (ALPs) are detectable by X-ray telescopes too when coupled to standard model particles and decay into photons in the keV range. Both particles could explain the unidentified 3.5 keV line and, interestingly, XENON1T observed an excess of electron recoil events most prominent at 2-3 keV. One explanation could be an ALPs origin, which is not yet excluded by X-ray constraints in an anomaly-free symmetry model in which the photon production is suppressed. We study the diffuse emission coming from the Galactic halo, and calculate the sensitivity of all-sky X-ray survey performed by eROSITA to identify a sterile neutrino or ALP dark matter. We estimate bounds on the mixing angle of the sterile neutrinos and coupling strength of the ALPs. After four years of data-taking by eROSITA, we expect to set stringent constraints, and in particular, we expect to firmly probe mixing angle $sin^2(2theta)$ up to nearly two orders magnitude below the best-fit value for explaining the unidentified 3.5 keV line. Moreover, with eROSITA, we will be able to probe the ALP parameter space of couplings to photons and electrons, and potentially confirm an ALP origin of the XENON1T excess.