Skip to main content

Metrics

Ingestion (sending metrics to CubeAPM)

CubeAPM can ingest metrics in OpenTelemetry (OTLP) and Prometheus formats.

OTLP Endpoint: POST http://<ip_address_of_cubeapm_server>:3130/api/metrics/v1/save/otlp

Prometheus Text Exposition Endpoint: POST http://<ip_address_of_cubeapm_server>:3130/api/metrics/v1/save

Prometheus Remote Write Endpoint: POST http://<ip_address_of_cubeapm_server>:3130/api/metrics/api/v1/write

Querying (fetching metrics from CubeAPM)

Instant Query API

The Instant Query API evaluates the specified query at a single point in time. It is useful for fetching the current state of a system or evaluating expressions for a specific timestamp.

Endpoint: POST http://<ip_address_of_cubeapm_server>:3140/api/metrics/api/v1/query

Request Parameters

ParameterTypeDescription
querystringThe metrics query.
timestring/integerTime instant at which to evaluate the query. Can be provided either in RFC3339 format or as a Unix timestamp in seconds.
stepinteger(Optional) Time window in seconds over which to process data.

curl

curl 'http://<ip_address_of_cubeapm_server>:3140/api/metrics/api/v1/query' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'query=<query>' \
--data-urlencode 'time=1760419800' \
--data-urlencode 'step=900'

Response Format

The response format is compatible with Prometheus instant query API response format.

FieldTypeDescription
statusstring"success" if the query executed correctly, "error" otherwise.
isPartialbooleanIndicates if the result is partial due to incomplete data.
data.resultTypestringType of result: "vector", "matrix", "scalar", or "string".
data.resultarrayList of metric results.
data.result[].metricobjectKey-value pairs of metric labels (can be empty).
data.result[].valuearray[timestamp, value] — the timestamp in Unix seconds and the corresponding metric value as a string.

For example

{
"status": "success",
"isPartial": false,
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"service": "order"
},
"value": [1760419800, "0.00300043554195535"]
}
]
}
}

Range Query API

The Range Query API processes metric data over a range of time. It is commonly used for plotting graphs or analyzing historical performance.

Endpoint: POST http://<ip_address_of_cubeapm_server>:3140/api/metrics/api/v1/query_range

Request Parameters

ParameterTypeDescription
querystringThe metrics query.
startstring/integerStart timestamp. Can be provided either in RFC3339 format or as a Unix timestamp in seconds.
endstring/integerEnd timestamp. Can be provided either in RFC3339 format or as a Unix timestamp in seconds.
stepintegerQuery resolution step width in seconds.

curl

curl 'http://<ip_address_of_cubeapm_server>:3140/api/metrics/api/v1/query_range' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'query=<query>' \
--data-urlencode 'start=1760254200' \
--data-urlencode 'end=1760254200' \
--data-urlencode 'step=900'

Response Format

FieldTypeDescription
statusstring"success" if the query executed correctly, "error" otherwise.
isPartialbooleanIndicates if the result is partial due to incomplete data.
data.resultTypestringType of result: "vector", "matrix", "scalar", or "string".
data.resultarrayList of metric results. Each item contains:
data.result[].metricobjectKey-value pairs of metric labels (can be empty).
data.result[].valuearray[timestamp, value] — the timestamp in Unix seconds and the corresponding metric value as a string.

For example

{
"status": "success",
"isPartial": false,
"data": {
"resultType": "matrix",
"result": [
{
"metric": {
"service": "order"
},
"values": [
[1760341500, "0.003422755399606299"],
[1760342400, "0.0024741669999999993"],
[1760345100, "0.003420891768172888"],
[1760346900, "0.001477216900355872"]
]
}
]
}
}