We have some SAM templates which we want to be automatically assigned to the nodes via automation or through API. Is there any way to achieve this goal?
In tool this is via groups usually
in api you can do stuff in this space, it can be a bit hard, i've got examples of prior work and a todo item
Assigning via groups will also be a manual intervention?
Nah you can do that full-auto-no-code
optional 0) add some discovery with auto-additions of nodes
1) create group
2) populate group with dynamic queries so it auto-updates
3) assign template/s to that group
You could add a couple extra steps if you wanted to
This script in my repo creates groups based on a couple custom properties, there are also examples in the repo for how to set custom properties automatically. I had one before to assign apps but i don't have it handy, that part is fairly simple if you get familiarized with the way the api works.
https://github.com/Mesverrum/MyPublicWork/blob/master/AppAndAppRoleGroupBuilder.ps1
We do something similar to this. We have a custom property on the node looking for a Tag property. If the Tag contains Microsoft SQL, the device gets added to the group. The group then has a couple SAM monitors attached to it, so within 10 minutes or so, the node gets a couple different SQL monitoring templates applied to it.
The only downside with this approach, is if you are using custom properties for alerting on the SAM side of things, then those would still need to be set.