NAV
shell php java

Introduction

This is the place where you will find details about the accessible API provided by Kronometrix for its users.

The Kronometrix API can be accessed over HTTP or HTTPS, using standard POST requests. The examples in this documentation will use standard HTTP, but using HTTPS should be straightforward.

Accessing the API

HTTP POST Request:

POST /api/get_subscriptions HTTP/1.1
Host: 192.168.2.56
Token: 8c24562ce3ae7812ef709934b7858b03

Response:

401 Unauthorized

{
  "error": "Invalid token"
}

To access the API you will have to use one of the two authentication methods:

The response from the server will be 200 OK in case of success, or an http error code in case of failure. The body of the response will consist of a string with JSON-encoded data, with various fields in case of succes, or a description of the error in case of failure.

Authentication

Authentication with username & password and with token

To authentication with the Kronometrix server using the API you can use one of the two authentication methods:

Using an API Token

API Token authentication

POST /api/get_subscriptions HTTP/1.1
Host: 192.168.2.56
Token: 8c24562ce3ae7812ef709934b7858b03

The recommended authentication method is the one using an API Token. This method is more secure and also offers better performance.

This method consists of using an API Token with every HTTP request you make to the API. The token must be present in the API request’s header under the field name “Token”:

Token: <api_token>

The API Token can be obtained by logging in Kronometrix and accessing the section Settings -> API Tokens. You can generate multiple API Tokens and name them according to their uses. The API Tokens are related only with your user account and will allow access only to your subscriptions and datasources, according to the set up visibility.

Using basic authentication

Basic authentication

POST /api/get_subscriptions HTTP/1.1
Host: 192.168.2.56
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

The second authentication method is the one using “basic authentication”. With this method, you can use your username and password directly to make API requests. This method is less secure because it sends authentication information in plain text. Also, it is less performant server-side.

All examples below will use API Token authentication, but basic authentication can also be used.

Create new API Token

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "token_name": "The token name"
    }
}' "http://<kronometrix_url>/api/create_token"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronometrix_url>/api/create_token');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "token_name": "The token name"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"token_name\": \"The token name\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronometrix_url>/api/create_token")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "token": "b3442fa2c7730d78a52497e37598e56c"
}

It is possible to create a new API Token using this API call:

Request

http://<kronometrix_url>/api/create_token

Parameter Details
token_name The name of the token to be created

Response

The API Token that has been created

Field Details
token The newly created API Token

Delete API Token

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "token": "477f78c737e6300e52184f1e31f29942"
    }
}' "http://<kronomentrix_url>/api/delete_token"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/delete_token');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "token": "477f78c737e6300e52184f1e31f29942"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"token\": \"477f78c737e6300e52184f1e31f29942\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/delete_token")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "removed": "477f78c737e6300e52184f1e31f29942"
}

You can delete existing API tokens using this API call:

Request

http://<kronometrix_url>/api/delete_token

Parameter Details
token The token to be deleted

Response

The API Token that has been deleted

Field Details
removed The deleted API Token

If the token didn’t exist, it will still appear as if it has been deleted (so you will get no error from trying to delete an inexistent token)

Create new user

Request

curl -X POST -d '{
    "params": {
        "username": "johndoe",
        "email": "johndoe@gmail.com",
        "first_name": "John",
        "last_name": "Doe",
        "company": "ACME",
        "country": "BS"
    }
}' "http://<kronomentrix_url>/api/create_user"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/create_user');
$request->setMethod(HTTP_METH_POST);

$request->setBody('{
    "params": {
        "username": "johndoe",
        "email": "johndoe@gmail.com",
        "first_name": "John",
        "last_name": "Doe",
        "company": "ACME",
        "country": "BS"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n \"params\": {\n \"username\": \"johndoe\",\n \"email\": \"johndoe@gmail.com\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"company\": \"ACME\",\n \"country\": \"BS\"\n}\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/create_user")
  .post(body)
  .build();

Response response = client.newCall(request).execute();

Response

OK

You can create a new user using the following API call:

Request

http://<kronometrix_url>/api/create_user

Parameter Details
username The username of the new user
email The e-mail address of the new user
first_name The new user’s first name
last_name The new user’s last name
company The new user’s company
phone The new user’s phone number (optional)
title The new user’s title (optional)
address The new user’s address (optional)
city The new user’s city (optional)
postalcode The new user’s postal code (optional)
country The country 2-letters code with capital letters (ex: BS for Bahamas)

Response

The text OK in case of success (with HTTP code 200 OK), or a JSON structure describing the error in case another HTTP code is received (thus denoting a failure):

Field Details
error The error message

Provisioning

List subscriptions

Request

curl -X POST -H "Token: <api_token>" "http://<kronometrix_url>/api/get_subscriptions"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronometrix_url>/api/get_subscriptions');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://<kronometrix_url>/api/get_subscriptions")
  .post(null)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
  {
    "monitoring_object": "cpd",
    "user_role": [
      "owner"
    ],
    "id": "998d1bd7d61e8850952902c3bc3a81f1",
    "monitoring_object_name": "Computer Performance",
    "name": "My Subscription",
    "description": "This is an example subscription"
  },
  {
    "monitoring_object": "wpd",
    "user_role": [
      "admin"
    ],
    "id": "08b861f5919722505166b81f95fde672",
    "monitoring_object_name": "Web Application Framework Performance",
    "name": "My Web Subscription",
    "description": ""
  }
]

