Skip to content

REST API

Mario Bielert edited this page Jul 30, 2019 · 5 revisions

These are the public function to communicate with this endpoint.

POST to /search

This will return a list of metrics matching the given criteria.

Request parameters

target

Type: string

This defines a partial metric name, which will be looked up in the database.

The target string will be matched against the metric name after every .. For example, target is foo:

Metric Matches
foo.bar.power yes
bar.foo.power yes
foobar.power yes
barfoo.power no

Response

A JSON array containing a list of the first 100 matching metric names. For example:

[ "foo.bar.power", "bar.foo.power", "foobar.power" ]

POST to /query

This will return a list of data points for the given metrics for a certain timespan.

Request parameters

targets

Type: array

A list of metrics and aggregations, which should be retrieved. Each entry is a dict with the following members:

  • target_metric: string, the name of the metric
  • aggregates: array of strings, the aggregation values, available are:
    • min
    • max
    • avg
    • count
  "targets": [
    {
      "target_metric": "foo.bar.power",
      "aggregates": [
        "min",
        "count"
      ]
    },
    {
      "target_metric": "foo.baz.power",
      "aggregates": [
        "max",
        "avg"
      ]
    }
  ]

intervalMs

Type: number

This is a hint for the maximum duration of one aggregation interval. The interval is given in milliseconds.

range

Type: object

With the members from and to, this defines the range of time, for when the data should be retrieved. Both members are expected as string in ISO 8601 format.

"range":{  
  "from": "2017-01-19T06:57:54.524Z",
  "to": "2017-02-02T01:27:34.195Z"
}

Response

A JSON array containing the data points. Each requested target (combination of metric and aggregation) is represented by an dict in the array. Each target dict contains the following members:

  • target: string, the metric and aggregation divided by a slash /
  • time_measurements: object, the time how much time was spent in db and transfer
  • datapoints: array, list of array, which represent the value and timestamp. The timestamp is given as milliseconds since unix epoch

For example:

[
    {
        "target": "foo.bar.power/min",
        "time_measurements": {
            "db": "0.061802",
            "http": "92212367"
        },
        "datapoints": [
            [
                69.37970733642578,
                1564125782000
            ]
        ]
    },
    {
        "target": "foo.bar.power/count",
        "time_measurements": {
            "db": "0.061802",
            "http": "92212367"
        },
        "datapoints": [
            [
                42,
                1564125782000
            ]
        ]
    },
    {
        "target": "foo.baz.power/max",
        "time_measurements": {
            "db": "0.061802",
            "http": "92212367"
        },
        "datapoints": [
            [
                74.40116882324219,
                1564125782000
            ]            
        ]
    },
    {
        "target": "foo.baz.power/avg",
        "time_measurements": {
            "db": "0.061802",
            "http": "92212367"
        },
        "datapoints": [
            [
                54.40137970732219,
                1564125782000
            ]            
        ]
    }
]
Clone this wiki locally