A non-Euclidian space here presumably means a Riemannian manifold $(M,g)$. Let us also assume there is given some gravitational energy distribution/profile $V:M\to\mathbb{R}$. So the brachistochrone problem is to minimize the time $$\Delta t~=~\int_A^B \frac{ds}{v}~=~\int_A^B \frac{\sqrt{g_{ij}(x)dx^idx^j}}{\sqrt{\frac{E-V(x)}{2m}}}$$$$\Delta t~=~\int_A^B \frac{ds}{v}~=~\int_A^B \frac{\sqrt{g_{ij}(x)dx^idx^j}}{\sqrt{\frac{2}{m}(E-V(x))}}\tag{1}$$ for a curve of a fixed constant mechanical energy $E$ between 2 points A and B.
For examples, see e.g. this Phys.SE post. There are generalizations to pseudo-Riemannian manifolds, cf. e.g. this Phys.SE post.