Studying terahertz resonators: the near-field approach