  Deviations from isotropy have been a key tool to identify the origin and the
primary type of cosmic rays at low energies. We suggest that the
Compton-Getting effect can play a similar role at ultra-high energies: If at
these energies the cosmic ray flux is dominated by sources at cosmological
distances, then the movement of the Sun relative to the cosmic microwave
background frame induces a dipole anisotropy at the 0.6% level. The energy
dependence and the orientation of this anisotropy provide important information
about the transition between galactic and extragalactic cosmic rays, the charge
of the cosmic ray primaries, the galactic magnetic field and, at the highest
energies, the energy-loss horizon of cosmic rays. A 3-sigma detection of this
effect requires around 10^6 events in the considered energy range and is thus
challenging but not impossible with present detectors. As a corollary we note
that the Compton-Getting effect allows one also to constrain the fraction of
the diffuse gamma-ray background emitted by sources at cosmological distance,
with promising detection possibilities for the GLAST satellite.
