Using consul as cluster member counter

I’m new to consul. I’m using terraform to manage our mongo environment which launches 2 replica sets, 3 nodes each, plus 3 node config set, and a single mongos. All 10 servers have consul on them with basic mongo health check.

Right now, I have bash scripts that do lots of sleep-waits, checking the status of the replica sets. It was my understanding that I could use consul instead to keep a running counter of the number of members per replica set. I think this should be implemented as a service check; some command that executes every 10s. If good check, increment number of servers by 1, or add this host to an existing group which I can count the number of. If bad check, remove server from group/tag.

I’m thinking to create 3 different “services” in consul: “mongo-alive”, “mongo-primary”, “mongo-rs-members” Each check does something different to add/remove the host from the check. Is this OK to have repeated services on each node? Is this the right way?