Metrics
Get Togai Metrics
Togai Metrics API allows you to fetch different metrics from Events, Usage Meters and PricePlans with multiple queryable options.
A single request can query up to five metrics.
Single response can contain a maximum of 100 data points.
POST
/
metrics
curl --request POST \
--url https://api.togai.com/metrics \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{
"startTime": "2017-07-21T00:00:00Z",
"endTime": "2017-07-22T00:00:00Z",
"metricQueries": [
{
"id": "m1",
"name": "EVENTS",
"aggregationPeriod": "DAY",
"filters": [
{
"fieldName": "ACCOUNT_ID",
"fieldValues": [
"account#1"
]
},
{
"fieldName": "CUSTOMER_ID",
"fieldValues": [
"customer#1"
]
},
{
"fieldName": "EVENT_STATUS",
"fieldValues": [
"PROCESSED"
]
}
]
},
{
"id": "m2",
"name": "USAGE",
"aggregationPeriod": "MONTH",
"filters": [
{
"fieldName": "CUSTOMER_ID",
"fieldValues": [
"customer#1"
]
}
]
}
]
}'
{
"results": [
{
"id": "m1",
"name": "EVENTS",
"data": {
"timestamps": [
"2017-07-21T00:00:00Z",
"2017-07-22T00:00:00Z"
],
"metricValues": [
53,
32
]
}
},
{
"id": "m2",
"name": "USAGE",
"data": {
"timestamps": [
"2017-07-01T00:00:00Z"
],
"metricValues": [
123.45
]
}
}
]
}
MetricQuery: Allowed field combinations
Authorizations
Authorization
string
headerrequiredBearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
startTime
string
requiredStart date time of the query (inclusive)
endTime
string
requiredEnd date time of the query (exclusive)
metricQueries
object[]
requiredResponse
200 - application/json
results
object[]
requiredcurl --request POST \
--url https://api.togai.com/metrics \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{
"startTime": "2017-07-21T00:00:00Z",
"endTime": "2017-07-22T00:00:00Z",
"metricQueries": [
{
"id": "m1",
"name": "EVENTS",
"aggregationPeriod": "DAY",
"filters": [
{
"fieldName": "ACCOUNT_ID",
"fieldValues": [
"account#1"
]
},
{
"fieldName": "CUSTOMER_ID",
"fieldValues": [
"customer#1"
]
},
{
"fieldName": "EVENT_STATUS",
"fieldValues": [
"PROCESSED"
]
}
]
},
{
"id": "m2",
"name": "USAGE",
"aggregationPeriod": "MONTH",
"filters": [
{
"fieldName": "CUSTOMER_ID",
"fieldValues": [
"customer#1"
]
}
]
}
]
}'
{
"results": [
{
"id": "m1",
"name": "EVENTS",
"data": {
"timestamps": [
"2017-07-21T00:00:00Z",
"2017-07-22T00:00:00Z"
],
"metricValues": [
53,
32
]
}
},
{
"id": "m2",
"name": "USAGE",
"data": {
"timestamps": [
"2017-07-01T00:00:00Z"
],
"metricValues": [
123.45
]
}
}
]
}