Absorption lines are often the answer.
The amount of absorption depends on the column density of the particular atom in its particular state of excitement that is doing the absorption. Column density is simply the number of such atoms per unit area along the line of sight to the background source that is being absorbed. If you look at the absorption with high spectral resolution, you can measure its width, which as mentioned above may tell you about the gas velocities, density etc. In practice, the doppler width usually dominates, so you only learn about the motion of the gas from the line width. If you can see more than one absorption-line, you can start trying to work out more about the gas cloud.