NAV
shell python ruby php

API Basics: Getting Started

The Server Density API allows you to manage your entire account programmatically. It’s a simple HTTP JSON API and you can quickly get started to pull a list of your servers:

Authentication

import requests
r = requests.get(
    'https://api.serverdensity.io/inventory/devices',
    params = {
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    }
)
r.json()

curl -v -X GET https://api.serverdensity.io/inventory/devices?token=b97da80a41c4f61bff05975ee51eb1aa
require "httparty"

params = {:query => {"token" => "b97da80a41c4f61bff05975ee51eb1aa"}}
response = HTTParty.get("https://api.serverdensity.io/inventory/devices", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

?>

The above command returns JSON structured like this

[
    {
        "_id": "51eacff476d3775722000000",
        "accountId": "51eacfc876d377471b000000",
        "agentKey": "f9ce01e1e962b59798d6350eb8cfce4c",
        "cId": "c28",
        "cpuCores": "",
        "createdAt": "2013-07-20T17:59:16",
        "deleted": false,
        "group": null,
        "hostname": "mail.sootsprite.jp",
        "installedRAM": "",
        "isMonitored": true,
        "isNew": true,
        "lastPayloadAt": {
            "sec": 1377170228,
            "usec": 0
        },
        "location": {
            "countryCode": "gb",
            "countryName": "United Kingdom",
            "text": ""
        },
        "name": "example.com",
        "os": {
            "code": "linux",
            "name": "Linux"
        },
        "pluginsEnabled": [],
        "privateIPs": [],
        "provider": "",
        "publicIPs": [],
        "swapSpace": "",
        "type": "device",
        "updatedAt": "2013-08-22T11:17:08"
    }
]

All access to the API requires a token rather than a username or password. You can generate tokens via the API but the quickest way is to create one through the web UI:

  1. Log in to your Server Density account.
  2. Click your name in the top left, then click Preferences.
  3. Go to the Security tab then in the bottom right, enter a name for the API application you’re building so you can easily recognise it in the future e.g. “Llama Script”.
  4. Press Enter and your API token will be shown as a 32 character ID.


image

Getting a list of servers

You can call the API through curl or via any programming language which supports HTTP requests.

Next steps

Use the navigation on the left to learn how to access data from your Server Density account.

Help

If you need help you can contact us with any questions - the API is fully supported so let us know if you have any problems, questions or ideas for improvement.

Authentication

Getting a token via the UI

  1. Log in to your Server Density account.
  2. Click your name in the top left, then click Preferences.
  3. Go to the Security tab then in the bottom right, enter a name for the API application you’re building so you can easily recognise it in the future e.g. “Llama Script”.
  4. Press Enter and your API token will be shown as a 32 character ID.


image

Getting a token via the API

curl -v https://api.serverdensity.io/tokens/ \
     --data username=llama \
     --data password=securepassword \
     --data tokenName=Llama+script \
     --data accountName=example \
     --header "Content-Type:application/json"
import json
import requests

user_payload = {
    "username": "llama",
    "password": "securepassword",
    "accountName": "example",
    "tokenName": 'Llama script',
}

token_data = requests.post(
    'https://api.serverdensity.io/tokens/',
    headers={
        "content-type": "application/json"
    },
    data=json.dumps(user_payload)
)

If you need to generate tokens programmatically, you can request a token through the API with your username and password. All future requests can then be performed using the returned token.

If the user generating the token has Multi Factor Authentication enabled, you cannot use this method and must create the token via the web UI.

HTTP Request

POST https://api.serverdensity.io/tokens

Request Parameters

Parameter Required Description
username Yes The token will be associated with this username
password Yes The token will be associated with this password
accountName Yes The Server Density account that the user is a member of e.g. if you log in at example.serverdensity.io your accountName is example
tokenName Yes The name of the token, displayed. in the UI

Response Parameters

The json response for the above command

{
    "token_data": {
        "userId": "51f65a19dba4bbf15d000000",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "date_issued": {
            "sec": 1375106903,
            "usec": 49000
        },
        "tokenName": "Llama script",
        "token": "b97da80a41c4f61bff05975ee51eb1aa"
    }
}

The response will be a json encoded hash containing relevant data for the creation of the token.

Parameter Description
userId A string containing your user id.
accountId A string containing your account id.
date_issued contains sec and usec
date_issued > sec The moment the api was created NOTE: what time scale.
date_issued > usec The moment the token was created NOTE: not sure this is right
tokenName The name of your api token
token Your api token

Deleting a token via the API

API tokens can be deleted via the API or through the web UI.

curl -v -X DELETE https://api.serverdensity.io/tokens/901de5c241a6e879c1c6f0b27459d3f1?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token_to_delete = '901de5c241a6e879c1c6f0b27459d3f1'

delete_response = requests.delete(
    "https://serverdensity.io/tokens/{0}".format(token_to_delete),
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    }
)
require "httparty"

token_to_delete = "901de5c241a6e879c1c6f0b27459d3f1"
current_token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {
    :query => {"token" => token},
}

response = HTTParty.delete("https://serverdensity.io/tokens/#{current_token}", params)

response.to_json

The response you get when you delete an api token

{
    "token": "901de5c241a6e879c1c6f0b27459d3f1"
}

HTTP request

DELETE https://api.serverdensity.io/tokens/<token_to_delete>?token=<token>

Request Parameters

Parameters Description
token_to_delete The token you want to delete, as part of the URL
token Your API token

Response Parameters

The response is a JSON encoded hash containing the token that has been deleted.

Parameters Description
token Returns the token you deleted

Example note

Pagination

curl -v -X GET "https://api.serverdensity.io/inventory/tags?perPage=10&page=4&token=b97da80a41c4f61bff05975ee51eb1aa"
import requests

r = requests.get('https://api.serverdensity.io/inventory/tags',
    params = {
        'token': 'b97da80a41c4f61bff05975ee51eb1aa',
        'perPage': '10',
        'page': '4'
    }
)
require "httparty"

token = 'b97da80a41c4f61bff05975ee51eb1aa'
params = {
    :query => {
        "token" => token,
        "perPage" => "10",
        "page" => "4"
    }
}

r = HTTParty.get('https://api.serverdensity.io/inventory/tags', params)

The HTTP response will contain the pagination headers.

< x-last-page: http://api.serverdensity.io/inventory/tags?page=106&perPage=5
< x-total-number: 529
< x-first-page: http://api.serverdensity.io/inventory/tags?page=1&perPage=5
< x-previous-page: http://api.serverdensity.io/inventory/tags?page=3&perPage=5
< x-next-page: http://api.serverdensity.io/inventory/tags?page=5&perPage=5
>> r.headers
{
    'x-last-page': 'http://api.serverdensity.io/inventory/tags?page=106&perPage=5'
    'x-total-number': '529'
    'x-first-page': 'http://api.serverdensity.io/inventory/tags?page=1&perPage=5'
    'x-previous-page': 'http://api.serverdensity.io/inventory/tags?page=3&perPage=5'
    'x-next-page': 'http://api.serverdensity.io/inventory/tags?page=5&perPage=5'
}
>> r.headers.inspect
{
    'x-last-page' => 'http://api.serverdensity.io/inventory/tags?page=106&perPage=5'
    'x-total-number' => '529'
    'x-first-page' => 'http://api.serverdensity.io/inventory/tags?page=1&perPage=5'
    'x-previous-page' => 'http://api.serverdensity.io/inventory/tags?page=3&perPage=5'
    'x-next-page' => 'http://api.serverdensity.io/inventory/tags?page=5&perPage=5'
}

Our API will not return more than 400 JSON objects in a single request. Therefore we provide pagination to access more data conveniently. For data where pagination is required additional headers will be included in the response.

Request Parameters

Parameters Description
perPage Maximum number of objects to include in response
page Request a specific page number

Response Headers

Header Description
x-total-number Total number of objects in response
x-last-page Request URL to last page
x-first-page Request URL to first page
x-previous-page Request URL to previous page
x-next-page Request URL to next page

Inventory

Devices

Creating a device

curl -v https://api.serverdensity.io/inventory/devices/?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data name=Llama
import requests

