How to get all related CIs for a Business Service via REST API? Or is there a better way?

IanHorse
Kilo Explorer

Hello,

First, the problem that I'm trying to solve:

1. I'd like to export a list of all Business Services with their information.

2. I'd like a list of all servers that [connect to, depend on, or exchange data with] this service

3. I'd like a list of all Interfaces(with IPs present on these servers)

The final goal here is to have a list of all IPs present with their service membership via the REST API.

 

I'm currently trying from the top down, i.e. grabbing the services, and then querying membership of those services. If it makes more sense to grab all server_cis and then query each of those for service membership, I'm all ears.

 

I've definitely seen this using BSM, but that is in the GUI. I've also seen this list when looking at a business service in the GUI, but don't know how to grab it via REST API. 

Currently, I have python able to pull the cmdb_ci_service table successfully with the right sysparm fields, so that if good. Not sure where to go from here... Please help!

1 REPLY 1

simonbergstedt
Tera Guru

If you have the Business services then you need to look at the cmdb_rel_ci table and query it like below with the info from your previous business service query. It querys based on the sys_id of the BS as the parent and list all relationships where the childs class contains Server so you get linux, windows, etc. You could ofc specify them as well. 

https://instancename.service-now.com/api/now/table/cmdb_rel_ci?sysparm_query=parent%3D451047c6c0a8016400de0ae6df9b9d76%5Echild.sys_class_nameLIKEserver&sysparm_fields=parent.sys_id%2Cparent.name%2Cparent.sys_class_name%2Cchild.sys_id%2Cchild.name%2Cchild.sys_class_name%2Ctype.sys_id%2Ctype.name

Or you could just do one query where you instead of specifying a BS you just add class = business service to the query. This gives you all BS to Server-relationshpis

https://instancename.service-now.com/api/now/table/cmdb_rel_ci?sysparm_query=child.sys_class_nameLIKEserver%5Eparent.sys_class_name%3Dcmdb_ci_service&sysparm_fields=parent.sys_id%2Cparent.name%2Cparent.sys_class_name%2Cchild.sys_id%2Cchild.name%2Cchild.sys_class_name%2Ctype.sys_id%2Ctype.name

Now you need to a query on the cmdb_ci_network_adapter-table, if you use that to store the IPs that is.

https://instancename.service-now.com/api/now/table/cmdb_ci_network_adapter?sysparm_query=cmdb_ci%3De28b05a09f030200fe2ab0aec32e70bc&sysparm_fields=cmdb_ci.sys_id%2Ccmdb_ci.name%2Cip_address%2Cname