Skip to main content
Version: 24.05

Performance Monitoring - Samples

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint​

/o/apm/samples

Overview​

Returns a page of the individual samples of one metric of a network or device trace, newest first.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

  • Requires Read permission for the Performance Monitoring feature (performance_monitoring) in the target app.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key authentication
auth_tokenStringYes (or api_key)Auth token authentication
app_idStringYesID of the app the trace belongs to.
idStringYesTrace ID, as returned in the id field of the traces listed by the Performance Monitoring read endpoints.
typeStringYesTrace type, network or device.
metricStringYesName of the metric, for example response_time or duration.
periodStringYesPeriod of the data: month, day, yesterday, hour, NUMBERdays (for example 30days) or a custom range as a JSON array.
queryString (JSON)NoFilter on the samples, as a JSON user query.
iDisplayStartNumberNoNumber of samples to skip. Defaults to 0.
iDisplayLengthNumberNoNumber of samples to return. Defaults to 10.
sEchoStringNoValue echoed back in the response, for DataTables paging.

Examples​

Example: Read the first ten samples​

curl "https://your-server.com/o/apm/samples?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&id=TRACE_ID&type=network&metric=response_time&period=30days"

Response​

Success Response​

{
"sEcho": "1",
"iTotalRecords": 16,
"iTotalDisplayRecords": 16,
"aaData": [
{
"_id": "SAMPLE_ID",
"uid": "USER_ID",
"did": "DEVICE_ID",
"ts": 1649323200000,
"sg": {
"name": "example.com/demo/",
"apm_metrics": {
"response_time": 106
},
"stz": 1649323200000,
"etz": 1649323200106
}
}
]
}

Response Fields​

FieldTypeDescription
sEchoStringThe sEcho value of the request.
iTotalRecordsNumberTotal number of samples that match.
iTotalDisplayRecordsNumberSame as iTotalRecords.
aaDataArrayThe samples of the requested page. Each has the user (uid), device (did), time (ts) and the trace data (sg: name, apm_metrics, stz, etz).

Error Responses​

  • HTTP 400 - Invalid request:
{
"result": "Unacceptable trace type."
}

Other messages for HTTP 400: Trace id not provided., Metric not provided., Missing request parameter: period, Bad request parameter: period, Samples data could not be fetched.. A query that cannot be parsed is also rejected with HTTP 400.

Behavior​

  • Samples are sorted by time, newest first.
  • When sample-level data is not stored for the app, the response is {"trace": "<trace name>", "ts": 0, "samples": []}.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
Drill events collection of the trace typeSamplesReads the samples of the trace in the period.