Geomagnetic precursor is one of many earthquake precursors, which have better effects on earthquake prediction, while the diurnal variation anomaly of geomagnetic precursor Z component is an important one in short-impending anomalies. Basing on the pattern distance of geomagnetic precursor Z component diurnal variation, this paper proposes an anomaly recognition algorithm which combines the feature of geomagnetic precursor data with time series similarity measure. We validate the effectiveness of the algorithm through the actual data.