This endpoint retreives the list of subscriptions the user has access to, with associated informations.

Request

http://<kronometrix_url>/api/get_subscriptions

No parameters needed

Response

A JSON-encoded array, each element of the array corresponding to a subscription and having these fields:

Field Details
id The ID of the subscription
name The name of the subscription
description The description of the subscription
monitoring_object The ID of the monitoring object
monitoring_object_name The name of the monitoring object
user_role Array of roles the user has for this subscription

Create new subscription

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "name": "Name of the subscription",
        "description": "The description of the API-created subscription",
        "type": "wpd"
    }
}' "http://<kronomentrix_url>/api/create_subscription"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/create_subscription');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "name": "Name of the subscription",
        "description": "The description of the API-created subscription",
        "type": "wpd"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"name\": \"Name of the subscription\",\n        \"description\": \"The description of the API-created subscription\",\n        \"type\": \"wpd\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/create_subscription")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "subscription_id": "5a332f210e37bb8c2a928bccd5423e33"
}

This endpoint allows the user to create a new subscription of a specified type.

Request

http://<kronometrix_url>/api/create_subscription

Parameter Details
name The name of the new subscription
description A description of the new subscription (optional)
type The type of the new subscription

Response

The ID of the new subscription

Field Details
subscription_id The ID of the new subscription

Delete subscription

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "5a332f210e37bb8c2a928bccd5423e33"
    }
}' "http://<kronomentrix_url>/api/delete_subscription"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/delete_subscription');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "5a332f210e37bb8c2a928bccd5423e33"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"5a332f210e37bb8c2a928bccd5423e33\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/delete_subscription")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "removed": "5a332f210e37bb8c2a928bccd5423e33"
}

This endpoint allows the user to delete an existing subscription.

Request

http://<kronometrix_url>/api/delete_subscription

Parameter Details
sid The ID of the subscription to be deleted

Response

The ID of the subscription that has been deleted

Field Details
removed The ID of the subscription that has been deleted

Rename subscription

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "4be4d9aef4ed832301e331c30ab88e5d",
        "name": "Another name",
        "description": "Edited description"
    }
}' "http://<kronomentrix_url>/api/rename_subscription"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/rename_subscription');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "4be4d9aef4ed832301e331c30ab88e5d",
        "name": "Another name",
        "description": "Edited description"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"4be4d9aef4ed832301e331c30ab88e5d\",\n        \"name\": \"Another name\",\n        \"description\": \"Edited description\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/rename_subscription")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "renamed": "4be4d9aef4ed832301e331c30ab88e5d"
}

This endpoint provides the user with the possibility to change the name of the subscription, or its description.

Request

http://<kronometrix_url>/api/rename_subscription

Parameter Details
sid Subscription ID to be renamed
name The new name of the subscription
description The new description of the subscription (optional)

Response

The ID of the subscription that has been renamed

Field Details
renamed The ID of the subscription that has been renamed

List datasources

This endpoint retreives the list of datasources which correspond to a subscription and which can be accessed by the user.

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "<subscription_id>"
    }
}' "http://<kronomentrix_url>/api/get_ds"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronometrix_url>/api/get_ds');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "<subscription_id>"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"<subscription_id>\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronometrix_url>/api/get_ds")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
  {
    "id": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
    "name": "ds-name1",
    "monitoring_object": "cpd"
  },
  {
    "id": "566ac121-59c7-509d-92e0-028b3c8d6154",
    "name": "other-ds",
    "monitoring_object": "cpd"
  }
]

Request

http://<kronometrix_url>/api/get_ds

Parameter Details
sid Subscription ID for which to query for datasources

Response

A JSON-encoded array, each element of the array corresponding to a datasource and having these fields:

Field Details
id The ID of the datasource
name The name of the datasource
monitoring_object The ID of the monitoring object

