The emerging fifth-generation (5G) mobile networks are empowered by softwarization and programmability, leading to the huge potentials of unprecedented flexibility and capability in cognitive network management such as self-reconfiguration and self-optimization. To help unlock such potentials, this paper proposes a novel framework that is able to monitor and calculate 5G network topological information in terms of advanced spatial metrics. These metrics, together with enabling and optimization algorithms, are purposely designed to address the complexity of 5G network topologies introduced by network virtualization and infrastructure sharing among operators (multi-tenancy). Consequently, this new framework, centred on a topology monitoring agent (TMA), enables on-demand 5G networks' spatial knowledge and topological awareness required by 5G cognitive network management in making smart decisions in various autonomous network management tasks including but not limited to virtual network function placement strategies. The paper describes several technical use cases enabled by the proposed framework, including proactive cache allocation, computation offloading, node overloading alerting, and load balancing. Finally, a realistic 5G testbed is deployed with the central component TMA, together with the new spatial metrics and associated algorithms, implemented. Experimental results empirically validate the proposed approach and demonstrate the scalability and performance of the TMA component. Keywords 5G networks • Topology management • Spatial network metrics • Cognitive management 1 Introduction Network management in the forthcoming fifth-generation (5G) mobile networks is notably influenced by the softwarization of network infrastructures where several hardware components are virtualized and by the multi-tenancy of the network infrastructures where hardware components are shared by different mobile operators. The main motivation of these 5G capabilities is the reduction of both capital and operational costs. 5G virtual network functions (VNFs) can now be deployed automatically and on-demand on the Edge and the Core segments of the 5G network and can be migrated between the computers that belong to the same net-Communicated by V. Loia.