Correlation functions play an important role for the theoretical and experimental characterization of many-body systems. In solid-state systems, they are usually determined through scattering experiments, whereas in cold gases systems, time-of-flight, and in situ absorption imaging are the standard observation techniques. However, none of these methods allow the in situ detection of spatially resolved correlation functions at the single-particle level. Here, we give a more detailed account of recent advances in the detection of correlation functions using in situ fluorescence imaging of ultracold bosonic atoms in an optical lattice. This method yields single-site- and single-atom-resolved images of the lattice gas in a single experimental run, thus gaining direct access to fluctuations in the many-body system. As a consequence, the detection of correlation functions between an arbitrary set of lattice sites is possible. This enables not only the detection of two-site correlation functions but also the evaluation of non-local correlations, which originate from an extended region of the system and are used for the characterization of quantum phases that do not possess (quasi-)long-range order in the traditional sense.