Skip to content

API Reference

sbtourist edited this page Nov 18, 2012 · 4 revisions

Nimrod 0.6 API Reference (WORK-IN-PROGRESS)

All Nimrod APIs are exposed over the HTTP protocol, and return JSON data.

GET /logs

Query all logs Nimrod has been configured to process.

Return codes:

  • 200: Success.

POST /logs/{log_id}/stop

Stop processing a given log.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.

Return codes:

  • 204: Success.
  • 404: No log found for the given id.

GET /logs/{log_id}

Query, for a given log, all metric types containing at least one metric value.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.

Return codes:

  • 200: Success.
  • 404: No log found for the given id, or no metrics associated with it.

GET /logs/{log_id}/{metric_type}

Query for a given log and metric type, all associated metric identifiers.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.

Return codes:

  • 200: Success.
  • 404: No metrics found for the given log and type.

GET /logs/{log_id}/{metric_type}/{metric_id}

Query for a given log and metric type, the latest value for a given metric identifier.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.
  • metric_id: The metric identifier.

Return codes:

  • 200: Success.
  • 404: No value found for the given log, type and id.

GET /logs/{log_id}/{metric_type}/{metric_id}/history

Query for a given log, metric type and metric identifier, its time-series history, in descending order.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.
  • metric_id: The metric identifier.

Query Parameters:

  • age: maximum age for returned metric values (only used if no to/from is provided), either in milliseconds or age-expression (see below).
  • from: Time of the first metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).
  • to: Time of the last metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).
  • tags: Comma-separated list of tags to use for further filtering the returned metric values.

If no age or time parameters are provided, a default 1 minute age is assumed.

Return codes:

  • 200: Success.
  • 404: No history found for the given log, type and id, or for the given time period and tags.

GET /logs/{log_id}/{metric_type}/{metric_id}/history/aggregate

Query for a given log, metric type and metric identifier, its time-series history, in order to produce a statistical aggregate with count, median, mean, variance and percentiles.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.
  • metric_id: The metric identifier.

Query Parameters:

  • age: maximum age for returned metric values (only used if no to/from is provided), either in milliseconds or age-expression (see below).
  • from: Time of the first metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).
  • to: Time of the last metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).
  • percentiles: Comma-separated list of percentages for percentiles calculation.

If no age or time parameters are provided, a default 1 minute age is assumed.

Return codes:

  • 200: Success.
  • 404: No history found for the given log, type and id, or for the given time period and tags.

POST /logs/{log_id}/{metric_type}/{metric_id}/history/delete

Delete for a given log, metric type and metric identifier, its time-series history, but keeps its latest computed value.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.
  • metric_id: The metric identifier.

Query Parameters:

  • age: maximum age for returned metric values (only used if no to/from is provided), either in milliseconds or age-expression (see below).
  • from: Time of the first metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).
  • to: Time of the last metric value to return, either as a Unix timestamp in milliseconds resolution or time-expression (see below).

If no age or time parameters are provided, a default 1 minute age is assumed.

Return codes:

  • 204: Success.
  • 404: No history found for the given log, type and id, or for the given time period and tags.

POST /logs/{log_id}/{metric_type}/{metric_id}/reset

Reset for a given log, metric type and metric identifier, its latest value (and related running statistical computations), but keeps its history.

URL Parameters:

  • log_id: The identifier of the log, as previously configured.
  • metric_type: The metric type in plural form, either alerts, counters, gauges or timers.
  • metric_id: The metric identifier.

Return codes:

  • 204: Success.
  • 404: No value found for the given log, type and id.

Age and Time Expressions

You can express metrics age in queries above by using an age-expression, composed as follows:

  • Time quantity (any integer value).
  • Time unit.
    • d as day.
    • h as hour.
    • m as minute.
    • s as second.

Examples: 1d (one day), 1h (one hour), 5m (five minutes), 10s (ten seconds).

Similarly, you can express to/from time intervals in queries above by using a time-expression, composed as follows:

  • Time quantity (any integer value).
  • Time unit.
    • d as day.
    • h as hour.
    • m as minute.
    • s as second.
  • .ago suffix (fixed).

Examples: 1d.ago (one day), 1h.ago (one hour), 5m.ago (five minutes), 10s.ago (ten seconds).

CORS Support

Cross-Origin Resource Sharing is a W3C specification, implemented in latest browsers, to allow javascript code to request resources on remote, different, hosts: this comes in handy if you want to access Nimrod HTTP metrics from a diffrent host, i.e. to draw some graphs.

Nimrod provides some preliminary support for CORS: i.e., all GET-based APIs can be invoked from any host within any CORS-enabled browser. In the future, support for restricting access to given hosts only, and invoking non-GET methods, will be added.