Mongo Primary State Check


Is there a way to check if a primary got changed for a certain amount of time?
Let’s say you have a replica set with A, B and C with A being the primary. Is there a way to alert if A got demoted to a secondary for more than a minute? This is using a grafana managed alert in pmm. Ideally this would be a generic alert so you don’t have to make a specific alert for every replica set.