Mastitis is an infectious-contagious disease that causes an inflammation of the udder that affects a high proportion of dairy cows throughout the world. The difficulty of its diagnosis (which requires culture media especially for its isolation) and inefficiency of antibiotics in your treatment, what become a fearsome enemy if detected its presence in a dairy farm, since only very rigorous hygiene and disposal measures of the positive cows, are the measures known for controlling it. While it is true that subclinical mastitis does not usually increase in greatly the amount of colony forming unit (CFU)/ml (x1000) of tank milk, can contribute some bacteria potentially harmful to human health, also alters the composition of milk. This research introduces the development of an analytical methodology for on-site monitoring the CFU/ml in raw milk at farm level by using a portable NIR sensor MicroPhazirTM NIR spectrometer, using a total of 1266 liquid milk samples, scanned at room temperature without pre-treatment. Samples were divided into two sub-sets. The training set composed of 1197 samples, and a set of 69 samples to external validation. Classification models were used for the prediction of CFU/ml in milk at legal level: < 400 and ≥ 400 CFU/ml(x1000), achieving less than 3% of penalties.