Metasurfaces are planar optical elements that provide much greater freedom in manipulating light than conventional optics. This article explores the potential for miniaturised metasurface-based optical sensors. We consider the realisation of a chromatic confocal sensor for position measurement, where a conventional hyperchromatic lens is replaced by a metasurface. The design and fabrication process for a metasurface based on truncated-waveguide type meta-atoms is described. Experimental evaluation of the sensor performance confirms the potential for metasurface-based optical sensors to form the basis of a new generation of miniature, lightweight, low-cost optical sensors to support the data-driven manufacturing technologies of the future.