Search datasources

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "search": "te"
    }
}' "http://<kronomentrix_url>/api/search_ds"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/search_ds');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "search": "te"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"search\": \"te\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/search_ds")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
  {
    "id": "a1153f37-57f5-5046-b117-ac195faff39a",
    "monitoring_object": "cpd",
    "name": "tethys"
  }
]

This endpoint offers the users the possibility to search for a datasource in a subscription by datasource name or ID. The call will return a list of datasources that contain the search string in their name or ID.

Request

http://<kronometrix_url>/api/search_ds

Parameter Details
sid Subscription ID in which to search for datasources
search The search term (part of the datasource’s name or ID)

Response

A JSON-encoded array, each element of the array corresponding to a datasource and having these fields:

Field Details
id The ID of the datasource
name The name of the datasource
monitoring_object The ID of the monitoring object

Delete datasources

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "datasources": [
            "b2fadd11-f143-529f-bd97-5f5e30b19499",
            "527debbd-c89b-5ea9-8052-ea8a4ae93cee"
        ]
    }
}' "http://<kronomentrix_url>/api/delete_ds"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/delete_ds');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "datasources": [
            "b2fadd11-f143-529f-bd97-5f5e30b19499",
            "527debbd-c89b-5ea9-8052-ea8a4ae93cee"
        ]
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"datasources\": [\n            \"b2fadd11-f143-529f-bd97-5f5e30b19499\",\n            \"527debbd-c89b-5ea9-8052-ea8a4ae93cee\"\n        ]\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/delete_ds")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "deleted": [
    "b2fadd11-f143-529f-bd97-5f5e30b19499",
    "527debbd-c89b-5ea9-8052-ea8a4ae93cee"
  ]
}

This endpoint allows the user to delete one or many datasources in a subscription.

Request

http://<kronometrix_url>/api/delete_ds

Parameter Details
sid The ID of the subscription from which to delete the datasources
datasources An array of datasource IDs

Response

The list of datasource IDs that have been deleted

Field Details
deleted An array of datasource IDs that have been deleted

List devices of a datasource

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "e03b7160-f82b-5125-871b-3567e76cb190"
    }
}' "http://<kronomentrix_url>/api/get_ds_devices"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_ds_devices');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "e03b7160-f82b-5125-871b-3567e76cb190"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"dsid\": \"e03b7160-f82b-5125-871b-3567e76cb190\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_ds_devices")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "eth0": [
    "linux-nicrec"
  ],
  "sda2": [
    "linux-diskrec"
  ],
  "cpu0": [
    "linux-cpurec"
  ],
  "sda1": [
    "linux-diskrec"
  ],
  "cpu1": [
    "linux-cpurec"
  ],
  "sda5": [
    "linux-diskrec"
  ],
  "sda": [
    "linux-diskrec"
  ],
  "system": [
    "linux-sysrec",
    "linux-hdwrec"
  ]
}

This endpoint returns the list of devices and associated messages, for a certain datasource.

Request

http://<kronometrix_url>/api/get_ds_devices

Parameter Details
sid The ID of the subscription in which the datasource resides
dsid The ID of the datasource

Response

A JSON-encoded hash table, with each key representing a device ID, and the corresponding value consisting of an array of message names for that device.

Add an user to a subscription

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "email": "test@gmail.com",
        "name": "John Doe",
        "role": "viewer",
        "ds_groups": ["5cc0a6701281b08e1f1733aaa6d4a41d"]
    }
}' "http://<kronomentrix_url>/api/adduser_subscription"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/adduser_subscription');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "email": "test@gmail.com",
        "name": "John Doe",
        "role": "viewer",
        "ds_groups": ["5cc0a6701281b08e1f1733aaa6d4a41d"]
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\", \"email\": \"test@gmail.com\", \"name\": \"John Doe\", \"role\": \"viewer\", \"ds_groups\": [\"5cc0a6701281b08e1f1733aaa6d4a41d\"] }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/adduser_subscription")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
    "added": "Existing user has been added"
}

This endpoint allows a subscription admin or owner to allow access to another user (existing in Kronometrix, or a completely new user).

Request

http://<kronometrix_url>/api/adduser_subscription

Parameter Details
sid The ID of the subscription to allow access to
email The email address of the user to be added
name The name of the user to be added; used for communication with the user if he will be invited to Kronometrix
role The role given to the user for this subscription; can be “owner”, “admin”, “provider”, “viewer”
ds_groups An array of datasource groups IDs to give access to, if the role is “provider” or “viewer”. A special value all_ds can be used to specify all datasources of the subscription

Response

A JSON-encoded structure representing the result of the operation or an error if the operation fails

Field Details
added A text message specifying if the user exists in Kronometrix or it has been invited
or
error A text describing the error

