Lameness is a big problem in the dairy industry, farmers are not yet able to adequately solve it because of the high initial setup costs and complex equipment in currently available solutions, and as a result, we propose an end-to-end IoT application that leverages advanced machine learning and data analytics techniques to identify lame dairy cattle. As part of a real world trial in Waterford, Ireland, 150 dairy cows were each fitted with a long range pedometer. The mobility data from the sensors attached to the front leg of each cow is aggregated at the fog node to form time series of behavioral activities (e.g., step count, lying time and swaps per hour). These are analyzed in the cloud and lameness anomalies are sent to farmer's mobile device using push notifications. The application and model automatically measure and can gather data continuously such that cows can be monitored daily. This means there is no need for herding the cows, furthermore the clustering technique employed proposes a new approach of having a different model for subsets of animals with similar activity levels as opposed to a one size fits all approach. It also ensures that the custom models dynamically adjust as weather and farm condition change as the application scales. The initial results indicate that we can predict lameness 3 days before it can be visually captured by the farmer with an overall accuracy of 87%. This means that the animal can either be isolated or treated immediately to avoid any further effects of lameness.