We introduce a cluster extension of multipole moments to discuss the anomalous Hall effect (AHE) in both ferromagnetic (FM) and antiferromagnetic (AFM) states in a unified framework. We first derive general symmetry requirements for the AHE in the presence or absence of the spin-orbit coupling by considering the symmetry of the Berry curvature in k space. The cluster multipole (CMP) moments are then defined to quantify the macroscopic magnetization in noncollinear AFM states as a natural generalization of the magnetization in FM states. We identify the macroscopic CMP order which induces the AHE. The theoretical framework is applied to the noncollinear AFM states of Mn3Ir, for which an AHE was predicted in a first-principles calculation, and Mn3Z(Z=Sn,Ge), for which a large AHE was recently discovered experimentally. We further compare the AHE in Mn3Z and bcc Fe in terms of the CMP. We show that the AHE in Mn3Z is characterized by the magnetization of a cluster octupole moment in the same manner as that in bcc Fe characterized by the magnetization of the dipole moment.