In this paper, we are concerned with the distributed monitoring of P2P systems. We introduce the P2P Monitor system and a new declarative language, namely P2PML, for specifying monitoring tasks. A P2PML subscription is compiled into a distributed algebraic plan which is described using algebra over XML streams. The operators of this algebra are first alerters in charge of detecting specific events and acting as stream sources. Other operators process the streams or publish them. We introduce a filter for streams of XML documents that scales by processing first simple conditions and then, if still needed, evaluating complex queries. We also show how particular tasks can be supported by identifying subtasks that are already provided by existing streams. Categories and Subject Descriptors H.2 [Database management]: Distributed databases, Query processing General Terms Algorithms, Design, Languages, Performance Keywords distributed data management, stream processing, peer to peer systems,...