How To: Customize Cloud Discovery MID server selection


Generally speaking Cloud Discovery is "unspecified" in that there's no way to enforce specific MID selection in Cloud Discovery schedules like there is for normal Configuration Item Discovery. 

This can create an issue where you have specific security constraints where you can't have any sort of data pollination between clients by using a shared Cloud Discovery MID server even if it's on a client neutral network or has proper domain separation in place for segregating the data.

Release or Environment

Written with Orlando in mind. Slight modifications required for older versions, general concepts are the same.


The bulk of customizations will be in the selectMid function in script include "CloudMidSelectionApi"

- Generally speaking most cloud API calls pass through a "context" object variable to the selectMid function. This usually has details on the service account that you could use for customizing the MID selection (usually it's context.account_id, but you may want to test on your specific version to confirm)
- Some API calls don't pass in a context variable, though. Most notably Discover Datacenters. (This also changes based on version, for OP3 look at CloudDiscoveryScheduleConfig.discoverDatacentersViaCapi()).
- So we can see there we call capiSvrScript.resolveMid('',cloudType,'')
- In the backend this call can actually support 4 arguments though, where the 4th is the context variable
- So you could customize CloudDiscoveryScheduleConfig to pass through a custom context object. Such as:

discoverDatacentersViaCapi: function(serviceAccountSysID) {

var context = {'account_id':serviceAccountSysId};

- And then pass that through by modifying the resolveMid() call:
- So that then Discover Datacenters would abide by your MID algorithm selection changes

For the "CloudMidSelectionApi" changes you would make any desired logical customizations here. If you wanted to assign MID server specifically by Service Account you might add additional if/if else blocks such as:

if (context.account == '[desired service account sysid]') {

return '[desired mid server sysid]';


Ultimately though you can implement any desired logical changes just note that likely the bulk of your information you'll use to differentiate between options will be in the context object variable.