Fixing misconfigured Auto-Balanced Collector assignments
I’ve seen this issue pop up a lot in support so I figured this post may help some folks out. I just came across a ticket the other day so it’s fresh on my mind!
In order for Auto-Balanced Collector Groups (ABCG) to work properly, i.e. balance and failover, you have to make sure that the Collector Group is set to the ABCG and (and this is the important part) the Preferred Collector is set to “Auto Balance”. If it is set to an actual Collector ID, then it won’t get the benefits of the ABCG.

You want this, not that:

Ok, so that’s cool but now the real question is how do you fix this?
There’s not really a good way to surface in the portal all devices where this is misconfigured. It’s not a system property so a report or AppliesTo query won’t help here…
Fortunately, not all hope is lost! You can use the ✨API✨
When you GET a Resource/device, you will get back some JSON and what you want is for the autoBalancedCollectorGroupId field to equal the preferredCollectorGroupId field. If “Preferred Collector” is not “Auto Balance” and set to a ID, then autoBalancedCollectorGroupId will be 0.
Breaking it down step by step:
- First, get a list of all ABCG IDs
- https://www.logicmonitor.com/swagger-ui-master/api-v3/dist/#/Collector%20Groups/getCollectorGroupList
/setting/collector/groups?filter=autoBalance:true
- Then, with any given ABCG ID, you can filter a device list for all devices where there’s this mismatch
- https://www.logicmonitor.com/swagger-ui-master/api-v3/dist/#/Devices/getDeviceList
/device/devices?filter=autoBalancedCollectorGroupId:0,preferredCollectorGroupId:11(where 11 is the ID of a ABCG)
- And now for each device returned, make a PATCH so that
autoBalancedCollectorGroupIdis now set topreferredCollectorGroupId
Here’s a link to the full script, written in Python for you to check out. I’ll also add it below in a comment since this is already getting long.
Do you have a better, easier, or more efficient way of doing this? I’d love to hear about it!
LM User
This uses my lmwrapper to make authentication and setup of the api object easy. It also uses pagination and skips collectors (in my environment due to naming standard):
Michael Raymond
OPThe call to the collector group and the call to fetch devices also needs pagination.
Yep yep. Definitely more of an example script than anything production ready. Pagination, check for Collector Resource, a flag to take in a subset of Collector IDs you want to fix (and not just all). Probably some other stuff too that I can’t think of!
Michael Raymond
OPThere should probably be something in there that avoids messing with the assignment of the collector to itself.
I agree, just prevent this altogether. Have the preferred Collector be just greyed out, or the dropdown not list anything… but then that might lead to issues because (and this is something I neglected to mention above) you actually do want the Collector hard set for the Collector host Resources. I should prob update my script to skip over Collector Resources… but I think my main point still comes across -- really just wanting to highlight how to spot these types of things.
There may also be some cases (mostly troubleshooting I think) where you might want to force a reassignment. So maybe the ‘reset’ button is the way to go 🤷
LM User
The call to the collector group and the call to fetch devices also needs pagination.
LM User
There should probably be something in there that avoids messing with the assignment of the collector to itself.
Michael Raymond
OPEverybody please submit a feed for there to be a method on the ABCGroup to “reset” devices assigned to the collectors in the group to the ABCGroup.
Yes! The more feedback, the better! 🚀
LM User
Everybody please submit a feed for there to be a method on the ABCGroup to “reset” devices assigned to the collectors in the group to the ABCGroup. We should not have to to build this functionality ourselves through Python/API. The method should open up a modal showing the list of all devices in a box on the left hand side. You move devices from the left side to the right side to include them in resetting their assignment. Typical filters should exist allowing easy selection of all, by collector, by hostname, etc.
Michael Raymond
OPUsing the LM SDK makes the code much cleaner:
Link to code on github
Michael Raymond
OPFull Python script: