I'm trying to get multiple time series using stackdriver api. Specifically, GCP load balancer data. Using the stackdriver dashboard I've created a chart with some params and it works well, displaying all different time series answering the filters. I've copied the same params to the API playground and the json response returning a single time series (probably the first).
This is the query (taken from the playground console):
return gapi.client.monitoring.projects.timeSeries.list({
"name": "projects/my_project",
"aggregation.alignmentPeriod": "60s",
"aggregation.crossSeriesReducer": "REDUCE_SUM",
"aggregation.groupByFields": [
"metric.label.cache_result",
"metric.label.response_code"
],
"aggregation.perSeriesAligner": "ALIGN_RATE",
"filter": "metric.type=\"loadbalancing.googleapis.com/https/request_count\" AND resource.label.forwarding_rule_name=\"my_rule_name\"",
"interval.endTime": "2018-11-16T15:04:05Z",
"interval.startTime": "2006-11-15T11:04:05Z",
"pageSize": 1,
"view": "FULL"
})
REST response:
{
"timeSeries": [
{
"metric": {
"labels": {
"response_code": "0",
"cache_result": "DISABLED"
},
"type": "loadbalancing.googleapis.com/https/request_count"
},
"resource": {
"type": "https_lb_rule",
"labels": {
"project_id": "my_project_id"
}
},
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"points": [
{
"interval": {
"startTime": "2018-11-15T13:12:05Z",
"endTime": "2018-11-15T13:12:05Z"
},
"value": {
"doubleValue": 0.05
}
}
]
}
],
"nextPageToken": "CPvK9vuH/qibZxJtIh0KEAoGCKXhtd8FEgYIpeG13wUSCRmamZmZmZmpPyoNaHR0cHNfbGJfcnVsZTI9chkKFWfdsfpYzovcmVzcG9uc2VfY29kZRAAciAKFG1ldHJpYzovY2FjaGVfcmVzdWx0GghESVNBQkxFRA=="
}
The actual chart I'm expecting to get (from SD console - same params):
In the request you pass "pageSize": 1
which tells the api to only return 1 result. Removing this parameter would allow it to return up to 100k results in a single response.
As "view": "FULL"
is passed, each result is a single point in the timeseries. If you remove the pageSize
parameter or increase it and still don't get all of the points back in a single response because there are too many, you can pass the same request with pageToken
set to the nextPageToken
of the prior response to get the next set of results.
More information here: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list#body.QUERY_PARAMETERS.page_size