Remove an user from a subscription

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "uid": "e0977c97ba60db95dedd8b8926bd0627"
    }
}' "http://<kronomentrix_url>/api/rmuser_subscription"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/rmuser_subscription');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "uid": "e0977c97ba60db95dedd8b8926bd0627"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\", \"uid\": \"e0977c97ba60db95dedd8b8926bd0627\" }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/rmuser_subscription")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
    "removed": "e0977c97ba60db95dedd8b8926bd0627"
}

This endpoint allows a subscription admin or owner to remove access for another user. The user’s ID to be removed must be known. The removed user will NOT be deleted from Kronometrix.

Request

http://<kronometrix_url>/api/rmuser_subscription

Parameter Details
sid The ID of the subscription to remove access from
uid The ID of the user to be removed

Response

A JSON-encoded structure representing the result of the operation or an error if the operation fails

Field Details
removed The ID of the user that has been removed
or
error A text describing the error

Send data

Request

curl -X POST -H "Token: <api_token>" -H "Content-Type: application/x-www-form-urlencoded" -d 'payload=win-sysrec:9ee583c7d0a8b314c947dccfdcd922ca:TEST:system:1458174060:0.17:0.00:0.00:0.09:0.09:99.61:0.01:0.00:49:790:34.20:5627684:10826808:16454492:65.80:0.00:0:2490368:2490368:0:0.00:0:9:146.42:0:0:0:9:146.42:8:1.23:0:0:5:0.59:0:0:14:1.82:48aae8722de9a0f1b50b906ee32c69f888ee7b2deaf42e3133ec6dbece4ba31b' "http://<kronomentrix_url>/api/private/send_data"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/private/send_data');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'content-type' => 'application/x-www-form-urlencoded',
  'token' => '<api_token>'
));

$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
  'payload' => 'win-sysrec:9ee583c7d0a8b314c947dccfdcd922ca:TEST:system:1458174060:0.17:0.00:0.00:0.09:0.09:99.61:0.01:0.00:49:790:34.20:5627684:10826808:16454492:65.80:0.00:0:2490368:2490368:0:0.00:0:9:146.42:0:0:0:9:146.42:8:1.23:0:0:5:0.59:0:0:14:1.82:48aae8722de9a0f1b50b906ee32c69f888ee7b2deaf42e3133ec6dbece4ba31b'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "payload=win-sysrec%3A9ee583c7d0a8b314c947dccfdcd922ca%3ATEST%3Asystem%3A1458174060%3A0.17%3A0.00%3A0.00%3A0.09%3A0.09%3A99.61%3A0.01%3A0.00%3A49%3A790%3A34.20%3A5627684%3A10826808%3A16454492%3A65.80%3A0.00%3A0%3A2490368%3A2490368%3A0%3A0.00%3A0%3A9%3A146.42%3A0%3A0%3A0%3A9%3A146.42%3A8%3A1.23%3A0%3A0%3A5%3A0.59%3A0%3A0%3A14%3A1.82%3A48aae8722de9a0f1b50b906ee32c69f888ee7b2deaf42e3133ec6dbece4ba31b");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/private/send_data")
  .post(body)
  .addHeader("token", "<api_token>")
  .addHeader("content-type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();

Response

OK

This is the API call through which data enter Kronometrix. All datasources send data using this API call. This API call supports only token-based authentication!

Request

http://<kronometrix_url>/api/private/send_data

Parameter Details
payload The message to be processed by Kronometrix

Response

The text OK in case of success (with HTTP code 200 OK), or a text describing the error in case another HTTP code is received (thus denoting a failure).

General considerations

Payload format

The payload contains a single message which is transmitted to Kronometrix. All messages are defined within the Kronometrix platform and are uniquely identified by their message_id.

A message is composed of multiple fields separated by a character, which also is defined within the Kronometrix platform. The separator character is a property of the message. As a general recommendation, we propose the use of characters : or ; as separators (keep in mind that the character : can be also found in the ISO formatted date field, so in this case the character ; is recommended).

The order of the fields is also defined in the platform as a characteristic of the message. The only restriction here is that the message must always begin with the message ID. The rest of the fields can be defined in any order, but the order in which the fields are specified in the message definition must be the same as the order in which the fields appear in the sent message.

A message is composed of the following fields:

Send bulk data

Request

curl -X POST -H "token: <api_token>" -H "message-id: <message_id>" -H "subscription-id: <subscription_id>" -H "datasource-id: <datasource_id>" -H "device-id: <device_id>" -d '<payload>' "http://<kronomentrix_url>/api/private/send_data_bulk"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/private/send_data_bulk');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'device-id' => '<device_id>',
  'datasource-id' => '<datasource_id>',
  'subscription-id' => '<subscription_id>',
  'message-id' => '<message_id>',
  'token' => '<api_token>'
));

