Add device to a Collector Group

  • 17 November 2022
  • 3 replies
  • 8 views

Hi Guys

Is it possible to add a device to a Collector Group directly?

I've been testing code to find a set of collectors that match a name and add to one of the specific collectors retrieved. Currently it grabs all with LON in the name and matches the device name.  I'm then randomly picking one of them and adding the device). However, my understanding is its then tied to this collector and not the grrup?

PLease correct me if I'm wrong here.

So, can I add directly to a group with JSON as below 

 $newdeviceobj= @{ 
                    'name' = "$device" - name of the device
                    'displayName' = "$device" - name of the device
                    'preferredCollectorId' = "0"
                    "autoBalancedCollectorGroupId" = $id - (this is the ID of the collector group)
                    'description' = "$device" - name of the device
                    }

I'm using a POST to device/devices and i receive

 @{data=; errmsg=Collector(id=0) does not exist; status=1404}

I've got 'preferredCollectorId' = "0" as clearly i dont want to define it at this point.

 

Thanks

 


3 replies

Userlevel 7
Badge +17

Devices cannot be added to Collector groups, only collectors can. Devices (including the device the collector is hosted on) can be added to resource/device groups.

When I add a device through the API, i find the collector group and just assign the preferredCollectorId to the first collector in that group. I don't define any collectors on resource groups.

This might be of interest: https://github.com/sweenig/lm/tree/main/LMAutomation/Devices_by_Collector_Auto_Groups

Thanks.

So maybe I misunderstood but if I just add a device with a preferred collector Id and the collector is a member of an auto balanced collector group does that mean LM will just handle the load and I don’t need to be concerned?

https://www.logicmonitor.com/support/collectors/collector-groups/auto-balanced-collector-group

Userlevel 7
Badge +17

Pretty much. By setting the preferred collector id, you're telling LM which collector the device is assigned to. The collector being a member of an ABCG will mean that overload will be rebalanced.

Also, don't confuse ABCGs with load balancing. It's not load balancing. It's overload rebalancing. In an ABCG, one collector could be 99% loaded and the other could be 3% loaded and this is normal/expected behavior. It's only when the load goes above 100% that rebalancing happens, and only enough to get it down below 100%. Definition of load is a specific number of instances. Not actually based on real performance stats.

Reply