api_response = requests.post(
    'https://api.serverdensity.io/inventory/devices/',
    params={
        'token':'b97da80a41c4f61bff05975ee51eb1aa'
    },
    data={
        "name": "Llama"
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {
    :query => {"token" => token},
    :body => {"name" => "Llama"}
}

response = HTTParty.post("https://api.serverdensity.io/inventory/devices/", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$device = array("name"=> "Llama");

$client->api('devices')->create($device);

?>

The response will be a JSON encoded hash representing the device, including the fields that have been created.

{
    "_id": "51f7eafcdba4bb235e000ae4",
    "name": "Llama",
    "type": "device",
    "agentKey": "c2bbdd6689ff46282bdaa07555641498",
    "group": null,
    "publicIPs": [],
    "privateIPs": [],
    "updatedAt": "2013-07-30T16:34:04",
    "createdAt": "2013-07-30T16:34:04",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "deleted": false,
    "tags": null,
}

You can create new devices via the API, useful if you want to automatically provision new devices and start monitoring automatically - the agent key.

This API method is used by our Puppet manifest, Chef cookbook and installer shell script to automatically create devices during the agent installation.

HTTP request

POST /inventory/devices?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
name Yes string Name of item.
cpuCores No string Item’s number of cores.
group No string Name of group. This is set to “null” when a device doesn’t have a group.
hostname No string Item’s hostname
installedRAM No string RAM installed
os No string Operating system that it runs.
privateIPs No JSON list Item’s private IP addresses as a JSON encoded list.
publicIPs No JSON list Item’s public DNS as a JSON encoded list.
swapSpace No string Item’s swap space
provider No string The provider dependent string that identifies this item. If this field is set, provider is mandatory.
tags No JSON list A JSON list of tag IDs.

Deleting a device

curl -v -X DELETE https://api.serverdensity.io/inventory/services/51f931c9dba4bba36d001542?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
device_id = '51f931c9dba4bba36d001542'

delete_response = requests.delete(
    "https://api.serverdensity.io/inventory/devices/{0}".format(device_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
device_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete("https://api.serverdensity.io/inventory/devices/#{device_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$device = "id here";

$client->api('devices')->delete($device);

?>

The response is a JSON encoded hash containing the ID of the device that has been deleted.

{
    "_id": "51f931c9dba4bba36d001542"
}

 Http request

DELETE /inventory/devices/<deviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
deviceId Yes string The ID of your device.

Response Parameters

Parameters Type Description
_id string The id of the device that got deleted

Listing all devices

Get a list of every device in your account.

curl -v -X GET https://api.serverdensity.io/inventory/devices?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = "b97da80a41c4f61bff05975ee51eb1aa"

r = requests.get(
    'https://api.serverdensity.io/inventory/devices',
    params = {
        'token': token 
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"

params = {:query => {"token" => token}}

response = HTTParty.get("https://api.serverdensity.io/inventory/devices", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('devices')->all();

?>

The response is a list of JSON objects representing each device.

[
    {
        "_id": "51f6585e11f144673749afbb",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "agentKey": "22ddab237dff5cde07dc70a26e93c262",
        "cId": "c16",
        "cloud": false,
        "cpuCores": null,
        "createdAt": "2013-07-29T12:19:11",
        "deleted": false,
        "group": "docs",
        "hostname": "docshost",
        "imageId": null,
        "installedRAM": "",
        "ip": null,
        "isMonitored": true,
        "isNew": true,
        "lastPayloadAt": {
            "sec": 1375179061,
            "usec": 0
        },
        "location": {
            "countryCode": "gb",
            "countryName": "United Kingdom",
            "text": "Docs device"
        },
        "name": "Llama",
        "os": {
            "code": "linux",
            "name": "Linux"
        },
        "pluginsEnabled": [
            {
                "DocsPlugin": [
                    "hats",
                    "socks",
                    "jumpers"
                ]
            },
            {
                "TestPlugin": [
                    "test1",
                    "test3",
                    "test2"
                ]
            }
        ],
        "privateIPs": [],
        "provider": null,
        "publicIPs": [],
        "status": null,
        "swapSpace": "",
        "CPUCores": "",
        "type": "device",
        "updatedAt": "2013-07-30T10:11:01",
        "userId": "507ec4f48f4a5c547f000000",
        "tags": null,
    }
]

HTTP Request

GET /inventory/devices?token=<token>

Request parameters

Parameters Required Type Description
token Yes string Your API token.

Response parameters

Parameters Type Description
_id string The id of your device. This is used when updating your device.
accountId string The account to which the device belongs to.
agentKey string The key used by the agent. Can be used to view device by agent key
cId string Used when first creating a cloud device, not important after that.
cloud bool Is a cloud device.
createdAt string When the device was created.
deleted bool If the device is deleted.
group string The group to which the device belongs to, default is null.
hostname string Hostname of the server.
imageId string Cloud Image ID from the cloud provider.
installedRam string The amount of ram as specified by the user.
ip string The IP adddress of the server.
isMonitored boolean An internal check making sure each machine is being monitored.
isNew boolean Whether the device is new or not.
lastPayLoadAt dictionary The id of your device.
lastPayLoadAt > sec int Numbers of seconds according to Unix time.
lastPayLoadAt > usec int This microseconds from that second where this was issued.
location dictionary A dictionary of location specifics.
location > countryCode string An international country code.
location > countryName string The name of country.
location > text string Text name of the place in the country, London for instance.
name string The name of your device.
os dictionary A dictionary of OS specifics.
os > code string An internal code for the OS.
os > name string The name of the OS.
pluginsEnabled JSON list A list of dictionaries containing which plugins the device is using.
privateIPs JSON list A list of the private IPs associated with the device.
provider string The provider associated with the device.
publicIPs JSON list A list of public IPs associated with the device.
swapSpace string The amount of swapspace as defined by the user.
CPUCores string The amount of cores as specified by the user.
type string Whether it is a device or a service.
updatedAt string When the device was last updated.
userId string The user associated with the device.
tags JSON list A JSON list with the tag IDs.

Searching for a device

There is a single resources endpoint that will search the entire inventory. This can be used to search for devices.

curl -v -X GET https://api.serverdensity.io/inventory/resources?token=b97da80a41c4f61bff05975ee51eb1aa\&filter='\{"name":"docs","type":"device"\}'\&fields='\["name","type","_id"\]'
import requests
import json

token = 'b97da80a41c4f61bff05975ee51eb1aa'

api_response = requests.get(
    'https://api.serverdensity.io/inventory/resources',
    params = {
        'token': token,
        'filter': json.dumps({
            'name':'docs',
            'type': 'device'
        }),
        'fields': json.dumps(
            [
                'name',
                'type',
                '_id'
            ]
        )
    }
)
require "httparty"
require "json"

token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token 
    "filter" : JSON.dump({
            :name => 'docs',
            :type => 'device'
        }),
        'fields': JSON.dump({
            [
                'name',
                'type',
                '_id'
            ]
        })
    }
}
response = HTTParty.get('https://api.serverdensity.io/inventory/resources', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$filter = array(
    "name" => "docs",
    "type" => "device"
);
$fields = array("name", "type", "_id");
$client->api('devices')->search($filter, $fields);

?>

The response will either be an empty JSON array, or a list of the devices that match the filter.

[
    {
        "_id": "51f6585e11f144673749afbb",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "agentKey": "22ddab237dff5cde07dc70a26e93c262",
        "cId": "c16",
        "cloud": false,
        "cpuCores": null,
        "createdAt": "2013-07-29T12:19:11",
        "deleted": false,
        "group": "docs",
        "hostname": "docshost",
        "imageId": null,
        "installedRAM": "",
        "ip": null,
        "isMonitored": true,
        "isNew": true,
        "lastPayloadAt": {
            "sec": 1375179061,
            "usec": 0
        },
        "location": {
            "countryCode": "gb",
            "countryName": "United Kingdom",
            "text": "Docs device"
        },
        "name": "Llama",
        "os": {
            "code": "linux",
            "name": "Linux"
        },
        "pluginsEnabled": [
            {
                "DocsPlugin": [
                    "hats",
                    "socks",
                    "jumpers"
                ]
            },
            {
                "TestPlugin": [
                    "test1",
                    "test3",
                    "test2"
                ]
            }
        ],
        "privateIPs": [],
        "provider": null,
        "publicIPs": [],
        "status": null,
        "swapSpace": "",
        "CPUCores": "",
        "type": "device",
        "updatedAt": "2013-07-30T10:11:01",
        "userId": "507ec4f48f4a5c547f000000",
        "tags": null, 
    }
]

HTTP request

GET /inventory/resources?token=<token>&filter='{"name":"Llama","type":"device"}'

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
filter Yes string A JSON encoded object of the fields that you wish to search by. Any field returned can be searched on.
fields Yes string A JSON encoded array of the fields that you wish returned by the call.

Response Parameters

Please refer to the response parameters listed in Listing all devices

Updating a device

curl -v -X PUT https://api.serverdensity.io/inventory/devices/51f7ecd4dba4bbee5d000a74?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data name=Changed+Llama
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
device_id = '51f7ecd4dba4bbee5d000a74'

api_response = requests.put(
    'https://api.serverdensity.io/inventory/devices/{0}'.format(device_id),
    params={
        'token': token
    },
    data={
        "name": "Changed Llama"
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
device_id = '51f7ecd4dba4bbee5d000a74'

params = {
    :query => {"token" => token},
    :body => {"name": "Changed Llama"}
}

response = HTTParty.put("https://api.serverdensity.io/inventory/devices/#{device_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$fields = array(
    "name" => "Changed llama",
);
$fields = array("name", "type", "_id");
$client->api('devices')->search($id, $fields);

?>

The response will be a JSON encoded hash representing the updated fields on the device.

{
    "name": "Changed Llama",
    "publicIPs": [],
    "privateIPs": [],
    "updatedAt": "2013-07-31T10:36:03",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "_id": "51f7ecd4dba4bbee5d000a74"
}

Http request

PUT /inventory/devices/<deviceId>?token=<token>

Request Parameters

Parameters Required Type Description
deviceId Yes string The ID of the device to update.
token Yes string Your API token.
cpuCores No string Item’s number of cores.
group No string Name of group. This is set to “null” when a device doesn’t have a group.
hostname No string Item’s hostname.
installedRAM No string RAM installed.
name No string Name of the device.
os No string Operating system that it runs.
privateIPs No string Item’s private IP addresses as a JSON encoded list.
privateDNS No string Item’s private DNS as a JSON encoded list.
publicDNS No string Item’s public DNS as a JSON encoded list.
publicIPs No string Item’s public IP addresss as a JSON encoded list.
swapSpace No string Item’s swap space.
provider No string Provider where the item is hosted. For cloud items it may be ‘amazon’, ‘google’ or ‘rackspace’.
providerId No string The provider dependent string that identifies this item. If this field is set, provider is mandatory.
tags No JSON list A JSON list of tag IDs.

View device by agent key

curl -v -X GET https://api.serverdensity.io/inventory/devices/22ddab237dff5cde07dc70a26e93c262/byagentkey?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

agent_key = '22ddab237dff5cde07dc70a26e93c262'
token = 'b97da80a41c4f61bff05975ee51eb1aa'

api_response = requests.get(
    'https://api.serverdensity.io/inventory/devices/{0}/byagentkey'.format(agent_key),
    params={
        'token': token
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
agent_key = "22ddab237dff5cde07dc70a26e93c262"

params = {:query => {"token" => token}}

response = HTTParty.get("https://api.serverdensity.io/inventory/devices/#{agent_key}/byagentkey", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$agentKey = "76oeu57a5765a76e5a7";

$client->api('devices')->viewByAgent($agentKey);

?>
{
    "_id": "51f6585e11f144673749afbb",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "agentKey": "22ddab237dff5cde07dc70a26e93c262",
    "cId": "c16",
    "cloud": false,
    "cpuCores": null,
    "createdAt": "2013-07-29T12:19:11",
    "deleted": false,
    "group": "docs",
    "hostname": "docshost",
    "imageId": null,
    "installedRAM": "",
    "ip": null,
    "isMonitored": true,
    "isNew": true,
    "lastPayloadAt": {
        "sec": 1375179061,
        "usec": 0
    },
    "location": {
        "countryCode": "gb",
        "countryName": "United Kingdom",
        "text": "Docs device"
    },
    "name": "Llama",
    "os": {
        "code": "linux",
        "name": "Linux"
    },
    "pluginsEnabled": [
        {
            "DocsPlugin": [
                "hats",
                "socks",
                "jumpers"
            ]
        },
        {
            "TestPlugin": [
                "test1",
                "test3",
                "test2"
            ]
        }
    ],
    "privateIPs": [],
    "provider": null,
    "publicIPs": [],
    "status": null,
    "swapSpace": "",
    "CPUCores": "",
    "type": "device",
    "updatedAt": "2013-07-30T10:11:01",
    "userId": "507ec4f48f4a5c547f000000", 
    "tags": null
}

HTTP Request

GET /inventory/devices/<agentkey>/byagentkey?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
agentKey Yes string The key used by the agent

Response parameters

Please refer to the response parameters listed in Listing all devices

View device by ID

curl -v -X GET https://api.serverdensity.io/inventory/devices/51f6585e11f144673749afbb?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

device_id = '51f6585e11f144673749afbb'
token = "b97da80a41c4f61bff05975ee51eb1aa"

api_response = requests.get(
    'https://api.serverdensity.io/inventory/devices/{0}'.format(device_id),
    params = {
        'token': token
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
device_id = "22ddab237dff5cde07dc70a26e93c262"

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/inventory/devices/#{device_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$client->api('devices')->view($id);

?>
{
    "_id": "51f6585e11f144673749afbb",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "agentKey": "22ddab237dff5cde07dc70a26e93c262",
    "cId": "c16",
    "cloud": false,
    "cpuCores": null,
    "createdAt": "2013-07-29T12:19:11",
    "deleted": false,
    "group": "docs",
    "hostname": "docshost",
    "imageId": null,
    "installedRAM": "",
    "ip": null,
    "isMonitored": true,
    "isNew": true,
    "lastPayloadAt": {
        "sec": 1375179061,
        "usec": 0
    },
    "location": {
        "countryCode": "gb",
        "countryName": "United Kingdom",
        "text": "Docs device"
    },
    "name": "Llama",
    "os": {
        "code": "linux",
        "name": "Linux"
    },
    "pluginsEnabled": [
        {
            "DocsPlugin": [
                "hats",
                "socks",
                "jumpers"
            ]
        },
        {
            "TestPlugin": [
                "test1",
                "test3",
                "test2"
            ]
        }
    ],
    "privateIPs": [],
    "provider": null,
    "publicIPs": [],
    "status": null,
    "swapSpace": "",
    "CPUCores": "",
    "type": "device",
    "updatedAt": "2013-07-30T10:11:01",
    "userId": "507ec4f48f4a5c547f000000",
    "tags": null,
}

Http Request

GET /inventory/devices/<deviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
deviceId Yes string The ID of the device to update.

NOTE copy parameters from listing device

Response parameters

Please refer to the response parameters listed in Listing all devices

Services

Creating a service

curl -v https://api.serverdensity.io/inventory/services/?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data name=Llama \
     --data checkType=http \
     --data checkUrl=http:\/\/www.example.org \
     --data checkMethod=GET \
     --data timeout=10 \
     --data checkLocations='["dub"]' \
     --data slowThreshold=500
import json
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

api_response = requests.post(
    'https://api.serverdensity.io/inventory/services',
    params={
        'token': token
    },
    data={
        'name': 'Llama',
        'checkType': 'http',
        'checkUrl': 'http://www.example.org',
        'checkMethod': 'GET',
        'timeout': '10',
        'slowThreshold': '500',
        'checkLocations': json.dumps(['dub'])
    }
)
require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {
    :query => {"token" => token},
    :body => {
        'name' => 'Llama',
        'checkType' => 'http',
        'checkUrl' => 'http://www.example.org',
        'checkMethod' => 'GET',
        'timeout' => '10',
        'slowThreshold' => '500',
        'checkLocations': JSON.dump(['dub'])
    }
}

response = HTTParty.post("https://api.serverdensity.io/inventory/services", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$service = array("name"=> "Llama");

$client->api('services')->create($service, ['my', 'tags']);

?>

The reponse will be a JSON encoded hash representing the service, including the fields that have been created by the inventory service.

{
    "name": "Llama",
    "checkType": "http",
    "checkUrl": "http://www.example.org",
    "checkMethod": "GET",
    "timeout": 10,
    "slowThreshold": 500,
    "checkLocations": [
        "dub"
    ],
    "group": null,
    "type": "service",
    "updatedAt": "2013-07-31T15:48:25",
    "createdAt": "2013-07-31T15:48:25",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "deleted": false,
    "_id": "51f931c9dba4bba36d001542",
    "tags": null,
}

HTTP Request

POST /inventory/services?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
name Yes string The display name for the service.
checkType Yes string The type of check: either http or tcp
timeout Yes int How many seconds to wait until timing out. Max 30.
checkUrl Yes string HTTP Check - The URL to issue the request to.
checkLocations Yes json list A JSON list of locations to check from e.g. ["lon", "dub"]. Each location has its own “API ID” which is noted on the locations list.
checkMethod Yes string HTTP Check - The HTTP method used to issue the check: either GET, POST, PUT or DELETE. Required for HTTP check, irrelevant for TCP.
slowThreshold Yes int HTTP Check - Request time millisecond threshold after which service is deemed slow.
group No string The group the service belongs to. If this is empty it’s set to null.
auth No dict Basic HTTP auth username and password. e.g {"username": Thomas", "password": "password"}
headers No dictionary HTTP Check - headers to include e.g. {"User-Agent": "Thomas the Tank Engine"}
body No string HTTP Check - Content of the HTTP request body
validateCert No bool HTTP Check - Whether to validate the SSL certificate or not
host No string TCP Check - The hostname or IP address to issue the TCP check to
port No string TCP Check - The port number to issue the TCP check to
data No string TCP Check - The content to send when opening the TCP socket
auth No dictionary Basic HTTP auth username and password. e.g. {"username":"Thomas", "password":"password"}
tags No JSON list A JSON list of tag IDs.

Response parameters

Please refer to the response parameters in Listing services

The response parameters are similar to the request parameters.

Deleting a Service

curl -v -X DELETE https://api.serverdensity.io/inventory/services/51f931c9dba4bba36d001542?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
service_id = '51f931c9dba4bba36d001542'

delete_response = requests.delete(
    "https://api.serverdensity.io/inventory/services/{0}".format(service_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
service_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete("https://api.serverdensity.io/inventory/services/#{service_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$service = "id here";

$client->api('services')->delete($service);

?>

The response is a JSON encoded hash containing the ID of the service that has been deleted.

{
    "_id": "51f931c9dba4bba36d001542"
}

HTTP request

DELETE /inventory/services/<serviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string The ID of your service.

Response parameters

Parameters Type Description
_id string The id of the service that got deleted

Listing services

Get a list of every service monitor on your account.

curl -v -X GET https://api.serverdensity.io/inventory/services?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

r = requests.get(
    'https://api.serverdensity.io/inventory/services',
    params={'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {:query => {"token" => token}}

response = HTTParty.get("https://api.serverdensity.io/inventory/services", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('services')->all();

?>

This will return a json encoded list of the services that are available in your account.

[
    {
        "_id": "51f6585e11f144673749afbb",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "currentStatus": "up",
        "body": [],
        "name": "Llama",
        "slowThreshold": 500,
        "timeout": 10,
        "checkType": "HTTP",
        "checkUrl": "http://example.org",
        "checkMethod": "GET",
        "checkLocations": [
            "dub"
        ],
        "notes": "",
        "group": null,
        "type": "service",
        "updatedAt": "2013-07-31T13:59:34",
        "createdAt": "2013-07-31T13:59:34",
        "deleted": false, 
        "headers": [], 
        "validateCert": false, 
        "tags": null,
    }
]

HTTP Request

GET /inventory/services?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response Parameters

Parameters Type Description
_id string The id of your service.
currentStatus string Whether the site is currently up and running or not.
body string HTTP Check - A body content string to send as part of the HTTP check.
name string The display name for the service.
slowThreshold int Request time millisecond threshold after which service is deemed slow.
timeout int How many seconds the service waits until timing out. Max 30.
checkType string The type of check: either http or tcp
checkUrl string HTTP Check - The URL to issue the request to.
checkMethod string HTTP Check - The HTTP method used to issue the check: either GET or POST.
checkLocations json list A JSON list of locations to check from e.g. ["lon", "dub"]. Each location has its own “API ID” which is noted on the locations list.
notes string A box on the ui for the user to put details about the service.
group string The group the service belongs to.
type string Whether this is a service or a device.
updatedAt string When this service was last updated
createdAt string When this service was created
accountId string To which account this service belongs to.
deleted string Whether the device is deleted or not.
headers JSON list Specific headers that you want to send with the HTTP request.
validateCert bool If the service is HTTPS we validate the certificate and check whether it is valid or not.
tags JSON list A JSON list with the tag IDs.

Searching for a Service

There is a single resources endpoint that will search the entire inventory. This can be used to search for devices.

curl -v -X GET https://api.serverdensity.io/inventory/resources?token=b97da80a41c4f61bff05975ee51eb1aa\&filter='\{"name":"Llama","type":"service"\}'\&fields='\["name","type","_id"\]'
import requests
import json

api_response = requests.get(
    'https://api.serverdensity.io/inventory/resources',
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa',
        'filter': json.dumps(
            {
                'name':'Llama',
                'type': 'service'
            }
        ),
        'fields': json.dumps(
            [
                'name',
                'type',
                '_id'
            ]
        )
    }
)
require "httparty"
require "json"

token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token 
    "filter" : JSON.dump({
            :name => 'docs',
            :type => 'service'
        }),
        'fields': JSON.dump({
            [
                'name',
                'type',
                '_id'
            ]
        })
    }
}
response = HTTParty.get('https://api.serverdensity.io/inventory/resources', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$filter = array(
    "name" => "docs",
    "type" => "service"
);
$fields = array("name", "type", "_id");
$client->api('services')->search($filter, $fields);

?>

The response will either be an empty JSON array, or a list of the services that match the filter. These will be in the same format and with the same fields as without the filter.

[
    {
        "_id": "51f6585e11f144673749afbb",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "currentStatus": "up",
        "body": [],
        "name": "Llama",
        "slowThreshold": 500,
        "timeout": 10,
        "checkType": "HTTP",
        "checkUrl": "http://example.org",
        "checkMethod": "GET",
        "checkLocations": [
            "dub"
        ],
        "notes": "",
        "group": null,
        "type": "service",
        "updatedAt": "2013-07-31T13:59:34",
        "createdAt": "2013-07-31T13:59:34",
        "deleted": false, 
        "headers": [], 
        "validateCert": false,
        "tags": null,
    }
]

HTTP request

GET /inventory/resources?token=<token>&filter='{"name":"Llama","type":"service"}'

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
filter Yes string A JSON encoded hash of the fields that you wish to search by. Any field returned can be searched on.
fields No string A JSON encoded array of the fields that you wish returned by the call.

Response parameters

Please refer to the response parameters in Listing services

Updating a Service

curl -v -X PUT http://api.serverdensity.io/inventory/services/51f932d0dba4bbf15d001219?token=b97da80a41c4f61bff05975ee51eb1aa
     --data name=Changed+Llama
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
service_id = '51f7ecd4dba4bbee5d000a74'

api_response = requests.put(
    'https://api.serverdensity.io/inventory/services/{0}'.format(service_id),
    params={'token': token},
    data={"name": "Changed Llama"}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
service_id = '51f7ecd4dba4bbee5d000a74'

params = {
    :query => {"token" => token},
    :body => {"name": "Changed Llama"}
}

response = HTTParty.put("https://api.serverdensity.io/inventory/services/#{service_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$fields = array(
    "name" => "Changed llama",
);
$fields = array("name", "type", "_id");
$client->api('services')->search($id, $fields);

?>

The response will be a JSON encoded hash reprsenting the updated fields on the service.

{
    "name": "Changed Llama",
    "updatedAt": "2013-07-31T16:25:22",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "_id": "51f932d0dba4bbf15d001219"
}

HTTP Request

PUT /inventory/services/<serviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string The ID of your service.
name No string The display name for the service.
checkType No string The type of check: either http or tcp
timeout No int How many seconds to wait until timing out. Max 30.
checkLocations No json list A JSON list of locations to check from e.g. ["lon", "dub"]. Each location has its own “API ID” which is noted on the locations list.
group No string The group the service belongs to.
checkUrl No string HTTP Check - The URL to issue the request to.
checkMethod No string HTTP Check - The HTTP method used to issue the check: either GET or POST.
slowThreshold No int HTTP Check - Request time millisecond threshold after which service is deemed slow.
body No string HTTP Check - Content of the HTTP request body
host No string TCP Check - The hostname or IP address to issue the TCP check to
port No string TCP Check - The port number to issue the TCP check to
data No string TCP Check - The content to send when opening the TCP socket
validateCert No bool Whether to validate the SSL certificate or not
auth No dictionary Basic HTTP auth username and password. e.g. {"username":"Thomas", "password":"password"}
headers No dictionary HTTP headers to include e.g. {"User-Agent": "Thomas the Tank Engine"}
tags No JSON list A JSON list of tag IDs.

View service by ID

curl -v -X GET https://api.serverdensity.io/inventory/services/51f91846dba4bbf05d001335/?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

service_id = '51f6585e11f144673749afbb'

api_response = requests.get(
    'https://api.serverdensity.io/inventory/services/{0}'.format(service_id),
    params = {'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
service_id = "22ddab237dff5cde07dc70a26e93c262"

params = {:query => {"token" => token}}

response = HTTParty.get("https://api.serverdensity.io/inventory/services/#{service_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$client->api('services')->view($id);

?>

The response is a JSON encoded hash containing the data for the service.

{
    "_id": "51f6585e11f144673749afbb",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "currentStatus": "up",
    "body": [],
    "name": "Llama",
    "slowThreshold": 500,
    "timeout": 10,
    "checkType": "HTTP",
    "checkUrl": "http://example.org",
    "checkMethod": "GET",
    "checkLocations": [
        "dub"
    ],
    "notes": "",
    "group": null,
    "type": "service",
    "updatedAt": "2013-07-31T13:59:34",
    "createdAt": "2013-07-31T13:59:34",
    "deleted": false, 
    "headers": [], 
    "validateCert": false,
    "tags": null,
}

HTTP Request

GET /inventory/services/<serviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response parameters

Please refer to the response parameters in Listing services

Alerts

Alert Config

Create new alerts on devices or services, at an item or group level.

Creating an alert

curl -v https://api.serverdensity.io/alerts/configs/?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data subjectId=520dee51cbda5de279000013 \
     --data subjectType=device \
     --data section=system \
     --data field=loadAvrg \
     --data comparison=gte \
     --data value=0 \
     --data recipients='[{"type":"user","id":"520dec7ecbda5d317300000a","actions":["sms","email"]}]' \
     --data wait='{"seconds": 60,"enabled":true,"displayUnits": "s"}' \
     --data repeat='{"seconds": 300,"enabled":true,"displayUnits": "s"}' \
     --data fix=true
import json
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

api_response = requests.post('https://api.serverdensity.io/alerts/configs',
    params={'token': token},
    data={
        'subjectId': '520dee51cbda5de279000013',
        'subjectType': 'device',
        'section': 'system',
        'field': 'loadAvrg',
        'comparison': 'gte',
        'value': 0,
        'recipients': json.dumps(
            [{
                "type": "user",
                "id":"520dec7ecbda5d317300000a",
                "actions": [
                    "sms",
                    "email"
                ]
            }]
        ),
        'wait': json.dumps(
            {
                "seconds": 60,
                "enabled": true,
                "displayUnits": "s"
            }
        ),
        'repeat': json.dumps(
            {
                "seconds": 300,
                "enabled": true,
                "displayUnits": "s"
            }
        ),
        'fix': True
    }
)
require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {
    :query => {"token" => token},
    :body => {
        'subjectId' => '520dee51cbda5de279000013',
        'subjectType' => 'device',
        'section' => 'system',
        'field' => 'loadAvrg',
        'comparison' => 'gte',
        'value' => 0,
        'recipients' => JSON.dump(
            [{
                "type" => "user",
                "id" =>"520dec7ecbda5d317300000a",
                "actions" => [
                    "sms",
                    "email"
                ]
            }]
        ),
        'wait' => JSON.dump(
            {
                "seconds" => 60,
                "enabled" => true,
                "displayUnits" => "s"
            }
        ),
        'repeat' => JSON.dump(
            {
                "seconds" => 300,
                "enabled" => true,
                "displayUnits" => "s"
            }
        ),
        'fix' => true
    }
}

response = HTTParty.post("https://api.serverdensity.io/alerts/configs", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);
$alert = array(
    'subjectId' => '520dee51cbda5de279000013',
    'subjectType' => 'device',
    'section' => 'system',
    'field' => 'loadAvrg',
    'comparison' => 'gte',
    'value' => 0
);
$recipients = array(
    "type" => "user",
    "id" =>"520dec7ecbda5d317300000a",
    "actions" => [
        "sms",
        "email"
    ]
);
$wait = array(
    "seconds" => 60,
    "enabled" => true,
    "displayUnits" => "s"
);
$repeat = array(
    "seconds" => 300,
    "enabled" => true,
    "displayUnits" => "s"
);


$client->api('alerts')->create($alert, $recipients, $wait, $repeat);

?>

The reponse will be a JSON encoded hash representing the created alert

{
    "subjectId": "520dee51cbda5de279000013",
    "subjectType": "device",
    "section": "system",
    "field": "loadAvrg",
    "comparison": "gte",
    "value": "0",
    "recipients": [
        {
            "type": "user",
            "id": "520dec7ecbda5d317300000a",
            "actions": [
                "sms",
                "email"
            ]
        }
    ],
    "wait": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    },
    "repeat": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"
    },
    "fix": true,
    "enabled": true,
    "subject": null,
    "valid": true,
    "accountId": "4fa3c6ef22257d6c2f000000",
    "createdAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "updatedAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "_id": "523599f19711f423690003e4"
}

HTTP Request

POST /alerts/configs?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
subjectId Yes string The ID of the subject e.g. the device/service ID or the group name for group alerts
subjectType Yes string The type of the subject - device or service for individual alerts, or deviceGroup or serviceGroup for group alerts
subject Yes string Is either null or contains a string of a path, or a name of process for instance. It can also be ‘ALL’ for average over all paths eg for disk usage.
enabled Yes bool Whether the alert is enabled or not. Shown as pause/resume in the web UI
section Yes string The metric section
field Yes string The metric sub-section
comparison Yes string The comparison type for the alert. See table below for full list of comparisons.
value Yes string The value to trigger the alert based on the comparison
recipients Yes list of dict JSON encoded list of objects describing recipients and actions (see below)
wait Yes dict JSON encoded object describing the amount of time to wait before first alert notification (see below)
repeat Yes dict JSON encoded object describing how often to repeat the alert notifications (see below)
fix Yes boolean Whether the alert is fixed or not.
group No string The group the alert should be created on
Comparison Explanation
lt less than
gt greater than
lte less than or equal to
gte greater than or equal to
eq equal to
neq not equal to
c contains
nc does not contain
re matches regex
nre does not match regex

Parameters: Recipients

This is a JSON encoded list of objects for each recipient of the alert notifications, and the type of notification they should receive:


    "recipients": [
        {
            "type": "user",
            "id": "505762ccfeff41bf55000001",
            "actions": ["sms", "email"]
        }
    ]

Parameters Required Type Description
type Yes string The type of recipient: user, pagerduty or webhook
id Yes string The ID of the recipient e.g. user ID or webhook ID
actions depends string The notification types to send, not required for pagerduty, webhook, slack or hipchat types

Parameters: Wait

This is a JSON encoded object describing whether to wait for the first notification after the alert is triggered.


    "wait": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"

Parameters Required Type Description
seconds Yes string The number of seconds to wait.
enabled Yes string Whether the wait configuration is enabled or not
displayUnits Yes string Hint for the UI, always s (may change in future releases)

Parameters: Repeat

This is a JSON encoded object describing how often to repeat the alert notifications:


    "repeat": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    }

Parameters Required Type Description
seconds Yes string The number of seconds to wait.
enabled Yes string Whether the wait configuration is enabled or not
displayUnits Yes string Hint for the UI, always s (may change in future releases)

Deleting an alert

curl -v -X DELETE https://api.serverdensity.io/alerts/configs/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
alert_id = '523599f19711f423690003e4'

delete_response = requests.delete(
    "https://api.serverdensity.io/alerts/configs/{0}".format(alert_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
alert_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete(
    "https://api.serverdensity.io/alerts/configs/#{alert_id}", 
    params
)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "id here";

$client->api('alerts')->delete($id);

?>

The response is a JSON encoded hash containing the ID of the alert that has been deleted.

{
    "_id": "523599f19711f423690003e4"
}

 HTTP Request

DELETE /alerts/configs/<alertId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response parameters

Parameters Type Description
_id string The id of the device that got deleted

Listing all alerts

curl https://api.serverdensity.io/alerts/configs/?token=b97da80a41c4f61bff05975ee51eb1aa\&filter='\{"field":"loadAvrg"\}'
import requests

requests.get(
    'https://api.serverdensity.io/alerts/configs',
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa',
        'filter': json.dumps({
            'field':'loadAvrg',
        })
    }
)
require "httparty"

token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token,
    "filter" => JSON.dump({
            "field" => "loadAvrg"
        })
}
response = HTTParty.get('https://api.serverdensity.io/alerts/configs', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('alerts')->all();

?>

This will return a JSON encoded list of the alert configurations for your account.

[
    {
        "_id": "5203a041dba4bb6010000000",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "comparison": "gt",
        "createdAt": {
            "sec": 1375969345,
            "usec": 0
        },
        "deleted": false,
        "enabled": true,
        "field": "loadAvrg",
        "fix": true,
        "fullField": "system-loadAvrg",
        "group": "",
        "locationThreshold": 1,
        "lastTriggeredAt": {
            "sec": 1418210271,
            "usec": 578000
        },
        "notificationSent": true, 

        "recipients": [
            {
                "id": "52037dd6dba4bbc014000349",
                "type": "user",
                "actions": [
                    "email"
                ]
            },
            {
                "id": "52037dd6dba4bb391e00009e",
                "type": "user",
                "actions": [
                    "email"
                ]
            }
        ],
        "repeat": {
            "seconds": 0,
            "enabled": false,
            "displayUnits": "s"
        },
        "open": true,
        "section": "system",
        "subject": null,
        "subjectId": "52037df285ce7525c4f5813a",
        "subjectType": "device",
        "updatedAt": {
            "sec": 1375969354,
            "usec": 0
        },
        "valid": true,
        "value": "2",
        "wait": {
            "seconds": 0,
            "enabled": false,
            "displayUnits": "s"
        },
        "waitTriggered": false
    }
]

Get a list of all configured alerts on your account.

HTTP Request

GET https://api.serverdensity.io/alerts/configs?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
filter No string A JSON encoded hash of the fields that you wish to search by. Any field returned can be searched on.

Response Parameters

Parameters Type Description
id string The ID of the alert.
account_id string The account to which the alert belongs to.
comparison string The comparison type for the alert, see table at creating an alert.
createdAt dict When the alert was created in unix time and microseconds after that second.
deleted bool Whether the alert has been deleted.
enabled bool Whether the alert is enabled or not.
fix bool Controls whether you get notifications when the alert is fixed.
field string The metric sub-section. Take a look at listing alert metrics for a full explanation.
fullField string a combination of section and field.
group string To which group the alert belongs to.
lastTriggeredAt dict When the alert was last triggered in unix time and microseconds after that second
locationsThreshold int Only valid for services, the number of locations that are down for the alert to trigger.
notificationSent bool An internal check for whether the notification has been sent or not.
open bool Set to true when an Alert is triggered.
section string The metric section. Take a look at listing alert metrics for a full explanation.
subject string Is the target you’re measuring from, eg for disk usage it would be /dev for instance.
subjectId string The ID of the subject.
subjectType string Either a device, service, service group or device group.
updatedAt string When the alert was last updated.
valid bool Whether all fields are filled in correctly for the alert.
value string The value to trigger the alert based on the comparison.
wait dict JSON encoded object describing the amount of time to wait before first alert notification. See this section at creating an alert
recipients dict JSON encoded list of objects describing recipients and actions. See this section at creating an alert
repeat dict JSON encoded object describing how often to repeat the alert notifications. See this section at creating an alert

Listing alerts by subjects

Get a list of all configured alerts for a specific subject (device or service).

curl https://api.serverdensity.io/alerts/configs/52037df285ce7525c4f5813a?subjectType=device\&token=b97da80a41c4f61bff05975ee51eb1aa
import requests

subject_id = '52037df285ce7525c4f5813a'

requests.get(
    'https://api.serverdensity.io/alerts/configs/{0}'.format(subject_id),
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa',
        'subjectType': 'device'
    }
)
require "httparty"

token = 'b97da80a41c4f61bff05975ee51eb1aa'
subject_id = '52037df285ce7525c4f5813a'

params = {:query => {
    "token" => token 
    "subjectType": "device"
}
response = HTTParty.get('https://api.serverdensity.io/alerts/configs/#{subject_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = '65oae4a65oe46a5oe4ao';
$type = 'device'

$client->api('alerts')->bySubject($id, $type);

?>

The response will be a JSON encoded list containing the alert configurations that apply to that particular subject.

[
    {
        "_id": "5203a041dba4bb6010000000",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "comparison": "gt",
        "createdAt": {
            "sec": 1375969345,
            "usec": 0
        },
        "deleted": false,
        "enabled": true,
        "field": "loadAvrg",
        "fix": true,
        "fullField": "system-loadAvrg",
        "group": "",
        "recipients": [
            {
                "id": "52037dd6dba4bbc014000349",
                "type": "user",
                "actions": [
                    "email"
                ]
            },
            {
                "id": "52037dd6dba4bb391e00009e",
                "type": "user",
                "actions": [
                    "email"
                ]
            }
        ],
        "repeat": {
            "seconds": 0,
            "enabled": false,
            "displayUnits": "s"
        },
        "section": "system",
        "subject": null,
        "subjectId": "52037df285ce7525c4f5813a",
        "subjectType": "device",
        "updatedAt": {
            "sec": 1375969354,
            "usec": 0
        },
        "valid": true,
        "value": "2",
        "wait": {
            "seconds": 0,
            "enabled": false,
            "displayUnits": "s"
        }
    }
]

HTTP Request

GET https://api.serverdensity.io/alerts/configs/<subjectId>?subjectType=<type>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
subjectId Yes string The ID of the subject e.g. the device ID
token Yes string The type of the subject - device or service

Response Parameters

See the section Listing alerts for explanation of the response parameters.

Updating alerts

Update existing alerts on devices or services, at an item or group level.

curl -v -X PUT https://api.serverdensity.io/alerts/configs/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data value=5 \
     --data recipients='[{"type":"user","id":"520dec7ecbda5d317300000a","actions":["email"]}]'
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
alert_id = '523599f19711f423690003e4'

api_response = requests.put(
    'https://api.serverdensity.io/alerts/configs/{0}'.format(alert_id),
    params={'token': token},
    data={
        "value": 5,
        "recipients": json.dumps(
            [{
                "type":"user",
                "id":"520dec7ecbda5d317300000a",
                "actions": ["email"]
            }]
        )
    }
)
require "httparty"
require 'json'

token = "b97da80a41c4f61bff05975ee51eb1aa"
alert_id = '51f7ecd4dba4bbee5d000a74'

params = {
    :query => {"token" => token},
    :body => {
        "value" => 5,
        "recipients" => JSON.dump(
            [{
                "type" =>"user",
                "id" =>"520dec7ecbda5d317300000a",
                "actions" => ["email"]
            }]
        )
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/alerts/configs/#{alert_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$fields = array(
        "value" => 5,
);

$arrayFields = array(
    "recipients" =>
        [
            "type":"user",
            "id":"520dec7ecbda5d317300000a",
            "actions": ["email"]
        ],
);

$id = '65oae4a65oe46a5oe4ao';
$type = 'device'

$client->api('alerts')->update($id, $fields, $arrayFields);

?>

The reponse will be a JSON encoded hash representing the updated alert

{
    "subjectId": "520dee51cbda5de279000013",
    "subjectType": "device",
    "section": "system",
    "field": "loadAvrg",
    "comparison": "gte",
    "value": "0",
    "recipients": [
        {
            "type": "user",
            "id": "520dec7ecbda5d317300000a",
            "actions": [
                "sms",
                "email"
            ]
        }
    ],
    "wait": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    },
    "repeat": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"
    },
    "fix": true,
    "enabled": true,
    "subject": null,
    "valid": true,
    "accountId": "4fa3c6ef22257d6c2f000000",
    "createdAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "updatedAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "_id": "523599f19711f423690003e4"
}

HTTP Request

PUT /alerts/configs/<alertId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string The ID of the service to update
subjectId No string The ID of the subject e.g. the device/service ID or the group name for group alerts
subjectType No string The type of the subject - device or service for individual alerts, or deviceGroup or serviceGroup for group alerts
enabled No bool Whether the alert is enabled or not. Shown as pause/resume in the web UI
section No string The metric section
field No string The metric sub-section
comparison No string The comparison type for the alert. See table below for full list of comparisons.
value No string The value to trigger the alert based on the comparison
recipients No list of dict JSON encoded list of objects describing recipients and actions (see below)
wait No dict JSON encoded object describing the amount of time to wait before first alert notification (see below)
repeat No dict JSON encoded object describing how often to repeat the alert notifications (see below)
group No string The group the alert should be created on
Comparison Explanation
lt less than
gt greater than
lte less than or equal to
gte greater than or equal to
eq equal to
neq not equal toc - contains
nc does not contain
re matches regex
nre does not match regex

Parameters: Recipients

This is a JSON encoded list of objects for each recipient of the alert notifications, and the type of notification they should receive:


    "recipients": [
        {
            "type": "user",
            "id": "505762ccfeff41bf55000001",
            "actions": ["sms", "email"]
        }
    ]

Parameters Required Type Description
type Yes string The type of recipient: user, pagerduty or webhook
id Yes string The ID of the recipient e.g. user ID or webhook ID
actions depends string The notification types to send, not required for pagerduty or webhook types`

Parameters: Wait

This is a JSON encoded object describing whether to wait for the first notification after the alert is triggered.


    "wait": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"

Parameters Required Type Description
seconds Yes string The number of seconds to wait.
enabled Yes string Whether the wait configuration is enabled or not
displayUnits Yes string Hint for the UI, always s (may change in future releases)

Parameters: Repeat

This is a JSON encoded object describing how often to repeat the alert notifications:


    "repeat": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    }

Parameters Required Type Description
seconds Yes string The number of seconds to wait.
enabled Yes string Whether the wait configuration is enabled or not
displayUnits Yes string Hint for the UI, always s (may change in future releases)

Response parameters

See the section Listing alerts for explanation of the response parameters.

Viewing an alert by ID

curl -v -X GET https://api.serverdensity.io/alerts/configs/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

alert_id = '523599f19711f423690003e4'

api_response = requests.get(
    'https://api.serverdensity.io/alerts/configs/{0}'.format(alert_id),
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
require "httparty"

token = 'b97da80a41c4f61bff05975ee51eb1aa'
alert_id = '523599f19711f423690003e4'

params = {:query => {
    "token" => token 
}
response = HTTParty.get('https://api.serverdensity.io/alerts/configs/#{alert_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$client->api('alerts')->view($id);

?>

HTTP Request

GET /alerts/configs/<alertId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response parameters

{
    "subjectId": "520dee51cbda5de279000013",
    "subjectType": "device",
    "section": "system",
    "field": "loadAvrg",
    "comparison": "gte",
    "value": "0",
    "recipients": [
        {
            "type": "user",
            "id": "520dec7ecbda5d317300000a",
            "actions": [
                "sms",
                "email"
            ]
        }
    ],
    "wait": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    },
    "repeat": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"
    },
    "fix": true,
    "enabled": true,
    "subject": null,
    "valid": true,
    "accountId": "4fa3c6ef22257d6c2f000000",
    "createdAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "updatedAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "_id": "523599f19711f423690003e4"
}

See the section Listing alerts for explanation of the response parameters.

Pausing and resuming alerts

Pausing and resuming existing alerts on devices or services, at an item or group level.

curl -v -X PUT https://api.serverdensity.io/alerts/configs/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data enabled=false
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
alert_id = '523599f19711f423690003e4'

api_response = requests.put(
    'https://api.serverdensity.io/alerts/configs/{0}'.format(alert_id),
    params={'token': token},
    data={"enabled": False}
)
require "httparty"
require 'json'

token = "b97da80a41c4f61bff05975ee51eb1aa"
alert_id = '51f7ecd4dba4bbee5d000a74'

params = {
    :query => {"token" => token},
    :body => {
        "enabled" => false 
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/alerts/configs/#{alert_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$fields = array(
    "enabled" => false,
);

$id = '65oae4a65oe46a5oe4ao';

$client->api('alerts')->update($id, $fields);

?>

The reponse will be a JSON encoded hash representing the updated alert

{
    "subjectId": "520dee51cbda5de279000013",
    "subjectType": "device",
    "section": "system",
    "field": "loadAvrg",
    "comparison": "gte",
    "value": "0",
    "recipients": [
        {
            "type": "user",
            "id": "520dec7ecbda5d317300000a",
            "actions": [
                "sms",
                "email"
            ]
        }
    ],
    "wait": {
        "seconds": 60,
        "enabled": true,
        "displayUnits": "s"
    },
    "repeat": {
        "seconds": 300,
        "enabled": true,
        "displayUnits": "s"
    },
    "fix": true,
    "enabled": true,
    "subject": null,
    "valid": true,
    "accountId": "4fa3c6ef22257d6c2f000000",
    "createdAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "updatedAt": {
        "sec": 1379244529,
        "usec": 0
    },
    "_id": "523599f19711f423690003e4"
}

HTTP Request

PUT /alerts/configs/<alertId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string The ID of the service to update
enabled Yes bool Whether the alert is enabled or not. false = paused, true = enabled.

Response Parameters

See the section Listing alerts for explanation of the response parameters.

Triggered Alerts

Get a list of all triggered alerts on your account, or per subject (device or service).

# Return all triggered alerts

curl https://api.serverdensity.io/alerts/triggered?token=b97da80a41c4f61bff05975ee51eb1aa
# Return all open triggered alerts

curl https://api.serverdensity.io/alerts/triggered?closed=false&token=b97da80a41c4f61bff05975ee51eb1aa
# Return all closed triggered alerts

curl https://api.serverdensity.io/alerts/triggered?closed=true&token=b97da80a41c4f61bff05975ee51eb1aa
# Return all open triggered alerts for device 520dee51cbda5de279000013

curl https://api.serverdensity.io/alerts/triggered/520dee51cbda5de279000013?closed=false&subjectType=device&token=b97da80a41c4f61bff05975ee51eb1aa
import requests
# Return all triggered alerts

requests.get(
    'https://api.serverdensity.io/alerts/triggered',
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
import requests
# Return all open triggered alerts

requests.get(
    'https://api.serverdensity.io/alerts/triggered',
    params={
        'closed': False,
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    }
)
import requests
# Return all closed triggered alerts

requests.get(
    'https://api.serverdensity.io/alerts/triggered',
    params={
        'closed': True,
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    }
)
import requests
# Return all open triggered alerts for device 520dee51cbda5de279000013

requests.get(
    'https://api.serverdensity.io/alerts/triggered/520dee51cbda5de279000013',
    params={
        'closed': False,
        'subjectType': 'device',
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    }
)
# Return all triggered alerts

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token 
}
response = HTTParty.get('https://api.serverdensity.io/alerts/triggered', params)

response.to_json
# Return all open triggered alerts

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token,
    "closed" => false 
}
response = HTTParty.get('https://api.serverdensity.io/alerts/triggered', params)

response.to_json
# Return all closed triggered alerts

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'

params = {:query => {
    "token" => token,
    "closed" => true 
}
response = HTTParty.get('https://api.serverdensity.io/alerts/triggered', params)

response.to_json
# Return all open triggered alerts for device 520dee51cbda5de279000013

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'
device_id = "520dee51cbda5de279000013"

params = {:query => {
        'closed' => false,
        'subjectType' => 'device',
        'token' => token
}
response = HTTParty.get('https://api.serverdensity.io/alerts/triggered/#{device_id}', params)

response.to_json
<?php
# Return all triggered alerts
$client->api('alerts')->triggered()

?>
<?php
# Return all open triggered alerts
$device_id = "520dee51cbda5de279000013";

$client->api('alerts')->triggered($closed=false)
# Return all closed triggered alerts
?>
<?php
# Return all closed triggered alerts
$device_id = "520dee51cbda5de279000013";

$client->api('alerts')->triggered($closed=true)
# Return all open triggered alerts for device 520dee51cbda5de279000013
?>
<?php
# Return all open triggered alerts for device 520dee51cbda5de279000013

$client->api('alerts')->triggered($closed=false, 'device', '520dee51cbda5de279000013')

?>

This will return a JSON encoded list of the triggered for your filter options.

[
    {
        "_id": "5232f915ab8b69c63429028b",
        "accountId": "4fa3c6ef22257d6c2f000000",
        "config": {
            "subjectType": "device",
            "fullField": "system-loadAvrg",
            "open": true,
            "createdAt": {
                "sec": 1379072212,
                "usec": 0
            },
            "subject": null,
            "group": "",
            "fix": true,
            "subjectId": "520dee51cbda5de279000013",
            "field": "loadAvrg",
            "valid": true,
            "accountId": "4fa3c6ef22257d6c2f000000",
            "lastTriggeredAt": {
                "sec": 1379080968,
                "usec": 0
            },
            "repeat": {
                "seconds": 60,
                "enabled": true,
                "displayUnits": "s"
            },
            "recipients": [
                {
                    "type": "user",
                    "id": "520dec7ecbda5d317300000a",
                    "actions": [
                        "email"
                    ]
                }
            ],
            "deleted": false,
            "updatedAt": {
                "sec": 1379072229,
                "usec": 0
            },
            "wait": {
                "seconds": 0,
                "enabled": false,
                "displayUnits": "s"
            },
            "comparison": "gte",
            "enabled": true,
            "value": "0",
            "_id": "5232f8d42ea0b7d131000000",
            "section": "system"
        },
        "firstTriggeredAt": {
            "sec": 1379072277,
            "usec": 0
        },
        "fixed": false,
        "triggeredAt": [
            {
                "sec": 1379072277,
                "usec": 0
            },
            {
                "sec": 1379072278,
                "usec": 0
            }
        ],
        "updatedAt": {
            "sec": 1379081031,
            "usec": 0
        }
    }
]

HTTP Request

GET /alerts/triggered?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
closed No bool Whether to filter by closed or open alerts - unset = all alerts, false = open alerts, true = closed alerts.
subjectType depends string The type of the subject - device or service if you also specify the subjectId as part of the URL (see examples below)

Listing Alert metrics

# device alerts

curl -v -X GET https://api.serverdensity.io/alerts/device_alerts.json?token=b97da80a41c4f61bff05975ee51eb1aa

# service alerts

curl -v -X GET https://api.serverdensity.io/alerts/service_alerts.json?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = "b97da80a41c4f61bff05975ee51eb1aa"

devices = requests.get(
    'https://api.serverdensity.io/alerts/device_alerts.json',
    params={'token': token}
)

services = requests.get(
    'https://api.serverdensity.io/alerts/service_alerts.json',
    params={'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"

params = {
    :query => {"token" => token} 
}

devices = HTTParty.get(
    "https://api.serverdensity.io/alerts/device_alerts.json", params)

services = HTTParty.get(
    "https://api.serverdensity.io/alerts/device_alerts.json", params
)

This is all the metric parameters for devices

{
    "mongoDB": {
        "metrics": {
            "aIx": {
                "units": "/s",
                "fullName": "MongoDB Index accesses",
                "name": "Index accesses",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "vMem": {
                "units": "MB",
                "fullName": "MongoDB Memory - virtual",
                "name": "Memory - virtual",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "mMem": {
                "units": "MB",
                "fullName": "MongoDB Memory mapped",
                "name": "Memory - mapped",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "bgLastFlushLength": {
                "units": "",
                "fullName": "MongoDB Last background flush length",
                "name": "Last background flush length",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "aConn": {
                "units": "",
                "fullName": "MongoDB Available connections",
                "name": "Connections available",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "globalLockQueueWriters": {
                "units": "",
                "fullName": "MongoDB Load queue - writers",
                "name": "Load queue - writers",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "iOps": {
                "units": "/s",
                "fullName": "MongoDB Insert operations",
                "name": "Insert operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "rMem": {
                "units": "MB",
                "fullName": "MongoDB Memory - resident",
                "name": "Memory - resident",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "mongoReplOptime": {
                "units": "s",
                "fullName": "MongoDB Replication - last optime",
                "name": "Replication - last optime",
                "excludeComparisons": ["c", "nc", "re", "nre", "ex", "nex"],
                "formatDecimals": 0
            },
            "cConn": {
                "units": "",
                "fullName": "MongoDB Current connections",
                "name": "Connections current",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "rmH": {
                "units": "MB",
                "fullName": "MongoDB RAM headroom",
                "name": "RAM headroom",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "globalLockQueueReaders": {
                "units": "",
                "fullName": "MongoDB Lock queue - readers",
                "name": "Lock queue - readers",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "Database": {
                "metrics": {
                    "dbStatsIndexSize": {
                        "units": "MB",
                        "fullName": "MongoDB Database index size",
                        "name": "Database index size",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "dbStatsObjects": {
                        "units": "",
                        "fullName": "MongoDB Database objects",
                        "name": "Database objects",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "dbStatsStorageSize": {
                        "units": "",
                        "fullName": "MongoDB Database storage size",
                        "name": "Database storage size",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "dbStatsFileSize": {
                        "units": "MB",
                        "fullName": "MongoDB Database file size",
                        "name": "Database file size",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "dbStatsDataSize": {
                        "units": "MB",
                        "fullName": "MongoDB Database data size",
                        "name": "Database data size",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    }
                },
                "name": "Databases"
            },
            "Asserts": {
                "metrics": {
                    "warningPS": {
                        "units": "/s",
                        "fullName": "MongoDB asserts: Warning",
                        "name": "WarningPS",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "rolloverPS": {
                        "units": "",
                        "fullName": "MongoDB asserts: Rollovers",
                        "name": "RolloverPS",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "userPS": {
                        "units": "/s",
                        "fullName": "MongoDB asserts: User",
                        "name": "UserPS",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "msgPS": {
                        "units": "/s",
                        "fullName": "MongoDB asserts: Msg",
                        "name": "MsgPS",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "regularPS": {
                        "units": "/s",
                        "fullName": "MongoDB asserts: Regular",
                        "name": "RegularPS",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    }
                },
                "name": "Asserts"
            },
            "mR": {
                "units": "/s",
                "fullName": "MongoDB Index miss ratio",
                "name": "Index miss ratio",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "qOps": {
                "units": "/s",
                "fullName": "MongoDB Query operations",
                "name": "Query operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "mIx": {
                "units": "/s",
                "fullName": "MongoDB Index misses",
                "name": "Index misses",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "hIx": {
                "units": "/s",
                "fullName": "MongoDB Index hits",
                "name": "Index hits",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "dOps": {
                "units": "/s",
                "fullName": "MongoDB Delete operations",
                "name": "Delete operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "gOps": {
                "units": "/s",
                "fullName": "MongoDB getmore operations",
                "name": "getmore operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "cOps": {
                "units": "/s",
                "fullName": "MongoDB Command operations",
                "name": "Command operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "uOps": {
                "units": "/s",
                "fullName": "MongoDB Update operations",
                "name": "Update operations",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "bgFlushLengthAvrg": {
                "units": "",
                "fullName": "MongoDB Background flush length",
                "name": "Background flush length",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "bgSecondsSinceLastFlush": {
                "units": "/s",
                "fullName": "MongoDB seconds since last background flush",
                "name": "Seconds since last background flush",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            }
        },
        "name": "MongoDB"
    },
    "iisStatus": {
        "metrics": {
            "rPS": {
                "units": "/s",
                "fullName": "IIS Requests per second",
                "name": "Requests per second",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            }
        },
        "name": "IIS"
    },
    "sqlServer": {
        "metrics": {
            "lRPS": {
                "units": "/s",
                "fullName": "SQLServer lock requests",
                "name": "Lock requests",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "aC": {
                "units": "",
                "fullName": "SQLServer active cursors ",
                "name": "Active cursors",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "txPS": {
                "units": "/s",
                "fullName": "SQLServer transactions",
                "name": "Transactions",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "lFUS": {
                "units": "KB",
                "fullName": "SQLServer log file size (used)",
                "name": "Log file size (used)",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "aWT": {
                "units": "",
                "fullName": "SQLServer average wait time",
                "name": "Average wait time",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "lkWPS": {
                "units": "/s",
                "fullName": "SQLServer lock waits",
                "name": "Lock waits",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "ePS": {
                "units": "/s",
                "fullName": "SQLServer errors",
                "name": "Errors",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "dFS": {
                "units": "KB",
                "fullName": "SQLServer data file size",
                "name": "Data file size",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "numDPS": {
                "units": "/s",
                "fullName": "SQLServer deadlocks",
                "name": "Deadlocks",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "pLU": {
                "units": "%",
                "fullName": "SQLServer log file used",
                "name": "Log file used",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "lkWT": {
                "units": "ms",
                "fullName": "SQLServer lock wait time",
                "name": "Lock wait time",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "lFS": {
                "units": "KB",
                "fullName": "SQLServer log file size",
                "name": "Log file size",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "lTPS": {
                "units": "/s",
                "fullName": "SQLServer lock timeouts",
                "name": "Lock timeouts",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "cMU": {
                "units": "",
                "fullName": "SQLServer cursor memory usage",
                "name": "Cursor memory usage",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "aTx": {
                "units": "",
                "fullName": "SQLServer active transactions",
                "name": "Active transactions",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            }
        },
        "name": "SQLServer"
    },
    "system": {
        "metrics": {
            "diskState": {
                "name": "Disk state",
                "excludeComparisons": ["c", "nc", "re", "nre", "lt", "gt", "lte", "gte"],
                "additionalDropdown": {
                    "length": 9,
                    "label": {
                        "default": "Select..."
                    }
                },
                "fullName": "Attached disk state",
                "availableChoices": ["ready", "failed", "creating", "restoring"],
                "conditions": ["hasDisks"]
            },
            "Process": {
                "metrics": {
                    "processCount": {
                        "name": "Process Count",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "displayMetrics": false,
                        "formatDecimals": 0,
                        "units": "",
                        "fullName": "Process Count"
                    },
                    "processCPU": {
                        "name": "Process CPU Usage",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "displayMetrics": false,
                        "units": "%",
                        "full Name": "Process CPU Usage",
                        "additionalInput": {
                            "length": 9,
                            "label": {
                                "default": "process, e.g: /sbin/init",
                                "windows": "process, e.g: svchost.exe"
                            }
                        }
                    },
                    "processNotRunning": {
                        "units": "",
                        "fullName": "Process list",
                        "name": "Process list",
                        "excludeComparisons": ["lt", "gt", "lte", "gte", "eq", "neq"],
                        "displayMetrics": false
                    },
                    "processMemory": {
                        "name": "Process Memory Usage",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "displayMetrics": false,
                        "units": "%",
                        "full Name": "Process Memory Usage",
                        "additionalInput": {
                            "length": 9,
                            "label": {
                                "default": "process, e.g: /sbin/init ",
                                "windows": "process, e.g: svchost.exe"
                            }
                        }
                    },
                    "processNameCount": {
                        "name": "Process Count by Name",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "displayMetrics": false,
                        "formatDecimals": 0,
                        "units": "",
                        "fullName": "Process Count by Name",
                        "additionalInput": {
                            "length": 9,
                            "label": {
                                "default": "process, e.g: /sbin/init",
                                "windows": "process, e.g: svchost.exe"
                            }
                        }
                    }
                },
                "name": "Process"
            },
            "instanceState": {
                "fullName": "Instance state",
                "availableChoices": ["provisioning", "running", "staging", "stopped", "stopping", "terminated"],
                "name": "Instance state",
                "excludeComparisons": ["c", "nc", "re", "nre", "lt", "gt", "lte", "gte"]
            },
            "ioStats": {
                "metrics": {
                    "rPS": {
                        "units": "/s",
                        "fullName": "I/O - Read requests",
                        "name": "Linux: Read requests",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "wKB": {
                        "units": "KB/s",
                        "fullName": "I/O - Data written",
                        "name": "Linux: Data written",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "aW": {
                        "units": "ms",
                        "fullName": "I/O - Average request time",
                        "name": "Linux: Average request time",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "pU": {
                        "units": "%",
                        "fullName": "I/O - Percentage of CPU time",
                        "name": "Linux: Percentage of CPU time",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "rPSM": {
                        "units": "/s",
                        "fullName": "I/O - Read reqeusts merged",
                        "name": "Linux: Read requests merged",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "aST": {
                        "units": "ms",
                        "fullName": "I/O - Average service time",
                        "name": "Linux: Average service time",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "wPSM": {
                        "units": "/s",
                        "fullName": "I/O - Write requests merged",
                        "name": "Linux: Write requests merged",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "wPS": {
                        "units": "/s",
                        "fullName": "I/O - Write requests",
                        "name": "Linux: Write requests",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "s": {
                        "units": "sectors",
                        "fullName": "I/O - Average request sector size",
                        "name": "Linux: Average request sector size",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "tps": {
                        "units": "/s",
                        "fullName": "I/O - Transfers per second",
                        "name": "Mac: Transfers per second",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "rKB": {
                        "units": "KB/s",
                        "fullName": "I/O - Data read",
                        "name": "Linux: Data read",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "qL": {
                        "units": "",
                        "fullName": "I/O - Average request queue length",
                        "name": "Linux: Average request queue length",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "KBt": {
                        "units": "KB/t",
                        "fullName": "I/O - Kilobytes per transfer",
                        "name": "Mac: Kilobytes per transfer",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "MBs": {
                        "units": "MB/s",
                        "fullName": "I/O - Megabytes per second",
                        "name": "Mac: Megabytes per second",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    }
                },
                "name": "IO stats",
                "additionalInput": {
                    "length": 6,
                    "label": {
                        "default": "Device name",
                        "windows": "Device name"
                    }
                }
            },
            "cpuStats": {
                "metrics": {
                    "guest": {
                        "units": "%",
                        "fullName": "CPU guest",
                        "name": "Guest",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "iowait": {
                        "units": "%",
                        "fullName": "CPU I/O wait",
                        "name": "I/O wait",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "sys": {
                        "units": "%",
                        "fullName": "CPU system level",
                        "name": "System level",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "steal": {
                        "units": "%",
                        "fullName": "CPU steal",
                        "name": "Steal",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "idle": {
                        "units": "%",
                        "fullName": "CPU idle",
                        "name": "Idle",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "usr": {
                        "units": "%",
                        "fullName": "CPU user level",
                        "name": "User level",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "irq": {
                        "units": "",
                        "fullName": "CPU interrupts",
                        "name": "Interrupts",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "soft": {
                        "units": "request",
                        "fullName": "CPU soft irqs",
                        "name": "Soft irqs",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    },
                    "nice": {
                        "units": "",
                        "fullName": "CPU user level nice priority",
                        "name": "User level nice priority",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 2
                    }
                },
                "additionalDropdown": {
                    "length": 6,
                    "emptyOption": {
                        "name": "Any CPU"
                    }
                },
                "name": "CPU stats"
            },
            "loadAvrg": {
                "metrics": {
                    "loadAvrg": {
                        "name": "Load average",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "mapping": "loadAvrg",
                        "formatDecimals": 0,
                        "units": "",
                        "fullName": "Load average"
                    }
                },
                "name": "Load average",
                "displayMetrics": false
            },
            "cpuUtil": {
                "metrics": {
                    "cpuUtil": {
                        "name": "CPU utilization",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "mapping": "cpuUtil",
                        "formatDecimals": 0,
                        "units": "%",
                        "fullName": "CPU utilization"
                    }
                },
                "name": "CPU utilization",
                "displayMetrics": false
            },
            "memory": {
                "metrics": {
                    "memPhysCached": {
                        "name": "Cache used",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "metrics": {
                            "c": {
                                "units": "MB",
                                "name": "Cached",
                                "formatDecimals": 0
                            },
                            "u": {
                                "units": "MB",
                                "name": "Used",
                                "formatDecimals": 0
                            },
                            "f": {
                                "units": "MB",
                                "name": "Free",
                                "formatDecimals": 0
                            }
                        },
                        "displayMetrics": false,
                        "units": "MB",
                        "fullName": "Cached memory used"
                    },
                    "memSwapUsed": {
                        "name": "Swap used",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "metrics": {
                            "u": {
                                "units": "MB",
                                "name": "Used",
                                "formatDecimals": 0
                            },
                            "f": {
                                "units": "MB",
                                "name": "Free",
                                "formatDecimals": 0
                            }
                        },
                        "displayMetrics": false,
                        "units": "MB",
                        "fullName": "Swap memory used"
                    },
                    "memSwapFree": {
                        "name": "Swap free",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "metrics": {
                            "u": {
                                "units": "MB",
                                "name": "Used",
                                "formatDecimals": 0
                            },
                            "f": {
                                "units": "MB",
                                "name": "Free",
                                "formatDecimals": 0
                            }
                        },
                        "displayMetrics": false,
                        "units": "MB",
                        "fullName": "Swap memory free"
                    },
                    "memPhysFree": {
                        "name": "Physical Free",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "metrics": {
                            "c": {
                                "units": "MB",
                                "name": "Cached",
                                "formatDecimals": 0
                            },
                            "u": {
                                "units": "MB",
                                "name": "Used",
                                "formatDecimals": 0
                            },
                            "f": {
                                "units": "MB",
                                "name": "Free",
                                "formatDecimals": 0
                            }
                        },
                        "displayMetrics": false,
                        "units": "MB",
                        "fullName": "Physical memory free"
                    },
                    "memPhysUsed": {
                        "name": "Physical Used",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "metrics": {
                            "c": {
                                "units": "MB",
                                "name": "Cached",
                                "formatDecimals": 0
                            },
                            "u": {
                                "units": "MB",
                                "name": "Used",
                                "formatDecimals": 0
                            },
                            "f": {
                                "units": "MB",
                                "name": "Free",
                                "formatDecimals": 0
                            }
                        },
                        "displayMetrics": false,
                        "units": "MB",
                        "fullName": "Physical memory used"
                    }
                },
                "name": "Memory"
            },
            "diskUsage": {
                "name": "Disk usage",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "metrics": {
                    "cp": {
                        "units": "k",
                        "name": "Capacity",
                        "formatDecimals": 2
                    },
                    "mt": {
                        "units": "",
                        "name": "Mounted on",
                        "formatDecimals": 0
                    },
                    "fs": {
                        "units": "",
                        "fullName": "Disk usage - File system",
                        "name": "File System",
                        "formatDecimals": 0
                    },
                    "us": {
                        "units": "%",
                        "fullName": "Disk usage",
                        "name": "Used",
                        "formatDecimals": 0
                    },
                    "av": {
                        "units": "k",
                        "name": "Available",
                        "formatDecimals": 0
                    }
                },
                "additionalDropdown": {
                    "length": 9,
                    "label": {
                        "default": "Select..."
                    }
                },
                "displayMetrics": false,
                "units": "%"
            }
        },
        "name": "System"
    },
    "rabbitMQ": {
        "metrics": {
            "queues": {
                "metrics": {
                    "msg": {
                        "units": "",
                        "fullName": "RabbitMQ messages",
                        "name": "Messages",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "msgUnack": {
                        "units": "",
                        "fullName": "RabbitMQ messages - unacknowledged",
                        "name": "Messages unacknowledged",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "c": {
                        "units": "",
                        "fullName": "RabbitMQ consumers",
                        "name": "Consumers",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "m": {
                        "units": "MB",
                        "fullName": "RabbitMQ memory - used",
                        "name": "Memory - used",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    },
                    "msgUncom": {
                        "units": "",
                        "fullName": "RabbitMQ messages - uncomitted",
                        "name": "Messages uncommitted",
                        "excludeComparisons": ["c", "nc", "re", "nre"],
                        "formatDecimals": 0
                    }
                },
                "name": "Queues",
                "additionalInput": {
                    "length": 10,
                    "label": {
                        "default": "Queue name"
                    }
                }
            },
            "rabbitmqConn": {
                "name": "Connections",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "displayMetrics": false,
                "formatDecimals": 0,
                "units": "",
                "fullName": "RabbitMQ connections"
            }
        },
        "name": "RabbitMQ"
    },
    "nginx": {
        "metrics": {
            "rPS": {
                "units": "/s",
                "fullName": "Nginx  Requests",
                "name": "Requests per second",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "conn": {
                "units": "",
                "fullName": "Nginx Connections",
                "name": "Nginx connections",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            }
        },
        "name": "Nginx"
    },
    "mysql": {
        "metrics": {
            "maxUsedConn": {
                "units": "/s",
                "fullName": "MySQL max used connections",
                "name": "Max used connections",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "slowQ": {
                "units": "",
                "fullName": "MySQL slow queries",
                "name": "Slow queries",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "threadsConn": {
                "units": "/s",
                "fullName": "MySQL threads connected",
                "name": "Threads connected",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "cTmpDT": {
                "units": "",
                "fullName": "MySQL temporary disk tables created",
                "name": "Temporary disk tables created",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "openF": {
                "units": "",
                "fullName": "MySQL open files",
                "name": "Open files",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "sMasterBehind": {
                "units": "s",
                "fullName": "MySQL seconds behind master",
                "name": "Seconds behind master",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "tLockWait": {
                "units": "table locks",
                "fullName": "MySQL table locks",
                "name": "Table locks",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "conn": {
                "units": "/s",
                "fullName": "MySQL Connections",
                "name": "Connections",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            }
        },
        "name": "MySQL"
    },
    "apache": {
        "metrics": {
            "rPS": {
                "units": "/s",
                "fullName": "Apache requests per second",
                "name": "Requests per second",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "bW": {
                "units": "/s",
                "fullName": "Apache workers busy",
                "name": "Workers busy",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            },
            "iW": {
                "units": "/s",
                "fullName": "Apache workers idle",
                "name": "Workers idle",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 2
            }
        },
        "name": "Apache"
    },
    "noData": {
        "metrics": {
            "device": {
                "noComparisons": true,
                "fullName": "No data received from device",
                "noValue": true,
                "name": "From Device"
            }
        },
        "name": "No Data"
    },
    "networkTraffic": {
        "metrics": {
            "rxMBitS": {
                "name": "Received (Mb/s)",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "mapping": "rxMBitS",
                "formatDecimals": 0,
                "units": "Mb/s",
                "fullName": "Network traffic: Received (Mb/s)",
                "additionalInput": {
                    "length": 13,
                    "label": {
                        "default": "Interface, e.g: eth0"
                    }
                }
            },
            "txMByteS": {
                "name": "Transmitted (MB/s)",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "mapping": "txMByteS",
                "formatDecimals": 0,
                "units": "MB/s",
                "fullName": "Network traffic: Transmitted (MB/s)",
                "additionalInput": {
                    "length": 13,
                    "label": {
                        "default": "Interface, e.g: eth0"
                    }
                }
            },
            "rxMByteS": {
                "name": "Received (MB/s)",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "mapping": "rxMByteS",
                "formatDecimals": 0,
                "units": "MB/s",
                "fullName": "Network traffic: Received (MB/s)",
                "additionalInput": {
                    "length": 13,
                    "label": {
                        "default": "Interface, e.g: eth0"
                    }
                }
            },
            "txMBitS": {
                "name": "Transmitted (Mb/s)",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "mapping": "txMBitS",
                "formatDecimals": 0,
                "units": "Mb/s",
                "fullName": "Network traffic: Transmitted (Mb/s)",
                "additionalInput": {
                    "length": 13,
                    "label": {
                        "default": "Interface, e.g: eth0"
                    }
                }
            }
        },
        "name": "Network traffic"
    }
}

This is all metric parameters for services.

{
    "http": {
        "metrics": {
            "status": {
                "fullName": "Status",
                "availableChoices": ["down", "slow", "up"],
                "name": "Status",
                "excludeComparisons": ["lt", "gt", "lte", "gte", "c", "nc", "re", "nre"]
            },
            "content": {
                "fullName": "HTTP Response body",
                "name": "Response body",
                "excludeComparisons": ["lt", "gt", "lte", "gte", "eq", "neq"],
                "graphable": false
            },
            "code": {
                "units": "",
                "fullName": "HTTP Code",
                "name": "Code",
                "excludeComparisons": ["c", "nc", "re", "nre"],
                "formatDecimals": 0
            },
            "time": {
                "units": "s",
                "fullName": "HTTP Response time",
                "name": "Response time",
                "excludeComparisons": ["c", "nc", "nre", "re", "eq", "neq"],
                "formatDecimals": 0
            }
        },
        "type": "service",
        "name": "HTTP"
    },
    "tcp": {
        "metrics": {
            "status": {
                "fullName": "Status",
                "availableChoices": ["down", "slow", "up"],
                "name": "Status",
                "excludeComparisons": ["lt", "gt", "lte", "gte", "c", "nc", "re", "nre"]
            },
            "content": {
                "fullName": "TCP Response data",
                "name": "Response data",
                "excludeComparisons": ["lt", "gt", "lte", "gte", "eq", "neq"],
                "graphable": false
            },
            "time": {
                "units": "s",
                "fullName": "TCP Response time",
                "name": "Response time",
                "excludeComparisons": ["c", "nc", "nre", "re", "eq", "neq"],
                "formatDecimals": 0
            }
        },
        "type": "service",
        "name": "TCP"
    }
}

Devices and services have different alert metrics which you can configure in the ui. The section correspond to the top-level of the alert metric whereas field correspond to the subsection of the given section.

HTTP Request

GET https://api.serverdensity.io/alerts/device_alerts.json?token=<token>

GET https://api.serverdensity.io/alerts/service_alerts.json?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Metrics

Available metrics

curl -v -X GET "https://api.serverdensity.io/metrics/definitions/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa&start=2013-09-15T17:00:00Z&end=2013-09-15T18:00:00Z"
import requests

subject_id = '523599f19711f423690003e4'

api_response = requests.get(
    'https://api.serverdensity.io/metrics/definitions/{0}'.format(subject_id),
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa',
        'start' : '2013-09-15T17:00:00Z',
        'end': '2013-09-15T18:00:00Z'
    }
)

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'
subject_id = '523599f19711f423690003e4'

params = {:query => {
        'start' => '2013-09-15T17:00:00Z',
        'end' => '2013-09-15T18:00:00Z',
        'token' => token
}
response = HTTParty.get('https://api.serverdensity.io/metrics/definitions/#{subject_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$client->api('metrics')->available($id, time()-7200, time());

?>

Of importance are the key fields, which are used in the Get metrics method to filter the results.

[
    {
        "tree": [
            {
                "name": "CPU0",
                "tree": [
                    {
                        "name": "Soft",
                        "unit": "%",
                        "key": "soft"
                    },
                    {
                        "name": "Guest",
                        "unit": "%",
                        "key": "guest"
                    },
                    {
                        "name": "I\/O Wait",
                        "unit": "%",
                        "key": "iowait"
                    },
                    {
                        "name": "System",
                        "unit": "%",
                        "key": "sys"
                    },
                    {
                        "name": "Idle",
                        "unit": "%",
                        "key": "idle"
                    },
                    {
                        "name": "User",
                        "unit": "%",
                        "key": "usr"
                    },
                    {
                        "name": "Interrupts",
                        "unit": "%",
                        "key": "irq"
                    },
                    {
                        "name": "Steal",
                        "unit": "%",
                        "key": "steal"
                    },
                    {
                        "name": "Nice",
                        "unit": "%",
                        "key": "nice"
                    }
                ],
                "key": "CPU0"
            }
        ],
        "name": "CPU stats",
        "key": "cpuStats"
    },
    {
        "tree": [
            {
                "name": "\/ (\/dev\/xvda1)",
                "tree": [
                    {
                        "name": "Capacity used",
                        "unit": "%",
                        "key": "cp"
                    },
                    {
                        "name": "Used",
                        "unit": "MB",
                        "key": "us"
                    },
                    {
                        "name": "Available",
                        "unit": "MB",
                        "key": "av"
                    }
                ],
                "key": "\/ (\/dev\/xvda1)"
            },
        ],
        "name": "Disk usage",
        "key": "diskUsage"
    },
    {
        "tree": [
            {
                "name": "xvda",
                "tree": [
                    {
                        "name": "Merged write requests",
                        "unit": "requests",
                        "key": "wrqm\/s"
                    },
                    {
                        "name": "Read requests",
                        "unit": "requests",
                        "key": "r\/s"
                    },
                    {
                        "name": "Merged read requests",
                        "unit": "requests",
                        "key": "rrqm\/s"
                    },
                    {
                        "name": "Kilobytes read",
                        "unit": "kB",
                        "key": "rkB\/s"
                    },
                    {
                        "name": "Average I\/O wait",
                        "unit": "requests",
                        "key": "await"
                    },
                    {
                        "name": "Write requests issued",
                        "unit": "requests",
                        "key": "w\/s"
                    },
                    {
                        "name": "Utilisation",
                        "unit": "%",
                        "key": "util"
                    },
                    {
                        "name": "Average queue length",
                        "unit": "requests",
                        "key": "avgqu-sz"
                    },
                    {
                        "name": "Average service time",
                        "unit": "requests",
                        "key": "svctm"
                    },
                    {
                        "name": "Kilobytes written",
                        "unit": "kB",
                        "key": "wkB\/s"
                    },
                    {
                        "name": "Average read time",
                        "unit": "requests",
                        "key": "r_await"
                    },
                    {
                        "name": "Average sector size request",
                        "unit": "sectors",
                        "key": "avgrq-sz"
                    },
                    {
                        "name": "Average write time",
                        "unit": "request",
                        "key": "w_await"
                    }
                ],
                "key": "xvda"
            }
        ],
        "name": "IO stats",
        "key": "ioStats"
    },
    {
        "name": "Load average",
        "unit": false,
        "key": "loadAvrg"
    },
    {
        "key": "memory",
        "name": "Memory",
        "tree": [
            {
                "name": "Cached used",
                "unit": "MB",
                "key": "memPhysCached"
            },
            {
                "name": "Physical free",
                "unit": "MB",
                "key": "memPhysFree"
            },
            {
                "name": "Physical used",
                "unit": "MB",
                "key": "memPhysUsed"
            },
            {
                "name": "Swap free",
                "unit": "MB",
                "key": "memSwapFree"
            },
            {
                "name": "Swap used",
                "unit": "MB",
                "key": "memSwapUsed"
            }
        ]
    },
    {
        "tree": [
            {
                "name": "eth0",
                "tree": [
                    {
                        "name": "Received bits",
                        "unit": "b",
                        "key": "rxMBitS"
                    },
                    {
                        "name": "Transmitted bits",
                        "unit": "b",
                        "key": "txMBitS"
                    },
                    {
                        "name": "Received MBs",
                        "unit": "MB",
                        "key": "rxMByteS"
                    },
                    {
                        "name": "Transmitted MBs",
                        "unit": "MB",
                        "key": "txMByteS"
                    }
                ],
                "key": "eth0"
            }
        ],
        "name": "Network traffic",
        "key": "networkTraffic"
    },
    {
        "name": "Processes",
        "unit": false,
        "key": "processes"
    }
]

Determine which metrics are available to return historical data for, for a specific subject (device or service) over a specific time range.

HTTP Request

GET https://api.serverdensity.io/metrics/definitions/subjectId?start=YYYY-MM-DDTHH:MM:SSZ&end=YYYY-MM-DDTHH:MM:SSZ&token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
subjectId Yes string The ID of the subject to get the definitions for, e.g. a device ID.
start Yes string The UTC date string for the start time range in format YYYY-MM-DDTHH:MM:SSZ e.g. 2013-09-15T00:00:00Z
end Yes string The UTC date string for the end time range in format YYYY-MM-DDTHH:MM:SSZ e.g. 2013-09-15T23:59:59Z

Get metrics

# Filter by network traffic, eth0, received MB/s

curl -v -X GET https://api.serverdensity.io/metrics/graphs/523599f19711f423690003e4?token=b97da80a41c4f61bff05975ee51eb1aa\&start=2013-09-15T17:00:00Z\&end=2013-09-15T18:00:00Z\&filter='\{"networkTraffic":\{"eth0":\["rxMByteS"\]\}\}'
# Filter by network traffic, eth0, received MB/s

import json
from datetime import datetime, timedelta

import requests

subject_id = '523599f19711f423690003e4'
token = 'b97da80a41c4f61bff05975ee51eb1aa'

# get start and end date via datetime
start = datetime.now() - timedelta(seconds=600)
end = datetime.now()

# build a filter
# eth0 rxMBytesS
filter = {
    'networkTraffic': {
        'eth0': ['rxMByteS']
    }
}

api_response = requests.get(
    'https://api.serverdensity.io/metrics/graphs/{0}'.format(subject_id),
    params={
        'token': token,
        'start' : start.isoformat(),
        'end': end.isoformat(),
        'filter': json.dumps(filter)
    }
)

require "httparty"
token = 'b97da80a41c4f61bff05975ee51eb1aa'
subject_id = '523599f19711f423690003e4'

params = {:query => {
        'start' => '2013-09-15T17:00:00Z',
        'end' => '2013-09-15T18:00:00Z',
        'token' => token,
        'filter' => JSON.dump({
            'networkTraffic' => {
                'eth0' => ['rxMByteS']
            }
        })
}
response = HTTParty.get('https://api.serverdensity.io/metrics/definitions/#{subject_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = "76oeu57a5765a76e5a7";

$filter = array('networkTraffic' => [
        'eth0' => ['rxMByteS']
    ]
);

$client->api('metrics')->metrics($id, $filter, time()-7200, time());

?>

The response will be values for the x (Unix timestamp) and y (value) axis.

[
    {
        "name": "Network traffic",
        "key": "networkTraffic",
        "tree": [
            {
                "name": "eth0",
                "tree": [
                    {
                        "name": "Received MBs",
                        "unit": false,
                        "data": [
                            {
                                "x": 1379268526,
                                "y": 0.001953125
                            },
                            {
                                "x": 1379268585,
                                "y": 0.0034505208333333
                            },
                            {
                                "x": 1379268645,
                                "y": 0.0017903645833333
                            },
                            {
                                "x": 1379268709,
                                "y": 0.0018880208333333
                            },
                            {
                                "x": 1379268769,
                                "y": 0.00166015625
                            },
                        ]
                    }
                ]
            }
        ]
    }
]

Return historical metrics data, for a specific subject (device or service) over a specific time range.

HTTP Request

GET https://api.serverdensity.io/metrics/graphs/subjectId?start=YYYY-MM-DDTHH:MM:SSZ&end=YYYY-MM-DDTHH:MM:SSZ&filter=filter&token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
subjectId Yes string The ID of the subject to get the definitions for, e.g. a device ID or service ID.
start Yes string The UTC date string for the start time range in format YYYY-MM-DDTHH:MM:SSZ e.g. 2013-09-15T00:00:00Z
end Yes string The UTC date string for the end time range in format YYYY-MM-DDTHH:MM:SSZ e.g. 2013-09-15T23:59:59Z

Parameters: Filter

For device IDs these are the following parameters you can filter at a top level. The filter allows you to return a specific metric (e.g. network traffic), filtered further by a item (e.g. eth0) and sub metric (received MB/s). Please refer to the response given at Available metrics if you need to filter further than that.

Parameter Description
cpuStats CPU statistics
diskUsage Disk usage
ioStats IO statistics
loadAvrg The Average load
memory Amount of memory use
networkTraffic Network bandwidth
processes The amount processes running

Devices: Load average

{
    "loadAvrg": "all"
}

Devices: All network traffic metrics

{
    "networkTraffic": "all"
}

Devices: Filter by network traffic, received MB/s

{
    "networkTraffic": [
        "rxMByteS"
    ]
}

Devices: Filter by network traffic, eth0, received MB/s

{
    "networkTraffic": {
        "eth0": [
            "rxMByteS"
        ]
    }
}

Services: Filter by response time, all locations

{
    "time": "all"
}

Services: Filter by response time, Tokyo location

{
    "time": "tyo"
}

Response Parameters

The response is a list of dictionaries. Each dictionary represents one of the parameters that you can filter on. The key tree let’s you access one level deeper in the structure.

Service Status

Overall Status (meta)

curl -v -X GET https://api.serverdensity.io/service-monitor/meta/5241a3cbdba4bbb8100002a1/?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
service_id = '5241a3cbdba4bbb8100002a1'

api_response = requests.get(
    'https://api.serverdensity.io/service-monitor/meta/{0}'.format(service_id),
    params={'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
service_id = '5241a3cbdba4bbb8100002a1'

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/service-monitor/meta/#{service_id}', params)

response.to_json

The response will be a JSON encoded hash containing the meta data and status for the service check.

{
  "currentStatus": "up",
  "metrics": {
    "status": 1.0,
    "time": 0.30260759999999987
  },
  "serviceId": "5241a3cbdba4bbb8100002a1",
  "createdAt": "2013-09-24T14:38:03",
  "updatedAt": "2013-09-24T16:06:57.639000"
}

Get the overall status for a service check.

HTTP Request

GET /service-monitor/meta/<serviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string the ID of the service to retrieve the details for.

Response parameters

Parameters Type Description
currentStatus string Whether the service is up or down
metrics dictionary a dictionary of status and time
metrics > status float The percentage of uptime for the service
metrics > time float The average response time for the service.

Location Service Status (last)

Get the current results from a service check.

curl -v -X GET https://api.serverdensity.io/service-monitor/last/5241a3cbdba4bbb8100002a1/?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
service_id = '5241a3cbdba4bbb8100002a1'

api_response = requests.get(
    'https://api.serverdensity.io/service-monitor/last/{0}'.format(service_id),
    params={'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
service_id = '5241a3cbdba4bbb8100002a1'

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/service-monitor/last/#{service_id}', params)

response.to_json

The response will be a JSON encoded list of the details for the requested service, including individual location response times.

[
  {
    "_id": "5241a65b8dd13a0eb6b9bf88",
    "_rtt": 3.254435,
    "accountId": "4fa3c6ef22257d6c2f000000",
    "code": 200,
    "content": "92c6852fd45a084b4c04ec7232d7b092",
    "createdAt": "2013-09-24T14:48:56.627000",
    "error": null,
    "headers": {
      "Connection": "close",
      "Content-Encoding": "gzip",
      "Content-Length": "3970",
      "Content-Type": "text/html; charset=UTF-8",
      "Date": "Tue, 24 Sep 2013 14:49:00 GMT",
      "Server": "Apache",
      "Set-Cookie": "landing=CM8n9FJXla01e91pbzepdThtUhjYRg6XlMCfT6P0k4-BewzH6xWQmtwOrBrH0LSf7p-4hM1GMSoXmtT52PgUVxZ96GMgnznj2-v5SHv_fuY.; expires=Wed, 24-Sep-2014 14:49:00 GMT; path=/",
      "Vary": "Accept-Encoding",
      "X-Ua-Compatible": "IE=edge,chrome=1"
    },
    "location": "man-34s",
    "location_node": "localhost",
    "service": {},
    "serviceId": "5241a3cbdba4bbb8100002a1",
    "status": "up",
    "success": true,
    "time": 0.293897,
    "type": "http",
    "updatedAt": "2013-09-24T14:48:59.881000"
  },
]

HTTP Request

GET /service-monitor/last/<serviceId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
serviceId Yes string the ID of the service to retrieve the details for.

Response Parameters

Parameters Type Description
_id string The ID of the service
rtt float This is the round trip time for the service in seconds.
accountId string The account to which the service belongs to.
code int HTTP status code for the website the service checks.
content string Body of the request that is being sent
createdAt string Time when service was created
error string If there was an error, what kind of error appears here.
headers dictionary The headers that the request sent to the service.
location string The location from the request is being sent.
location_node string The actual server from the request is being sent.
service dictionary Contains all the details about the service check.
status string Whether the website is up or not at the last check.
success bool Whether the service succeeded in accessing website.
time float This is the response time in seconds.
type string Type of request, either HTTP or TCP.
updatedAt string When service was last updated.

Users

Creating a user

curl -v https://api.serverdensity.io/users/users/?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data admin=false \
     --data firstName=Llama \
     --data lastName=Hat \
     --data login=llama \
     --data password=biu687ftg \
     --data emailAddresses='["hello@serverdensity.com"]' \
     --data phoneNumbers='["+16464194674"]'
import json
import requests

api_response = requests.post(
    'https://api.serverdensity.io/users/users',
    params={'token': token},
    data={
        'admin': False,
        'firstName': 'Llama',
        'lastName': 'Hat',
        'login': 'llama',
        'password': 'biu687ftg',
        'emailAddresses': json.dumps(['hello@serverdensity.com']),
        'phoneNumbers': json.dumps(['+16464194674']),
        'permissions': json.dumps({
                "tags": {"548984f976d377a53d459be4": {
                    "mode": "read"
                }}
            })
    }
)
require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {
    :query => {"token" => token},
    :body => {
        'admin' => false,
        'firstName' => 'Llama',
        'lastName' => 'Hat',
        'login' => 'llama',
        'password' => 'biu687ftg',
        'emailAddresses' => JSON.dump(['hello@serverdensity.com']),
        'phoneNumbers' => JSON.dump(['+16464194674']),
        'permissions': JSON.dump({
        "tags" => {"548984f976d377a53d459be4" => {
            "mode" => "read"}}
        })
    }
}

response = HTTParty.post("http://api.serverdensity.io/users/users", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$user = array(
    'admin' => false,
    'firstName' => 'Llama',
    'lastName' => 'Hat',
    'login' => 'llama',
    'password' => 'biu687ftg',
    'emailAddresses' => ['hello@serverdensity.com'],
    'phoneNumbers' => ['+16464194674'],
);

$client->api('users')->create($user, ['my', 'tags']);

?>

HTTP Request

POST /users/users?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
admin Yes bool Admin user or not.
firstName Yes string User first name.
lastName Yes string User last name.
login Yes string Username for login
password Yes string Password for login
emailAddresses Yes JSON list JSON list of e-mail addresses.
phoneNumbers Yes JSON list JSON list of phone numbers in international format with country code.
permissions No dict A dictionary that contains the key tags, tags itself is a dictionary that contains the tag IDs. Each tag ID is a dictionary with a key mode and value read

Response Parameters

The response will be a JSON encoded hash representing the user, including the fields that have been created.

{
    "admin": false,
    "firstName": "Llama",
    "lastName": "Hat",
    "login": "llama",
    "emailAddresses": [
        "hello@serverdensity.com"
    ],
    "phoneNumbers": [
        " 16464194674"
    ],
    "gravatar": "http://www.gravatar.com/avatar/abc013bd0be76d8d25656c3ab7bd1fa2",
    "updatedAt": "2013-11-05T13:43:17",
    "createdAt": "2013-11-05T13:43:17",
    "_id": "5278f5f576d3774043000000",
    "permissions": {
        "tags": {"548984f976d377a53d459be4": {
            "mode": "read"
        }}
    }
}

Please refer to listing all users to see all response parameters.

Deleting a user

curl -v -X DELETE https://api.serverdensity.io/users/users/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
user_id = '5278f5f576d3774043000000'

delete_response = requests.delete(
    "https://api.serverdensity.io/users/users/{0}".format(user_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
user_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete(
    "https://api.serverdensity.io/users/users/#{user_id}", 
    params
)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = '32465e65a65eu6a5465aoe'

$client->api('users')->delete($id, ['my', 'tags']);

?>

The response is a JSON encoded hash containing the ID of the user that has been deleted.

{
    "_id": "5278f5f576d3774043000000"
}

 HTTP Request

DELETE /users/users/<userId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
userId Yes string The ID of the user to delete

Response parameters

Parameters Type Description
_id string The ID of the user that got deleted.

Listing all users

curl -v -X GET https://api.serverdensity.io/users/users?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

requests.get(
    'https://api.serverdensity.io/users/users',
    params = {'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/users', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('users')->all();

?>

Get a list of every user on your account.

HTTP Request

GET /users/users?token=<token>

Request Parameters

Response Parameters

This will return a json encoded list of the users in your account.

[
    {
        "_id": "5278f5f576d3774043000000",
        "admin": false,
        "createdAt": "2013-11-05T13:43:17",
        "emailAddresses": [
            "hello@serverdensity.com"
        ],
        "firstName": "Llama",
        "gravatar": "http://www.gravatar.com/avatar/abc013bd0be76d8d25656c3ab7bd1fa2",
        "lastName": "Hat",
        "login": "llama",
        "phoneNumbers": [
            " 16464194674"
        ],
        "updatedAt": "2013-11-05T13:43:17",
        "permissions": {
            "tags": {"548984f976d377a53d459be4": {
                "mode": "read"
            }}
        }
    }
]
Parameters Type Description
admin bool Admin user or not.
firstName string User first name.
lastName string User last name.
login string Username for login
password string Password for login
emailAddresses JSON list JSON list of e-mail addresses.
phoneNumbers JSON list JSON list of phone numbers in international format with country code.
gravatar string The Gravatar that is tied to your email address.
updatedAt string When the user was last updated
createdAt string When the user was created
_id string The ID of the user
permissions dict A dictionary that contains the key tags, tags itself is a dictionary that contains the tag IDs. Each tag ID is a dictionary with a key mode and value read

Updating a user

curl -v -X PUT https://api.serverdensity.io/users/users/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data firstName=James
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
user_id = '5278f5f576d3774043000000'

api_response = requests.put(
    'https://api.serverdensity.io/users/users/{0}'.format(user_id),
    params={'token': token},
    data={"firstName": "James"}
)
require "httparty"
require 'json'

token = "b97da80a41c4f61bff05975ee51eb1aa"
user_id = '5278f5f576d3774043000000'

params = {
    :query => {"token" => token},
    :body => {
        "firstName" => "James"
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/users/users/#{user_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$user = array(
    'name' => 'Changed llama'
);
$id = 'e6o5a65oe6e5o6ae4a'
$client->api('users')->update($id, $user);

?>

The response will be a JSON encoded hash representing the updated fields on the device.

{
    "firstName": "James",
    "updatedAt": "2013-11-05T13:53:51",
    "_id": "5278f5f576d3774043000000"
}

HTTP Request

PUT /users/users/<userId>?token=<token>

Request Parameters

Please refer to listing all users to see all response parameters.

Viewing a user

curl -v -X GET https://api.serverdensity.io/users/users/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

user_id = '5278f5f576d3774043000000'

api_response = requests.get(
    'https://api.serverdensity.io/users/users/{0}'.format(user_id),
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
user_id = '5278f5f576d3774043000000'

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/users/#{user_id}', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = 'e6o5a65oe6e5o6ae4a'
$client->api('users')->view($id);

?>

HTTP Request

GET /users/users/<userId>?token=<token>

Response Parameters

Response Parameters

The response is a JSON encoded hash containing the data for the user.

{
    "_id": "5278f5f576d3774043000000",
    "admin": false,
    "createdAt": "2013-11-05T13:43:17",
    "emailAddresses": [
        "hello@serverdensity.com"
    ],
    "firstName": "Llama",
    "gravatar": "http://www.gravatar.com/avatar/abc013bd0be76d8d25656c3ab7bd1fa2",
    "lastName": "Hat",
    "login": "llama",
    "phoneNumbers": [
        " 16464194674"
    ],
    "updatedAt": "2013-11-05T13:43:17",
    "permissions": {
        "tags": {"548984f976d377a53d459be4": {
            "mode": "read"
        }}
    }
}

Please refer to listing all users to see all response parameters.

Postbacks

Creating a postback

# Example 1: Network traffic request

curl -X POST https://api.serverdensity.io/alerts/postbacks?token=b97da80a41c4f61bff05975ee51eb1aa \
    --data hash=be8c0635f5fdd4da4f0573601a67a9e4 \
    --data payload='{"agentKey": "23ddab267dff7cde05dc20a28e93c272", "os": "linux", "networkTraffic": {"lo": {"trans_bytes": "0", "recv_bytes": "0"}, "eth0": {"trans_bytes": "25603", "recv_bytes": "5861"}}}' \
    --header "X-Forwarded-Host: example.serverdensity.io"
# Example 2: Custom metrics request
# Custom metrics are sent as "plugins". Take a look at our guide on sending custom data [1] if you have any problems here.
# 1. https://support.serverdensity.com/hc/en-us/articles/203958073

curl -X POST https://api.serverdensity.io/alerts/postbacks?token=b97da80a41c4f61bff05975ee51eb1aa \
    --data hash=3cb14ab69c100a7c077c40bffce48424 \
    --data payload='{"agentKey": "23ddab267dff7cde05dc20a28e93c272", "plugins": {"MyCustomMetric": {"key1": "1", "key2": "true"}, "AnotherCustomMetric": {"Cheese": "25603", "StringValue": "yes"}}}' \
    --header "X-Forwarded-Host: example.serverdensity.io"
# Example 1: Network traffic request

import json
from hashlib import md5

import requests

payload = json.dumps({
    "agentKey": "23ddab267dff7cde05dc20a28e93c272",
    "os": "linux",
    "networkTraffic": {
        "lo": {"trans_bytes": "0", "recv_bytes": "0"},
        "eth0": {"trans_bytes": "25603", "recv_bytes": "5861"}
    }
})
payload_hash = md5(payload).hexdigest()
headers = {'X-Forwarded-Host': 'example.serverdensity.io'}

api_response = requests.post(
    'https://api.serverdensity.io/alerts/postbacks',
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'},
    data={
        'hash': payload_hash,
        'payload': payload,
    },
    headers=headers
)
# Example 1: Network traffic request

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

payload = JSON.dump({
    "agentKey" => "23ddab267dff7cde05dc20a28e93c272",
    "os" => "linux",
    "networkTraffic" => {
        "lo" => {"trans_bytes" => "0", "recv_bytes" => "0"},
        "eth0" => {"trans_bytes" => "25603", "recv_bytes" => "5861"}
    }
})
payload_hash = Digest::MD5.hexdigest(payload)

params = {
    :query => {"token" => token},
    :body => {
        "hash" => payload_hash,
        "payload" => payload
    },
    :headers => headers = {'X-Forwarded-Host' => 'example.serverdensity.io'}
}

response = HTTParty.post("https://api.serverdensity.io/alerts/postbacks", params)

response.to_json
# Example 2: Custom metrics request
# Custom metrics are sent as "plugins". Take a look at our guide on sending custom data [1] if you have any problems here.
# 1. https://support.serverdensity.com/hc/en-us/articles/203958073

import json
from hashlib import md5

import requests

payload = json.dumps({
    "agentKey": "23ddab267dff7cde05dc20a28e93c272",
    "plugins": {
        "MyCustomMetric": {"key1": "1", "key2": "true"},
        "AnotherCustomMetric": {"Cheese": "25603", "StringValue": "yes"}
    }
})
payload_hash = md5(payload).hexdigest()
headers = {'X-Forwarded-Host': 'example.serverdensity.io'}

api_response = requests.post(
    'https://api.serverdensity.io/alerts/postbacks',
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'},
    data={
        'hash': payload_hash,
        'payload': payload,
    },
    headers=headers
)
# Example 2: Custom metrics request
# Custom metrics are sent as "plugins". Take a look at our guide on sending custom data [1] if you have any problems here. 
# 1. https://support.serverdensity.com/hc/en-us/articles/203958073

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

payload = JSON.dump({
    "agentKey" => "23ddab267dff7cde05dc20a28e93c272",
    "plugins" => {
        "MyCustomMetric" => {"key1" => "1", "key2" => "true"},
        "AnotherCustomMetric" => {"Cheese" => "25603", "StringValue" => "yes"}
    }
})
payload_hash = Digest::MD5.hexdigest(payload)

params = {
    :query => {"token" => token},
    :body => {
        "hash" => payload_hash,
        "payload" => payload
    },
    :headers => headers = {'X-Forwarded-Host' => 'example.serverdensity.io'}
}

response = HTTParty.post("https://api.serverdensity.io/alerts/postbacks", params)

response.to_json

You can use this method to post data back to Server Density without using the agent, for example using your own scripts or to integrate in something custom you are doing. You will still be restricted to posting back once per minute using this method, as you would be using the agent.

HTTP Request

POST /alerts/postbacks?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
payload Yes JSON list The payload you want to post back to us. Must contain the agentKey for the device to send the data to.
hash Yes string An md5 hash of the JSON encoded payload, used for error checking.
X-Forwarded-Host Yes string Set this to your Server Density account url, e.g. example.serverdensity.io

The response will either be a string of ‘OK’ on success, or a JSON encoded hash with error messages.

{
    "message":"bad_request",
    "errors":
        [
            {
                "type":"hash_mismatch",
                "message":"Unable to process payload due to mismatch in hash"
            }
        ]
    }

Dashboards

Creating a new dashboard

curl -v https://api.serverdensity.io/users/dashboards/?token=b97da80a41c4f61bff05975ee51eb1aa \
  --data name=dashname
import json
import requests

api_response = requests.post(
    'http://api.serverdensity.io/users/dashboards',
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    },
    data={
        'name': 'dashname',
    }
)

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

params = {
    :query => {"token" => token},
    :body => {
      "name" => "dashname"
    }
}

response = HTTParty.post("http://api.serverdensity.io/users/dashboards", params)

response.to_json

HTTP Request

POST /users/dashboards?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
name Yes string Name of the dashboard.
layout No dictionary Dictionary with the ids of the widgets from this dashboard as keys. The values are objects with 3 values: col (column), row (row), size_x (size in the x axis, from 1 to 6)

Response parameters

The response will be the created dashboard as a json object.

{
  "name":"dashname",
  "accountId":"4fa3c6ef22257d6c2f000000",
  "_id":"545742cfd4d3680e0a3348a9"
}

Please refer to listing all dashboards to see response parameters.

Deleting a dashboard

curl -v -X DELETE https://api.serverdensity.io/users/dashboards/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
dashboard_id = '5278f5f576d3774043000000'

delete_response = requests.delete(
    "https://api.serverdensity.io/users/dashboards/{0}".format(dashboard_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
dashboard_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete(
    "https://api.serverdensity.io/users/dashboards/#{dashboard_id}", 
    params
)

response.to_json

HTTP Request

DELETE /users/dashboards/<dashboardId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
dashboardId Yes string The ID of the dashboard to delete

Response parameters

The response is a JSON encoded hash containing the ID of the dashboard that has been deleted.

{
    "_id": "5278f5f576d3774043000000"
}
Parameters Type Description
_id string The ID of the dashboard that got deleted.

List all dashboards

Get a list of every dashboard on your account.

curl -v -X GET https://api.serverdensity.io/users/dashboards?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

requests.get(
    'https://api.serverdensity.io/users/dashboards',
    params = {'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/dashboards', params)

response.to_json

HTTP Request

GET /users/dashboards?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

This will return a json encoded list of the dashboards in your account.

[
  {
    "_id": "532c054495fe352d6d84b9e7",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "layout": {
      "5451159395fe35d3055f60df": {
        "col": 1,
        "row": 1,
        "size_x": 6
      }
    },
    "name": "dash",
    "timeRange": {
      "from": "2014-03-21T08:24:18Z",
      "to": "2014-03-21T09:24:18Z",
      "timePreset": {
        "key": "1 hour ago"
      }
    }
  },
  {
    "_id": "5457a1fad998d12f038b4567",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "layout": {
      "5457a1ff95fe35c63174751f": {
        "col": 1,
        "row": 1,
        "size_x": 2
      }
    },
    "name": "dash2"
  }
]
Parameters Type Description
name string The name of the dashboard.
accountId string The account to which the dashboard belongs.
_id string The ID of the dashboard.
layout dict Dictionary with the ids of the widgets from this dashboard as keys. The values are objects with 3 values: col (column), row (row), size_x (size in the x axis, from 1 to 6)

Updating a dashboard

curl -v -X PUT https://api.serverdensity.io/users/dashboards/54525649d4d368e620334887?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data name=mynewdashboard2
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
dashboard_id = '5278f5f576d3774043000000'

api_response = requests.put(
    'https://api.serverdensity.io/users/dashboards/{0}'.format(dashboard_id),
    params={'token': token},
    data={"name": "mynewdashboard2"}
)
require "httparty"
require 'json'

token = "b97da80a41c4f61bff05975ee51eb1aa"
dashboard_id = '5278f5f576d3774043000000'

params = {
    :query => {"token" => token},
    :body => {
        "name" => "mynewdashboard2"
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/users/dashboards/#{dashboard_id}", params)

response.to_json

The response will be the new dashboard json representation

{
    "name": "mynewdashboard2",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "_id": "54525649d4d368e620334887"
}

HTTP Request

PUT /users/dashboards/<dashboardId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
dashboardId Yes string The ID of the dashboard to update.
name No string Name of the dashboard.
layout No Dictionary Dictionary with the ids of the widgets from this dashboard as keys. The values are objects with 3 values: col (column), row (row), size_x (size in the x axis, from 1 to 6)

Response Parameters

Please refer to listing all dashboards to see response parameters.

Viewing a dashboard

curl -v -X GET https://api.serverdensity.io/users/dashboards/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

dashboard_id = '5278f5f576d3774043000000'

api_response = requests.get(
    'https://api.serverdensity.io/users/users/{0}'.format(dashboard_id),
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
dashboard_id = '5278f5f576d3774043000000'

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/users/#{dashboard_id}', params)

response.to_json

The response is a JSON encoded hash containing the data for the dashboard.

{
  "_id": "532c054495fe352d6d84b9e7",
  "accountId": "4fa3c6ef22257d6c2f000000",
  "layout": {
    "5451159395fe35d3055f60df": {
      "col": 1,
      "row": 1,
      "size_x": 6
    }
  },
  "name": "dash",
  "timeRange": {
    "from": "2014-03-21T08:24:18Z",
    "to": "2014-03-21T09:24:18Z",
    "timePreset": {
      "key": "1 hour ago"
    }
  }
}

HTTP Request

GET /users/dashboards/<dashboardId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
dashboardId Yes string The ID of the dashboard to update.

Response Parameters

Please refer to listing all dashboards to see response parameters.

Widgets

Creating a widget

curl -v https://api.serverdensity.io/users/widgets/?token=b97da80a41c4f61bff05975ee51eb1aa \
  --data type=elasticGraph
  --data dashboardId=5457a1fad998d12f038b4567
import json
import requests

api_response = requests.post(
    'http://api.serverdensity.io/users/widgets',
    params={
        'token': 'b97da80a41c4f61bff05975ee51eb1aa'
    },
    data={
        'type': 'elasticGraph',
        'dashboardId': '5457a1fad998d12f038b4567'
    }
)

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

params = {
    :query => {"token" => token},
    :body => {
      "type" => "elasticGraph",
      "dashboardId" => "5457a1fad998d12f038b4567"
    }
}

response = HTTParty.post("http://api.serverdensity.io/users/widgets", params)

response.to_json

The response will be the created widget as a json object.

{
  "_id": "5457b3b495fe35d54d747520",
  "type": "elasticGraph",
  "dashboardId": "5457a1fad998d12f038b4567",
  "accountId": "4fa3c6ef22257d6c2f000000"
}

HTTP Request

POST /users/widgets?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
dashboardId Yes string ID of the dashboard this widget belongs to.
type Yes string Type of widget. See table below for allowed values.
config Yes string Configuration of widget. See the full details of how to configure a widget
Widget Description
cloudStatus Status of some cloud vendors
elasticGraph Graph widget with time series data that dynamically selects the devices/services that will be displayed based on a search term
graph Graph widget with time series data
openAlerts Open alerts from the selected device/service/group
rss RSS feed
serviceStatus Display the current status of one of your service checks

Response Parameters

Please check response parameters at listing widgets

Deleting a widget

curl -v -X DELETE https://api.serverdensity.io/users/widgets/5278f5f576d3774043000000?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
widget_id = '5278f5f576d3774043000000'

delete_response = requests.delete(
    "https://api.serverdensity.io/users/widgets/{0}".format(widget_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
widget_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete(
    "https://api.serverdensity.io/users/widgets/#{widget_id}", 
    params
)

response.to_json

 HTTP Request

DELETE /users/widgets/<widgetId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
widgetId Yes string The ID of the widget to delete.

Response Parameters

The response is a JSON encoded hash containing the ID of the widget that has been deleted.

{
    "_id": "5278f5f576d3774043000000"
}
Parameters Type Description
_id string The ID of the user that got deleted.

Listing all widgets

curl -v -X GET https://api.serverdensity.io/users/widgets?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

requests.get(
    'https://api.serverdensity.io/users/widgets',
    params = {'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/widgets', params)

response.to_json

This will return a json encoded list of the widgets in your account.

[
  {
    "_id": "5457a1ff95fe35c63174751f",
    "accountId": "4fa3c6ef22257d6c2f000000",
    "config": {
      "providerId": "joyent",
      "feedUrl": "https:\/\/help.joyent.com\/forums\/20715782-Current-System-Status\/posts.rss"
    },
    "dashboardId": "5457a1fad998d12f038b4567",
    "type": "cloudStatus"
  },
  {
  "_id": "1457a1ff95fe35c63174751f",
  "accountId": "4fa3c6ef22257d6c2f000000",
  "config": {
    "providerId": "joyent",
    "feedUrl": "https:\/\/help.joyent.com\/forums\/20715782-Current-System-Status\/posts.rss"
  },
  "dashboardId": "5457a1fad998d12f038b4567",
  "type": "cloudStatus"
  },
]

Get a list of every widget on your account.

Http Request

GET /users/widgets?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response Parameters

Parameters Type Description
_id string The id of the widget
type string The type of graph.
dashboardId string The dashboard to which the widget belongs
accountId string The account to which the widget belongs
config dict Configuration options, refer to the section of how to configuring the widget to read more

Updating a widget

curl -v -X PUT https://api.serverdensity.io/users/widgets/5457a1ff95fe35c63174751f?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data type=rss
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
widget_id = '5457a1ff95fe35c63174751f'

api_response = requests.put(
    'https://api.serverdensity.io/users/widgets/{0}'.format(widget_id),
    params={'token': token},
    data={"type": "rss"}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
widget_id = '5278f5f576d3774043000000'

params = {
    :query => {"token" => token},
    :body => {
        "type" => "rss"
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/users/widgets/#{widget_id}", params)

response.to_json

The response will be the new widget json representation

{
  "_id": "5457a1ff95fe35c63174751f",
  "accountId": "532c053395fe35876a84b9e7",
  "config": {
    "providerId": "joyent",
    "feedUrl": "https://help.joyent.com/forums/20715782-Current-System-Status/posts.rss"
  },
  "dashboardId": "5457a1fad998d12f038b4567",
  "type": "rss"
}

HTTP Request

PUT /users/widgets/<widgetId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
widgetId Yes string The ID of the widget to update.
dashboardId No string ID of the dashboard this widget belongs to.
type No string Type of widget. See table below for allowed values.
config No string Configuration of widget. See the full details of how to configure a widget
Widget Description
cloudStatus Status of some cloud vendors
elasticGraph Graph widget with time series data that dynamically selects the devices/services that will be displayed based on a search term
graph Graph widget with time series data
openAlerts Open alerts from the selected device/service/group
rss RSS feed
serviceStatus Display the current status of one of your service checks

Viewing a widget

curl -v -X GET https://api.serverdensity.io/users/widgets/5457a1ff95fe35c63174751f?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

widget_id = '5457a1ff95fe35c63174751f'

api_response = requests.get(
    'https://api.serverdensity.io/users/widgets/{0}'.format(widget_id),
    params={'token': 'b97da80a41c4f61bff05975ee51eb1aa'}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
widget_id = '5457a1ff95fe35c63174751f'

params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/users/widgets/#{widget_id}', params)

response.to_json

The response is a JSON encoded hash containing the data for the widget.

{
  "_id": "5457a1ff95fe35c63174751f",
  "accountId": "532c053395fe35876a84b9e7",
  "config": {
    "providerId": "joyent",
    "feedUrl": "https://help.joyent.com/forums/20715782-Current-System-Status/posts.rss"
  },
  "dashboardId": "5457a1fad998d12f038b4567",
  "type": "cloudStatus"
}

HTTP Request

GET /users/widgets/<widgetId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
widgetId Yes string The ID of the widget to update.

Response Parameters

Please check response parameters at listing widgets

Configuring a widget

Widget json objects have a config field where the widget configuration is stored. The configuration depends on the widget type. This different configuration variants are described in this document.

cloudStatus - config

This widget type shows the status of some cloud vendors

Config Parameters
Parameters Description
providerId Name of the provider
amazon
digitalOcean
google
joyent
linode
rackspace
salesforce
softlayer
windowsAzure
feedUrl Url of the news feed. The feed needs to be one of the specified in the annexexes section. If the feed you wish to use is not in this list you should use an RSS widget, which can be configured with any feed.

elasticGraph - config

This widget shows time series data from a list of devices or services dynamically generated

Config Parameters

Filter example

{
  "apache":"all"
}

Example of an elasticGraph configuration

{
  "searchFilter": "s",
  "sectionFilter": "all",
  "filters": {
    "time": "all"
  },
  "seriesStates": {
    "series": {
      "5358f95f76d377e876000000: Australia: Sydney": "left",
      "5358f95f76d377e876000000: Brazil: Sao Paulo": "right",
      "5358f95f76d377e876000000: Chile: Vina del Mar": "disabled"
    }
  }
}
Parameters Required Type Description
filter Yes dict Object containing the metrics to be graphed. The JSON representation to the left would graph all available apache stats.
type Yes string “line” for line a line graph. “area” for a stacked area graph.
searchFilter Yes string The search query that will be used to find devices, services or both (dependant on the sectionFilter). All devices or services return by the search query will graph the selected metrics.
tall No bool True makes the maximized view of the graph extra tall.
seriesStates No dict Contains the series configuration of a graph such as assigning series to the left or right axis or disabling them completely.
sectionFilter No string “devices” or “services” to graph only devices or services respectively. Use “all” not to filter.

graph - config

This widget shows time series data

Config Parameters

Example of a graph configuration

{
  "graphs": [
    {
      "filters": {
        "time": "all"
      },
      "type": "service",
      "serviceId": "5358f95f76d377e876000000"
    },
  ],
  "seriesStates": {
    "series": {
      "5358f95f76d377e876000000: Australia: Sydney": "left",
      "5358f95f76d377e876000000: Brazil: Sao Paulo": "right",
      "5358f95f76d377e876000000: Chile: Vina del Mar": "disabled"
    }
  },
  "type": "line",
  "tall": false
}
Parameters Required Type Description
filter Yes dict Object containing the metrics to be graphed. The JSON representation to the left would graph all available apache stats.
type Yes string “line” for line a line graph. “area” for a stacked area graph.
tall No bool True makes the maximized view of the graph extra tall.
seriesStates No dict Contains the series configuration of a graph such as assigning series to the left or right axis or disabling them completely.

rss - config

This widget shows the last entries from the specified RSS feed

Config Parameters

Example of a RSS configuration

{
  "feedUrl": "http://status.aws.amazon.com/rss/fps.rss"  
}
Parameters Required Type Description
feedUrl Yes string Url of the RSS news feed.

serviceStatus - config

This widget shows the current status of one of your service checks

Config Parameters

Example of a serviceStatus configuration

{
  "serviceId": "5457a1ff95fe35c63174751f"  
}
Parameters Required Type Description
serviceId Yes string Id of the service this widget will display information from.

openAlerts - config

This widget shows the number of open alerts

Config Parameters

Examples of openAlerts configurations

All alerts on the account

{
  "entity": {
    "id": "all",
    "name": "The entire account",
    "type": "all",
    "isGroup": false
  }
}

A single device

{
  "id": "5458c45276d3776004900000",
  "name": "test",
  "type": "device",
  "isGroup": false
}

A single service check

{
  "id": "5358f95f76d377e876000000",
  "name": "www.serverdensity.com",
  "type": "service",
  "isGroup": false
}

A device group

{
  "id": "test_group",
  "name": "test_group",
  "type": "deviceGroup",
  "isGroup": true
}

A service group

{
  "id": "Monitored websites",
  "name": "Monitored websites",
  "type": "serviceGroup",
  "isGroup": true
}

entity Is a dictionary which is the definition of the subset of entities from which to count alerts.

Within entity the following parameters can be used.

Parameters Type Description
id string Id of the device or service or the name of the group. Use all for the whole account
name string Name of the device or group
type string What type it is. See the following types.
type > device string The id is from a device
type > deviceGroup string The id is from a deviceGroup
type > service string The id is from a service
type > serviceGroup string The id is from a service group
isGroup bool Depending if the ID is from a group.

Annexes

CloudStatus feed url list

Logs

Store a log

curl -X POST https://logs.serverdensity.io/collector \
  --data sdUrl=example \
  --data payload='{ "itemId": "32d3535f7ccc363c88a5311b77e581c1", "logs" : [{"timestamp": "2014-09-13T12:00:00", "message": "This is a test", "filename": "/var/log/hat.log"}, {"timestamp": "2014-09-13T12:01:00", "message": "This is a test", "filename": "/var/log/hat.log"}]}'
import json
import requests

payload = json.dumps({
    "itemId": "32d3535f7ccc363c88a5311b77e581c1",
    "logs" :
    [
      {"timestamp": "2014-09-13T12:00:00", "message": "This is a test", "filename": "/var/log/hat.log"},
      {"timestamp": "2014-09-13T12:01:00", "message": "This is a test", "filename": "/var/log/hat.log"}
    ]
})

api_response = requests.post(
  'https://logs.serverdensity.io/collector',
  params={"sdUrl": "example"},
  data={'payload': payload}
)

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

payload = json.dumps({
    "itemId" => "32d3535f7ccc363c88a5311b77e581c1",
    "logs"  =>
    [
      {"timestamp" => "2014-09-13T12:00:00", "message" => "This is a test", "filename" => "/var/log/hat.log"},
      {"timestamp" => "2014-09-13T12:01:00", "message" => "This is a test", "filename" => "/var/log/hat.log"}
    ]
})

params = {
    :query => {
      "token" => token,
      "sdUrl" => "example"
    },
    :body => {
      "type" => "elasticGraph",
      "dashboardId" => "5457a1fad998d12f038b4567"
    }
}

response = HTTParty.post("https://logs.serverdensity.io/collector", params)

response.to_json

You can use this method to post logs to Server Density without using the agent, for example using your own scripts or to integrate in something custom you are doing.

Http Request Method

POST https://logs.serverdensity.io/collector

Request Parameters

Parameters Required Type Description
sdUrl Yes string Set this to the hostname of your Server Density account URL, e.g. example.serverdensity.io would be example
payload Yes JSON array The payload of log lines you wish to store. See below for the format. The maximum size for this field is 100KB.

Payload

Example of a payload

{
    "itemId": "32d3535f7ccc363c88a5311b77e581c1",
    "logs" :
    [
      {"timestamp": "2014-09-13T12:00:00", "message": "This is a test", "filename": "/var/log/hat.log"},
      {"timestamp": "2014-09-13T12:01:00", "message": "This is a test", "filename": "/var/log/hat.log"}
    ]
}

The payload contains 2 fields. Only 1 log line is required but you can send batches if you wish. The maximum payload size is 100KB.

Parameters Type Description
itemId string This is the agent key for the device you are posting logs back to.
logs JSON array An array of the log line(s). The maximum size for each array item (log entry) is 20KB, including all fields.
logs > timestamp string Timestamp for the log line in the format YYYY-MM-DDTHH:MM:SS
logs > message string The log message.
logs > filename string The source of the log line, usually a file path but can be anything you wish.

Response parameters

The response will either be a string of OK plus a request ID on success, or an error string.

Tags

You can create new tags for devices and services. These tags are used to give permissions to set of users for them to be able to view these devices.

Creating new tags

curl -v https://api.serverdensity.io/inventory/tags/?token=b97da80a41c4f61bff05975ee51eb1aa \
  --data name=newTag \ 
  --data color=#fff000
import requests

token = "b97da80a41c4f61bff05975ee51eb1aa"

api_response = requests.post(
    'https://api.serverdensity.io/inventory/tags',
    params={
        'token': token
    },
    data={
        'name': 'newTag',
        'color': '#fff000'
    }
)

require "httparty"
require "json"

token = "b97da80a41c4f61bff05975ee51eb1aa"

params = {
    :query => {"token" => token},
    :body => {
      "name" => "newTag",
      "color" => "#fff000"
    }
}

response = HTTParty.post("http://api.serverdensity.io/inventory/tags", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('tags')->create("my tag");

?>

HTTP Request

POST /inventory/tags?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
name Yes string Name of the tag.
color Yes string The color of the tag in hexcode.

Response parameters

You get a json object containing all the information about the tag.

{
        "_id": "5488258495fe35fb2d9abc58",
        "name": "newTag",
        "color": "#fff000",
        "updatedAt": "2014-12-10T10:50:44",
        "createdAt": "2014-12-10T10:50:44",
        "accountId": "5460a25972d377c3324420b2",
        "deleted": false
}
Parameters Type Description
name string The name of the dashboard.
accountId string The account to which the dashboard belongs.
name string The ID of the dashboard.

Deleting a tag

curl -v -X DELETE https://api.serverdensity.io/inventory/tags/51f931c9dba4bba36d001542?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
tag_id = '51f931c9dba4bba36d001542'

delete_response = requests.delete(
    "https://api.serverdensity.io/inventory/tags/{0}".format(tag_id),
    params={'token': token}
)
require "httparty"

token = "901de5c241a6e879c1c6f0b27459d3f1"
tag_id = '51f7eafcdba4bb235e000ae4'

params = {
    :query => {"token" => token},
}

response = HTTParty.delete(
    "https://api.serverdensity.io/inventory/tags/#{tag_id}", 
    params
)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = '65o4ea65oe46ao4e5a'

$client->api('tags')->delete($id);

?>

The response is a JSON encoded hash containing the ID of the tag that has been deleted.

{
    "_id": "51f931c9dba4bba36d001542"
}

 Http request

DELETE /inventory/tags/<tag_id>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.

Response Parameters

Parameters Type Description
_id string The id of the tag that got deleted

View all tags

curl -v -X GET https://api.serverdensity.io/inventory/tags?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'

requests.get(
    'https://api.serverdensity.io/inventory/tags',
    params = {
        'token': token
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
params = {:query => {"token" => token}}

response = HTTParty.get('https://api.serverdensity.io/inventory/tags', params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$client->api('tags')->all();

?>

You get a list of json objects containing all the information about the tag.

[
    {
        "_id": "5488258495fe35fb2d9abc58",
        "name": "uppsala",
        "color": "#c33b9b",
        "updatedAt": "2014-12-10T10:50:44",
        "createdAt": "2014-12-10T10:50:44",
        "accountId": "5460a25976d377c3324420b2",
        "deleted": false
    }
]

HTTP Request

GET /inventory/tags?token=<token>

Request parameters

Parameters Required Type Description
token Yes string Your API token.

Response Parameters

Parameters Type Description
_id string The ID of the tag.
name string The name of the tag.
color string The color of the tag in hexcode.
updatedAt string The date when the tag was last updated.
createdAt string The date when the tag was created.
accountId string The account to which the tag belongs.
deleted boolean Whether the tag has been deleted or not.

Updating a tag

curl -v -X PUT https://api.serverdensity.io/inventory/tags/5457a1ff95fe35c63174751f?token=b97da80a41c4f61bff05975ee51eb1aa \
     --data name=UpdatedLlama color=#f0f0f0
import requests

token = 'b97da80a41c4f61bff05975ee51eb1aa'
tag_id = '5457a1ff95fe35c63174751f'

r = requests.put(
    'https://api.serverdensity.io/inventory/tags/{0}'.format(tag_id),
    params={'token': token},
    data={
        "name": "UpdatedLlama",
        "color": "#f0f0f0",
    }
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
tag_id = '5278f5f576d3774043000000'

params = {
    :query => {"token" => token},
    :body => {
        "name" => "UpdatedLlama",
        "color" => "#f0f0f0"
    }        
}

response = HTTParty.put(
    "https://api.serverdensity.io/inventory/tags/#{tag_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = '2342342513aa34a34a4a';
$fields = array(
    'name' => 'tag',
    'color' => '#ffffff'
);

$client->api('tags')->update($id, $fields);

?>

The JSON response you get contains the fields that got updated.

{
    "color": "#f0f0f0",
    "name": "UpdatedLlama",
    "updatedAt": "2014-12-10T12:38:33",
    "accountId": "5460a25976d377c3324420b2",
    "_id": "5488373095fe3569108b456a"
}

HTTP Request

PUT /inventory/tags/<tagId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
name No string Name of the tag.
color No string Color of the the tag in hexcode.

Viewing an individual tag

curl -v -X GET https://api.serverdensity.io/inventory/tags/51f6585e11f144673749afbb?token=b97da80a41c4f61bff05975ee51eb1aa
import requests

token = "b97da80a41c4f61bff05975ee51eb1aa"
tag_id = '51f6585e11f144673749afbb'

api_response = requests.get(
    'https://api.serverdensity.io/inventory/tags/{0}'.format(tag_id),
    params = {'token': token}
)
require "httparty"

token = "b97da80a41c4f61bff05975ee51eb1aa"
tag_id = '5457a1ff95fe35c63174751f'

params = {:query => {"token" => token}}

response = HTTParty.get("https://api.serverdensity.io/inventory/tags/#{tag_id}", params)

response.to_json
<?php
namespace serverdensity;
require __DIR__.'/vendor/autoload.php';
use serverdensity\Client;

$TOKEN = 'your authentication token here';

$client = new Client();
$client->authenticate($TOKEN);

$id = '2342342513aa34a34a4a';

$client->api('tags')->view($id);
$client->api('tags')->find('namehere');
$client->api('tags')->findAll(['name', 'here']);

?>
{
    "_id": "5488258495fe35fb2d9abc58",
    "name": "uppsala",
    "color": "#c33b9b",
    "updatedAt": "2014-12-10T10:50:44",
    "createdAt": "2014-12-10T10:50:44",
    "accountId": "5460a25976d377c3324420b2",
    "deleted": false
}

HTTP Request

GET /inventory/tags/<tagId>?token=<token>

Request Parameters

Parameters Required Type Description
token Yes string Your API token.
tagId Yes string The ID of the tag to view.

Response Parameters

Parameters Type Description
_id string The ID of the tag.
name string The name of the tag.
color string The color of the tag in hexcode.
updatedAt string The date when the tag was last updated.
createdAt string The date when the tag was created.
accountId string The account to which the tag belongs.
deleted boolean Whether the tag has been deleted or not.