$request->setBody('<payload>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "<payload>");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/private/send_data_bulk")
  .post(body)
  .addHeader("token", "<api_token>")
  .addHeader("message-id", "<message_id>")
  .addHeader("subscription-id", "subscription_id")
  .addHeader("datasource-id", "datasource_id")
  .addHeader("device-id", "device_id")
  .build();

Response response = client.newCall(request).execute();

Response

OK

This is the API call through which bulk data enter Kronometrix. Bulk data is the kind of generic data that is stored in Kronometrix as a file (raw data file), but it is not parsed in any way. This can be useful for uploading log dumps, binary data (e.g. images) or any other kind of big data. This API call supports only token-based authentication!

Request

http://<kronometrix_url>/api/private/send_data_bulk

Header field Details
token The API Token to be used for authentication
message-id The ID of the message; this message must be defined as type="bulk" in the LMO
subscription-id The ID of the subscription
datasource-id The ID of the datasource
device-id The ID of the device
hash An sha256 hash of the payload (optional)

Response

The text OK in case of success (with HTTP code 200 OK), or a text describing the error in case another HTTP code is received (thus denoting a failure).

General considerations

Summary statistics

List message statistics

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "message": "<message_id>"
    }
}' "http://<kronometrix_url>/api/get_msg_stats"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronometrix_url>/api/get_msg_stats');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "message": "<message_id>"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"message\": \"<message_id>\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronometrix_url>/api/get_msg_stats")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "monitoring_object": "cpd",
  "message": "linux-sysrec",
  "stats": [
    {
      "name": "cpupct",
      "functions": {
        "MAX": [ [300, 300 ], [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "SUM": [ [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "COUNT": [ [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "MIN": [ [300, 300 ], [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ]
      }
    },
    {
      "name": "memusedpct",
      "functions": {
        "MAX": [ [300, 300 ], [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "SUM": [ [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "COUNT": [ [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ],
        "MIN": [ [300, 300 ], [10800, 60], [21600, 300], [43200, 900], [86400, 1800], [259200, 3600], [604800, 10800], [2592000, 43200], [7776000, 86400 ] ]
      }
    }
  ]
}

This endpoint lists the available statistics with intervals for a certain message. The message ID is the one listed for each device of the datasource.

Request

http://<kronometrix_url>/api/get_msg_stats

Parameter Details
message The message ID for which to obtain the available statistics and intervals

Response

A JSON-encoded hash table with these fields:

Field Details
monitoring_object The ID of the monitoring object
message The message ID (same with the “message” parameter sent)
stats An array of objects, each object (hash-table) having these fields: “name” = parameter name; “functions” = an array of functions (hash table).
Each element of the “functions” hash has the aggregation function ID as key (“MIN”, “MAX”, “SUM”, “COUNT”, “LAST”, “PERCENTILE”) and an array of intervals as value.
Each interval is an array of 2 elements, first element representing the interval width in seconds, and the second element representing the resolution in seconds.

List summary statistics functions

Request

curl -X POST -H "Token: <api_token>" "http://<kronomentrix_url>/api/get_stats"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_stats');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_stats")
  .post(null)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
    "name": "The Library of Summary Statistics Functions",
    "description": "Includes Kronometrix summary statistics functions",
    "id": "libssf",
    "functions": {
      "MIN": {
        "name": "Min",
        "id": "MIN",
        "description": "Minimum value",
        "formats": [
          { "format": "Min([x1, x2, ...])", "description": "Returns the minimum value from the array" }
        ]
      },
      "MAX": {
        "name": "Max",
        "id": "MAX",
        "description": "Maximum value",
        "formats": [
          { "format": "Max([x1, x2, ...])", "description": "Returns the maximum value from the array" }
        ]
      },
      ...
    }
  }

This endpoint lists the available summary statistics functions available in Kronometrix.

Request

http://<kronometrix_url>/api/get_stats

No parameters needed

Response

A JSON-encoded hash describing the statistics functions library, with the following fields:

Field Details
name The name of the library
description A short description of the library
id An internal library ID
functions A hash of objects, each object (hash-table) having these fields: “id” = the ID of the function; “name” = the name (definition) of the function; “description” = a short description of the function; “formats” = an array with the available function formats

Get statistical data

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947882fdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "device": "system",
        "message": "win-sysrec",
        "param": "cpupct",
        "function": "AVG",
        "interval": "10800",
        "resolution": "60"
    }
}' "http://<kronometrix_url>/api/get_values"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronometrix_url>/api/get_values');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947882fdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "device": "system",
        "message": "win-sysrec",
        "param": "cpupct",
        "function": "AVG",
        "interval": "10800",
        "resolution": "60"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947882fdcd922ca\",\n        \"dsid\": \"527debbd-c89b-5ea9-8052-ea8a4ae93cee\",\n        \"device\": \"system\",\n        \"message\": \"win-sysrec\",\n        \"param\": \"cpupct\",\n        \"function\": \"AVG\",\n        \"interval\": \"10800\",\n        \"resolution\": \"60\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronometrix_url>/api/get_values")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
  [
    1457441220000,
    3.03
  ],
  [
    1457441280000,
    3.25
  ],
  [
    1457441340000,
    3.08
  ],
  [
    1457441400000,
    2.91
  ]
  ...
]

This endpoint lists statistical data for the required datasource, device, message, parameter, function, interval and resolution.

Request

http://<kronometrix_url>/api/get_values

Parameter Details
sid Subscription ID
dsid Datasource ID
device Device ID
message Message ID
param Parameter name
function Aggregation function
interval Interval width
resolution Resolution

Response

A JSON-encoded array, each element of the array being an array of 2 elements, the first element representing the unix timestamp in milliseconds (multiplied by 1000), and the second element representing the value of the parameter for that timestamp. The second value may be null, which means that there is not an available value for that timestamp.

Raw data

List raw data files

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "date": "2016-03-16"
    }
}' "http://<kronomentrix_url>/api/list_raw_data_files"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/list_raw_data_files');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "date": "2016-03-16"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"dsid\": \"527debbd-c89b-5ea9-8052-ea8a4ae93cee\",\n        \"date\": \"2016-03-16\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/list_raw_data_files")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
  {
    "file": "nicrec.e1iexpress.2016-03-16.krd",
    "size": "94 KB"
  },
  {
    "file": "cpurec.cpu2.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "cpurec.cpu5.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "hdwrec.system.2016-03-16.krd",
    "size": "126 KB"
  },
  {
    "file": "cpurec.cpu7.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "cpurec.cpu0.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "cpurec.cpu6.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "diskrec.diskC.2016-03-16.krd",
    "size": "124 KB"
  },
  {
    "file": "diskrec.diskD.2016-03-16.krd",
    "size": "116 KB"
  },
  {
    "file": "cpurec.cpu1.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "cpurec.cpu3.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "cpurec.cpu4.2016-03-16.krd",
    "size": "59 KB"
  },
  {
    "file": "sysrec.system.2016-03-16.krd",
    "size": "263 KB"
  }
]

