Show meter statistics (GET /v2/meters/{meter_name}/statistics)

Computes and lists statistics for samples in the specified time range.

{meter_name}: Name of the meter from which to retrieve samples.

Request headers

Refer to "Common API items".

Request parameters

q.field

Specifies the following fields for query.

  • resource_id: ID of the resource.
  • source: Source meter.
  • timestamp: Aggregation start/end time
    • If timestamp is omitted, the search conditions are set with "timestamp >= currentTime - (period x 1440)" (*1) as the aggregation start time, and "timestamp < currentTime" as the aggregation end time (when the period is 60 (seconds), the range will be up to one day).
    • If only the aggregation start time is specified for timestamp, the search conditions are set with the following as the aggregation end time: "aggregationStartTime + (period x 1440) > timestamp" (*1).
    • If only the aggregation end time is specified for timestamp, the search conditions are set with the following as the aggregation start time: "aggregationEndTime - (period x 1440) <= timestamp" (*1).
    • An error will occur if the range (seconds) of the aggregation start and end times for timestamp is larger than the (period x 1440) value.

    *1: If the (period x 1440) value is more than 1209600 (two weeks), it will be handled as 1209600.

  • user_id: ID of the user that created the meter.

If omitted, the aggregate results of all samples of the specified meter will be output.

Data type Cardinality
String 0..10

q.op

Specifies the comparison operator described below.

  • If q.field is "resource_id":

    eq: Equal to

  • If q.field is "source":

    eq: Equal to

  • If q.field is "timestamp":

    gt: Greater than

    ge: Greater than or equal to

    lt: Less than

    le: Less than or equal to

  • If q.field is user_id:

    eq: Equal to

If omitted, "eq" is used.

Data type Cardinality
String 0..10

q.value

Specifies the following data value targeted for comparison.

  • If q.field is "resource_id":

    Resource ID

  • If q.field is "source":

    Source

  • If q.field is "timestamp":

    Datetime (YYYY-MM-DDThh:mm:ss)

  • If q.field is user_id:

    User ID

Valid characters: Fullwidth characters, halfwidth alphanumeric characters and halfwidth symbols

Number of characters: 1 to 255

Data type Cardinality
String 0..10

groupby

Specifies the following field if aggregating by field.

  • resource_id
  • user_id

If omitted, aggregation will not be performed by field.

Data type Cardinality
String 0..1

period

Specifies the aggregation interval (seconds).

Range: 60 to 1209600 (can only be specified in multiples of 60)

If omitted, the aggregate results of all samples of the specified range are output.

Data type Cardinality
int 0..1

aggregate.func

Specifies the following aggregation functions.

  • avg: average value
  • count: number of samples
  • max: maximum value
  • min: minimum value
  • sum: total value

If omitted, the results of all aggregation functions will be output.

Data type Cardinality
String 0..10

Response headers

Status

If normal, the following status is returned.

200: Normal completion

Refer to "Common API error codes" if the state is error.

Data type Cardinality
Int 1..1

Response elements

Returns a list of aggregation results in JSON format.

Refer to "type Statistics" for details.

Example of request

Example 1: Specify the datetime of the sample and the user ID for "groupby", and retrieve statistics by user within a specific time range.


curl -H 'X-Auth-Token: ImFkbWluVVJMIjogImh0dHA6Ly8xMC4x . . .' \
'https://telemetry.jp-east-1.cloud.global.fujitsu.com/v2/meters/my_meter/statistics?groupby=user_id&q.field=timestamp&q.op=gt&q.value=2014-10-22T00:00:00&
q.field=timestamp&q.op=lt&q.value=2014-10-23T00:00:00'
     

Example 2: Specify the aggregation interval and aggregation function, and retrieve the maximum and minimum values on an hourly basis.


curl -H 'X-Auth-Token: ImFkbWluVVJMIjogImh0dHA6Ly8xMC4x . . .' \
'https://telemetry.jp-east-1.cloud.global.fujitsu.com/v2/meters/my_meter/statistics?period=3600&aggregate.func=max&aggregate.func=min'
     

Example of response


[
    {
        "avg": 0.041790414908881302,
        "count": 1716,
        "duration": 89950.0,
        "duration_end": "2014-10-23T00:59:22",
        "duration_start": "2014-10-22T00:00:12",
        "groupby": {
            "user_id": "f2ee0c983abf4c65aa44b3328b8a484f"
        },
        "max": 0.314285714285714,
        "min": 0.0172413793103448,
        "period": 0,
        "period_end": "2014-10-23T00:59:22",
        "period_start": "2014-10-22T00:00:12",
        "sum": 71.712351983640303,
        "unit": "%"
    },
    {
        "avg": 0.048886882955332202,
        "count": 905,
        "duration": 89858.0,
        "duration_end": "2014-10-23T00:59:05",
        "duration_start": "2014-10-22T00:01:27",
        "groupby": {
            "user_id": "0d6293fbdf8948f090b8195bebd8ee8b"
        },
        "max": 0.36956521739130399,
        "min": 0.0280373831775701,
        "period": 0,
        "period_end": "2014-10-23T00:59:05",
        "period_start": "2014-10-22T00:01:27",
        "sum": 44.242629074575603,
        "unit": "%"
    }
]