Metadynamics allow to efficiently sample probability landscapes with multiple maxima, in conditions where transitions between them are rare. It was formulated for sampling processes in detailed balance, with an underlying Gibbs measure. Here, we generalize this procedure to transition pathways in arbitrary dynamics, including irreversible and time-dependent ones. One key realization is that every stochastic diffusion induces a gradient flow in path space, namely for the gradient of its corresponding Onsager-Machlup functional. Using this, we can apply metadynamics in path space for transition path sampling in stochastic systems, including stochastic differential equations and stochastic partial differential equations.