This endpoint lists the available raw data files for a certain date (day). Please note that the date is in yyyy-mm-dd format!

Request

http://<kronometrix_url>/api/list_raw_data_files

Parameter Details
sid Subscription ID
dsid Datasource ID
date The date for which to list files

Response

A JSON-encoded array, each element of the array being a hash table with two elements: file = the file name; size = the file size.

Download raw data file

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "file": "sysrec.system.2016-03-16.krd"
    }
}' "http://<kronometrix_url>/api/get_raw_data_file"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_raw_data_file');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "sid": "9ee583c7d0a8b314c947dccfdcd922ca",
        "dsid": "527debbd-c89b-5ea9-8052-ea8a4ae93cee",
        "file": "sysrec.system.2016-03-16.krd"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"sid\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"dsid\": \"527debbd-c89b-5ea9-8052-ea8a4ae93cee\",\n        \"file\": \"sysrec.system.2016-03-16.krd\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_raw_data_file")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

1458086400:0.58:0.00:0.00:0.30:0.28:98.63:0.01:0.00:74:1342:41.54:6834524:9619968:16454492:58.46:0.73:18064:2472304:2490368:0:5.41:0:11:188.44:0:0:0:11:193.85:11:2.89:0:0:7:0.80:0:0:18:3.69
1458086460:0.43:0.00:0.00:0.24:0.19:98.84:0.00:0.00:74:1339:41.52:6832560:9621932:16454492:58.48:0.73:18064:2472304:2490368:0:0.00:0:10:169.21:0:0:0:10:169.21:9:1.27:0:0:6:0.64:0:0:15:1.91
1458086520:0.43:0.00:0.00:0.27:0.15:98.77:0.00:0.00:74:1325:41.49:6827092:9627400:16454492:58.51:0.73:18064:2472304:2490368:0:1.34:0:10:143.63:0:0:0:10:144.97:10:2.30:0:0:6:0.67:0:0:17:2.97
1458086580:0.42:0.00:0.00:0.24:0.19:98.78:0.01:0.00:75:1317:41.49:6826668:9627824:16454492:58.51:0.73:18064:2472304:2490368:1:17.34:0:13:180.12:0:0:0:14:197.46:9:1.23:0:0:6:0.63:0:0:15:1.86
1458086642:0.78:0.00:0.00:0.33:0.46:98.41:0.02:0.00:74:1321:41.60:6845692:9608800:16454492:58.40:0.73:18064:2472304:2490368:0:0.26:0:20:662.37:0:0:0:20:662.63:10:2.35:0:0:7:0.72:0:0:18:3.07
...

