Skip to content

Get multiple counters

Jon Watte edited this page Sep 9, 2013 · 2 revisions

Home - HTTP Interface - Get multiple counters

Usage

POST /*

Parameters

The POST data contains a JSON object value, sort of like this:

{
    "start": START,
    "end": END,
    "maxSamples": MAX,
    "keys": ["counter.name", "yet.another.counter.name"],
    "trailing": 0
}

These are the entries that can appear in the object:

  • keys - A required list of counter names to grab data for. This is an array of strings.
  • maxSamples - The maximum number of samples that should be returned by this search. Used to simplify datasets for graphing.
  • start - An optional Unix timestamp specifying the lower time bound to use. (Default: 15 minutes before end)
  • end - An optional Unix timestamp specifying the upper time bound to use. (Default: now)
  • trailing - An optional value of 0 or 1 to read trailing averages (seasonal, lambda-based values) instead of regular counter history.
  • The value of end must be >= start.

Overview

Use this URI to get data for multiple counters at once, and then down-size the number of samples. It's extremely useful for generating fixed-size graphs with multiple plots.

Returns the data for each counter specified, in succession.

Response

When the request is well-formed, with all of its required parameters,

  • Status code: 200

Response body:

{
    // A list of all names that match the pattern given.
    "start": int, // The start time that was passed to this request, or 0 if none was given.
    "end":   int, // The end time that was passed to this request, or 0 if none was given.
    // The name of a counter that was asked for in the 'keys' parameter.
    "counter.name": {
        "interval": int,
        // A list of buckets of data within this time range. Possibly empty.
        "data": [
            // One bucket of data in the list. 
            {
                "time":  int,   // When this bucket was recorded. A unix timestamp.
                "count": int,   // Number of values in the bucket.
                "min":   float, // Minimum of all values in the bucket.
                "max":   float, // Maximum of all values in the bucket.
                "sum":   float, // Sum of each value in this bucket.
                "sumsq": float, // Sum of each value squared in this bucket.
                "avg":   float, // The average of the bucket, or the number 0 if the count is zero.
                "sdev":  float  // The standard deviation of the bucket, or the number 0 if the count is less than 2.
            }
            // ... the rest of the data. There will be at most maxSamples number of data entries for this counter.
        ]
    },
    // This is what you get if a counter does not exist.
    "something.that.does.not.exist": "Not found",
    // ... the rest of the keys
}

When a request that does not specify `keys` in its POST data,
  • Status code: 400

Trailing counters

If you have configured seasonal averages, the trailing=1 parameter will request those instead of the regular counter history. If there is more than one season, the shortest season that covers the given time interval will be selected.

Clone this wiki locally