Usage Filtering

Query Usage data

https://docs.amberflo.io/reference/post_usage

Usage API payload:

PropertyDescriptionRequired
meterApiName meterApiName as defined in meter-definition APIYes
aggregation Aggregation function: 'SUM', 'COUNT', 'MIN', 'MAX'Yes
timeGroupingInterval Valid time-slot or bucket size: 'HOUR', 'DAY', 'WEEK', 'MONTH'Yes
timeRange.startTimeInSecondsStart date time represented as seconds since the Unix Epoch (1970-01-01T00:00:00Z) and using UTC.

For example, 1619293642 => 2021-04-26T20:03:33.263Z
Yes
timeRange.endTimeInSecondsOptional. The end of search time range.No
groupBy Defines the groupBy attributes for aggregating the data. If no groupBy is defined, the data will be aggregated for the meter as a whole. Valid groups: customerId or Any dimension defined in meter-definition API (for example: region, customerType).No
filterwhere clause for the usage query. Valid filters: customerId or Any dimension defined in meter-definition API (for example: region, customerType).No
take Setting for result set.
"limit": number of records
"isAscending" (default is false)
No

POST https://app.amberflo.io/usage-java

{
    "meterApiName": "ApiCalls",
    "aggregation": "SUM",
    "timeGroupingInterval": "Day",
    "timeRange": {
        "startTimeInSeconds": 1619293642
    },
    "filter": { "customerId": ["xxx", "yyy"]},
    "groupBy": ["customerId"],
    "take": {
        "limit": 10,
        "isAscending": false
    }
}

API response breakdown:

SegmentDescription
metadata Embeds the usage query payload from the request for reference purposes
secondsSinceEpochIntervals Buckets or time-slots with the starting at time in seconds since the Unix Epoch (1970-01-01T00:00:00Z) and using UTC for time representation

The query was run for usage activity in last 2 days with start time at
1619293642 => 2021-04-26T20:03:33.263Z

In this example, following are the buckets:
1619222400 => 2021-04-24T00:00:00.000Z
1619308800 => 2021-04-25T00:00:00.000Z
1619395200 => 2021-04-26T00:00:00.000Z
clientMetersAn array for each aggregation group as defined by groupBy and filter in the usage query
clientMeters[x].group.groupInfoIncludes group info, group name and value by which the data is aggregated. If groupBy was not set in request query, this will be null.
clientMeters[x].group.groupValue Aggregated value for the group for all buckets
clientMeters[x].group.valuesPer bucket aggregate as listed in secondsSinceEpochIntervals
clientMeters[x].group.values.percentageFromPreviousPercent change from previous bucket

Sample API response:

{
    "metadata": {
        "account": null,
        "meterApiName": "ApiCalls",
        "aggregation": "sum",
        "timeRange": {
            "startTimeInSeconds": 1619294851,
            "endTimeInSeconds": 1619467650
        },
        "filter": {
            "customerId": [
                "xxx",
                "yyy"
            ]
        },
        "groupBy": [
            "customerId"
        ],
        "take": {
            "limit": 10,
            "isAscending": false
        },
        "timeGroupingInterval": "day"
    },
    "secondsSinceEpochIntervals": [
        1619222400,
        1619308800,
        1619395200
    ],
    "clientMeters": [
        {
            "group": {
                "groupInfo": {
                    "customerId": "xxx"
                }
            },
            "groupValue": 23645.0,
            "values": [
                {
                    "percentageFromPrevious": 0.0,
                    "value": 0.0,
                    "secondsSinceEpochUtc": 1619222400
                },
                {
                    "percentageFromPrevious": 100.0,
                    "value": 4040.0,
                    "secondsSinceEpochUtc": 1619308800
                },
                {
                    "percentageFromPrevious": 385.2722772277228,
                    "value": 19605.0,
                    "secondsSinceEpochUtc": 1619395200
                }
            ]
        },
        {
            "group": {
                "groupInfo": {
                    "customerId": "yyy"
                }
            },
            "groupValue": 22608.0,
            "values": [
                {
                    "percentageFromPrevious": 0.0,
                    "value": 0.0,
                    "secondsSinceEpochUtc": 1619222400
                },
                {
                    "percentageFromPrevious": 100.0,
                    "value": 2507.0,
                    "secondsSinceEpochUtc": 1619308800
                },
                {
                    "percentageFromPrevious": 701.7949740725967,
                    "value": 20101.0,
                    "secondsSinceEpochUtc": 1619395200
                }
            ]
        }
    ]
}