This endpint allows users to download a raw data file.

Request

http://<kronometrix_url>/api/get_raw_data_file

Parameter Details
sid Subscription ID
dsid Datasource ID
file File name to download

Response

The file content

Widgets

List widgets

Request


curl -X POST -H "Token: <api_token>" "http://<kronomentrix_url>/api/get_widgets"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_widgets');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_widgets")
  .post(null)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "bc34d59ea95b38992569b9ac79e37b32": {
    "subscription_id": "9ee583c7d0a8b314c947dccfdcd922ca",
    "subscription_name": "Computer Performance",
    "params": {
      "cpu": {
        "val": "566ac121-59c7-509d-92e0-028b3c8d6154:system:linux-sysrec:cpupct:LAST:300:300"
      }
    },
    "settings": {
      "type": "gauge",
      "gauge_color": "#55af0f",
      "gauge_aswidget": true
    },
    "name": "CPU Gauge",
    "description": ""
  },
  "7a550181d038429b1dd4f8ccbc1ac758": {
    "subscription_id": "9ee583c7d0a8b314c947dccfdcd922ca",
    "subscription_name": "Computer Performance",
    "params": {
      "cpu": {
        "val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:cpupct:AVG:10800:60",
        "color": "#619639"
      },
      "memory": {
        "val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:memusedpct:AVG:10800:60",
        "color": "#0e74b2"
      }
    },
    "settings": {
      "type": "chart",
      "chart_aswidget": true,
      "chart_haslegend": true,
      "chart_type": "line"
    },
    "name": "CPU & Memory utilization",
    "description": "in %"
  }
}

This endpoint lists the available widgets for the current user, with associated information.

Request

http://<kronometrix_url>/api/get_widgets

No parameters needed

Response

A JSON-encoded array, each element of the array corresponding to a widget, having as the key the widget ID and containing these fields:

Field Details
name The name of the widget
description The description of the widget
subscription_id The ID of the subscription
subscription_name The name of the subscription
params An array of params, each element having as key the name of the param (unique) and as value a hash-table with the elements “val” having the param’s value and “color” having the line color (color needed only for chart widgets)
settings A hash-table containing at least one element - “type”, which can be “chart”, “indicator” or “gauge”; the rest of the hash’s elements are dependant on the type of the widget

Create new widget

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "name": "API-created widget",
        "description": "The description of the API-created widget",
        "subscription_id": "9ee583c7d0a8b314c947dccfdcd922ca",
        "params": {
            "cpu": {"val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:cpupct:AVG:10800:60", "color": "#D40B51"},
            "memory": {"val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:memusedpct:AVG:10800:60", "color": "#21C4B1"}
        },
        "settings": {
            "type": "chart",
            "chart_type": "line",
            "chart_aswidget": true,
            "chart_haslegend": true
        }
    }
}' "http://<kronomentrix_url>/api/create_widget"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/create_widget');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "name": "API-created widget",
        "description": "The description of the API-created widget",
        "subscription_id": "9ee583c7d0a8b314c947dccfdcd922ca",
        "params": {
            "cpu": {"val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:cpupct:AVG:10800:60", "color": "#D40B51"},
            "memory": {"val": "527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:memusedpct:AVG:10800:60", "color": "#21C4B1"}
        },
        "settings": {
            "type": "chart",
            "chart_type": "line",
            "chart_aswidget": true,
            "chart_haslegend": true
        }
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"name\": \"API-created widget\",\n        \"description\": \"The description of the API-created widget\",\n        \"subscription_id\": \"9ee583c7d0a8b314c947dccfdcd922ca\",\n        \"params\": {\n            \"cpu\": {\"val\": \"527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:cpupct:AVG:10800:60\", \"color\": \"#D40B51\"},\n            \"memory\": {\"val\": \"527debbd-c89b-5ea9-8052-ea8a4ae93cee:system:win-sysrec:memusedpct:AVG:10800:60\", \"color\": \"#21C4B1\"}\n        },\n        \"settings\": {\n            \"type\": \"chart\",\n            \"chart_type\": \"line\",\n            \"chart_aswidget\": true,\n            \"chart_haslegend\": true\n        }\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/create_widget")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "widget_id": "65102c8e86cd5ed2baf60ebf69b31d9e"
}

This endpoint allows the user to create a new widget of a specified type, for a specified subscription.

Request

http://<kronometrix_url>/api/create_widget

