Get Entity History Data

Retrieves object’s or link’s metric history using an existing metric token.

Request

HTTP Request

GET /node/api/metric-token/:id/history

Path parameters

Parameter Type Description

id

String

Metric Token ID

Query parameters

Parameter Type Description

duration

Integer

History period up to present moment (in milliseconds).

Request body

The request body is empty.

Response

Returns the set of data points containing entity’s history data.

Each data point contains the following fields:

Field Type Description

metric

String

Metric name.

tags.entity

String

The ID of the entity prefixed by the type of the entity. The format is objectxxx for objects and linkxxx for links.

aggregateTags

Array

Work In Progress

dps

Array<DataPoint>

An array of data points. Each data point is represented by an array that contains two values. The first one is a timestamp, the second one is value.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
token_id=<...>
duration=<...>
url=https://$saymon_hostname/node/api/metric-token/$token_id/history?duration=$duration

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let tokenId = <...>
let queryParams = "duration=1000000";
let path = "/node/api/metric-token/" + tokenId + "/history" + "?" + queryParams;
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Authorization", auth);

let requestOptions = {
    method: "GET",
    headers: headers
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let tokenId = <...>
let queryParams = "duration=1000000";
let path = "/node/api/metric-token/" + tokenId + "/history" + "?" + queryParams;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "GET",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth
    },
    "path": path
};

let req = http.request(options, function (res) {
    let chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        let body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
token_id = <...>
url = "https://" + saymon_hostname + "/node/api/metric-token/" + \
    token_id + "/history"

params = {
    "duration": 1577836800000
}

response = requests.request("GET", url, params=params auth=(login, password))
print(response.text)

Response

[
  {
    "metric": "responseTimeMs",
    "tags": {
        "entity": "obj59141f6253d529144c977f1f"
    },
    "aggregateTags": [],
    "dps": [
      [
          1499333280000,
          275
      ],
      [
          1499333400000,
          275
      ]
    ]
  },
  ...
]