Export the Inventory
The inventory export API returns the resources in a workspace’s Inventory and the relationships between them: what runs on what, what contains what, and what calls what. Use it to fill a CMDB, such as ManageEngine ServiceDesk Plus or ServiceNow, or any tool that keeps its own list of your infrastructure.
Two endpoints, each in two formats:
| Endpoint | Returns |
|---|---|
GET /inventory/resources | Cloud resources, hosts, Kubernetes objects, services, and databases |
GET /inventory/relationships | The links between those resources |
- JSON returns a page at a time, with a cursor for the next page. Use it from a script or a scheduled job.
- CSV returns the whole export in one file. Use it to import into a spreadsheet or a CMDB’s import wizard.
Before you start
Section titled “Before you start”Use the base URL for your organization’s region:
| Region | Base URL |
|---|---|
| US | https://api.kloudmate.com |
| India | https://api.in.kloudmate.com |
Send a personal API key in the x-api-key header. A tool that can’t send a custom header, such as ServiceNow’s file import, can send the key as the password of HTTP basic authentication, with any user name. The key acts as you, so it can export any workspace you are a member of, with any role. Every request names the workspace in the workspace_id query parameter.
What the export holds
Section titled “What the export holds”The export lists the resources Inventory lists:
- A cloud resource until its account’s sync no longer finds it.
- A host, Kubernetes object, or service while KloudMate still sees its telemetry. One not seen for two hours drops out.
- Containers, network endpoints, and storage mounts are left out, because their names are ids. Name one of these kinds in
kindto export it anyway.
A relationship is exported only when the resources at both ends are, so every relationship names resources the resource export also returns.
Query parameters
Section titled “Query parameters”Both endpoints take the same parameters.
| Parameter | Description |
|---|---|
workspace_id | Required. The workspace to export. |
kind | Only these kinds, comma-separated, such as aws.ec2.instance,host. For relationships, both ends must be one of them. |
account_id | Only the resources of one connected cloud account, by its KloudMate account id. |
tags | Only resources carrying every one of these tags, as a JSON object: {"team":"payments","env":"prod"}. URL-encode it. |
format | json (the default) or csv. |
limit | JSON only. Rows per page, from 1 to 1000. The default is 500. |
cursor | JSON only. The next_cursor of the page before. |
tag_columns | Resources CSV only. Tag keys that each get their own column, comma-separated, such as team,env. |
Export resources
Section titled “Export resources”| Field | Description |
|---|---|
id | KloudMate’s id for the resource. It stays the same while the resource exists, so use it to match the resource on the next export. |
urn | A readable unique name: a cloud resource’s ARN, or the kind and identity of a host, Kubernetes object, or service, such as k8s.deployment:prod/payments/checkout. |
kind | The resource type, such as aws.ec2.instance, host, k8s.deployment, or service. |
account | The connected cloud account, or null for a resource from telemetry. |
cloud, cloud_account_id, region | Where a cloud resource lives. null for a resource from telemetry. |
tags | The resource’s tags. Kubernetes objects carry their cluster and namespace here. |
first_seen, last_seen | When KloudMate first and last saw the resource. |
Export relationships
Section titled “Export relationships”A relationship reads as a sentence from from to to: the host runs_on the instance, a VPC contains a subnet, a service calls another. class groups the types:
| Class | Types | Meaning |
|---|---|---|
placement | runs_on, instance_of, and similar | Where something runs or what it is an instance of |
ownership | contains, member_of, and similar | A parent or group |
dependency | calls, talks_to, reads_from, attached_to, associated, and similar | Something it uses or talks to |
Page through the results
Section titled “Page through the results”A JSON response holds next_cursor while there may be more. Send it back as cursor with the same other parameters, and stop when next_cursor is null. A page can hold fewer rows than limit, or none, and still have a next_cursor, so stop on the cursor, not on the row count.
A cursor that can’t be read gets a 400 response. Start again from the first page.
Download CSV
Section titled “Download CSV”Add format=csv to get the whole export as one file:
The resources file has the JSON fields as columns, with account as the account name, tags as JSON, and a tag:<key> column for each key in tag_columns. The relationships file has from_id, from_urn, from_kind, from_name, type, class, to_id, to_urn, to_kind, to_name, first_seen, and last_seen.
A value that starts with =, +, -, or @ is written with a leading ', so a spreadsheet shows it as text instead of running it as a formula.
Import into ManageEngine ServiceDesk Plus
Section titled “Import into ManageEngine ServiceDesk Plus”ServiceDesk Plus imports configuration items (CIs) and their relationships from CSV in two steps.
- Download
resources.csvwith the kinds you want as CIs, for examplekind=aws.ec2.instance,aws.rds.dbinstance,host. Downloadrelationships.csvwith the samekind, so every relationship names CIs from the first file. - In ServiceDesk Plus, open CMDB, import CIs from the resources file into the matching CI type, and map
nameand thetag:columns to CI fields. ServiceDesk Plus matches an imported CI to an existing one by name, so a later import updates it. Mapidto a custom field as well, to keep KloudMate’s id on each CI. - Import CI relationships from the relationships file, mapping
from_nameto the source CI,to_nameto the destination CI, andtypeto the relationship type.
To keep the CMDB current, call the JSON endpoints from a ServiceDesk Plus scheduled custom function, or from your own scheduled job, and add or update CIs through the ServiceDesk Plus CMDB API.