Parameter Details
name The name of the new widget
description The description for the new widget
subscription_id The ID of the subscription for which the widget is created
params A hash-table of parameters for this widget; the keys are paramater names, and the values have two elements:
  • val = the parameter value, with the format
    <ds_id>:<device_id>:<message_id>:<parameter>:<stat>:<interval>:<resolution>
  • color = the parameter’s line color; needed only for widgets of type chart
settings A hash-table with the widget settings; each widget type has its own set of settings, as follows:
  • chart:
    • type = “chart”
    • chart_type = “line” or “stacked”
    • chart_aswidget = true/false - the control is displayed as widget or not
    • chart_haslegend = true/false - the chart has a legend or not
  • gauge:
    • type = “gauge”
    • gauge_color = the hex value of the color
    • gauge_aswidget = true/false - the control is displayed as widget or not
  • indicator:
    • type = “indicator”
    • indicator_type = “plain”, “widget” or “colored”
    • indicator_color = the hex value of the color; needed only for indicator_type=“colored”
    • indicator_decimals = the number of decimals; can be “0”, “1” or “2”
    • indicator_unit = optional; a string with the indicator’s unit

Response

The ID of the new widget

Field Details
widget_id The ID of the new widget

Delete widgets

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "widgets": ["79a58bc264faa53967c532d43377fe38", "1415799bc10b5a1aae81ac862fde795b"]
    }
}' "http://<kronomentrix_url>/api/delete_widgets"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/delete_widgets');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "widgets": ["79a58bc264faa53967c532d43377fe38", "1415799bc10b5a1aae81ac862fde795b"]
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"widgets\": [\"79a58bc264faa53967c532d43377fe38\", \"1415799bc10b5a1aae81ac862fde795b\"]\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/delete_widgets")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

{
  "deleted": [
    "79a58bc264faa53967c532d43377fe38",
    "1415799bc10b5a1aae81ac862fde795b"
  ]
}

This endpoint allows the user to delete one or many widgets of his own.

Request

http://<kronometrix_url>/api/delete_widgets

Parameter Details
widgets An array of widget IDs

Response

The list of widget IDs that have been deleted

Field Details
deleted An array of widget IDs that have been deleted

Get widget embed code

Request

curl -X POST -H "Token: <api_token>" -d '{
    "params": {
        "widget_id": "7a550181d038429b1dd4f8ccbc1ac758"
    }
}' "http://<kronomentrix_url>/api/get_widget_embed_code"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_widget_embed_code');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

$request->setBody('{
    "params": {
        "widget_id": "7a550181d038429b1dd4f8ccbc1ac758"
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n    \"params\": {\n        \"widget_id\": \"7a550181d038429b1dd4f8ccbc1ac758\"\n    }\n}");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_widget_embed_code")
  .post(body)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

<iframe width="600" height="300" frameborder="0" src="http://<kronometrix_url>/widgets/<uid>/7a550181d038429b1dd4f8ccbc1ac758"></iframe>

This endpoint provides the possibility to easily obtain the HTTP code to embed the widget on another web page.

Request

http://<kronometrix_url>/api/get_widget_embed_code

Parameter Details
widget_id The ID of the widget to get the embed code for

Response

The HTML code to use in your web page to embed this widget

Info

Get data analytics platform information

Request

curl -X POST -H "Token: <api_token>" "http://<kronomentrix_url>/api/get_kinfo"
<?php

$request = new HttpRequest();
$request->setUrl('http://<kronomentrix_url>/api/get_kinfo');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'token' => '<api_token>'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
Request request = new Request.Builder()
  .url("http://<kronomentrix_url>/api/get_kinfo")
  .post(null)
  .addHeader("token", "<api_token>")
  .build();

Response response = client.newCall(request).execute();

Response

[
    {
        "Type": "K500"
    },
    {
        "ID": "NA"
    },
    {
        "Version": "1.6.4"
    },
    {
        "Architecture": "x64"
    },
    {
        "Name": "K500 Development"
    },
    {
        "Last Updated": "NA"
    },
    {
        "Modules": [
            "authenticator: kauth 1.6.4",
            "kernel: kkernel 1.6.4",
            "messenger: kmesg 1.6.4",
            "monitor: kmon 1.6.4"
        ]
    },
    {
        "Manufactured": "Mon Jul 24 12:10:18 UTC 2017"
    },
    {
        "Vendor": "SDR Dynamics, Helsinki, Finland"
    },
    {
        "Registrant": "NA"
    },
    {
        "Email": "NA"
    },
    {
        "License": "NA"
    }
]

This endpoint provides the possibility to list details about the Kronometrix installation.

Request

http://<kronometrix_url>/api/get_kinfo

No parameters needed

Response

A JSON-encoded array with various details about the Kronometrix installation.