Managing Hosts

The /hosts endpoint can be used to fetch and update hosts. You will need an API token, represented in each example as <API_TOKEN>.

Get the list of Hosts in an environment

To fetch a list of the hosts active within the past hour, we can use the following request:

curl 'https://app.vividcortex.com/api/v2/hosts?from=-3600&nest=tags&until=0' \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Accept: application/json, */*' \
  -H 'X-Indent: true'

To retrieve hosts active during a different timeframe, you can use from and until; they can be relative times in seconds (e.g. -3600 for the past hour) or Unix timestamps.

You can specify a host ID if you want the details of a specific host by adding id=<hostID>.

Include nest=tags if you want to include host tags in the response.

The response will look something like this:

{
"data": [
    {
      "id": 203,
      "uuid": "94253fcfa6c3359b77506fdd62314c60",
      "created": 1462296574,
      "updated": 1462296574,
      "deleted": 0,
      "lastSeen": 1462301121,
      "parent": 0,
      "name": "prod-slice-1.example.net",
      "bindings": [
      ],
      "type": "os",
      "description": "Server prod-slice-1.example.net version 2.6.32-573.3.1.el6.x86_64",
      "status": 0,
      "tags": [
      ],
      "os": "linux",
      "arch": " amd64",
      "discovered": 0
    } 
 ]
}

The response fields are mostly self-explanatory; the important ones for interacting with the API are id and type.

  • id is the identifier that Database Performance Monitor uses to filter requests to specific hosts; the other API endpoints do not understand names.
  • type is the kind of host (OS vs. MySQL), and depending on which one you look at you will see different metrics available (e.g. OS hosts have no query metrics associated with their id).

Change host name or description

You can change the name and/or description associated with a host with a request like the one below:

curl -X PUT 'https://app.vividcortex.com/api/v2/hosts/<hostID>' \
  -H 'Authorization: Bearer <API Token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "name":"A new name",
    "description":"A new description"
  }'

Set tags for a host

You can change the tags associated with a host with a request like the one below:

curl -X PUT 'https://app.vividcortex.com/api/v2/hosts/<hostID>' \
  -H 'Authorization: Bearer <API Token>' \
  -H 'Content-Type: application/json' \
  -d '{"tags":["tag1","tag2"]}'

The above request sets the tags for a given host to ["tag1", "tag2"]. If you wish to remove all tags for a given host, you can do so by passing [] for the tags field.

Delete a host

You can delete a given host with a request like the one below:

curl -X DELETE 'https://app.vividcortex.com/api/v2/hosts/<hostID>' \
  -H 'Authorization: Bearer <API Token>'

The above request deletes a given host, which will shutdown the running agents and free the license it is consuming immediately. If the specified hostID has one or more child hosts, they will also be deleted. You can also delete a host by following the uninstall instructions, which can also be used to free a license immediately.