The high demand for better services in cellular networks is the motivation behind the evolution of said network. Currently, the Open Radio Access Network (O-RAN) paradigm was proposed to provide more intelligent management of the user radio access, improving the quality of services, by applying Artificial Intelligence (IA); and Machine Learning (ML) algorithms. Despite their high potential, ML is highly dependent on the integrity of applied data, especially in the training stage. To avoid any data alteration, in this work an algorithm for anomaly detection in network metrics is proposed. This approach is based on a state machine to determine the network behaviour and Otsu thresholding. The algorithm performance is evaluated on data obtained from a 5G microcell.