In many applications, it is often necessary to sample the mean value of certain quantity with respect to a probability measure μ on the level set of a smooth function ξ : ℝd → ℝk, 1 ≤ k < d. A specially interesting case is the so-called conditional probability measure, which is useful in the study of free energy calculation and model reduction of diffusion processes. By Birkhoff’s ergodic theorem, one approach to estimate the mean value is to compute the time average along an infinitely long trajectory of an ergodic diffusion process on the level set whose invariant measure is μ. Motivated by the previous work of Ciccotti et al. (Commun. Pur. Appl. Math. 61 (2008) 371–408), as well as the work of Leliévre et al. (Math. Comput. 81 (2012) 2071–2125), in this paper we construct a family of ergodic diffusion processes on the level set of ξ whose invariant measures coincide with the given one. For the conditional measure, we propose a consistent numerical scheme which samples the conditional measure asymptotically. The numerical scheme doesn’t require computing the second derivatives of ξ and the error estimates of its long time sampling efficiency are obtained.