Metrics API
MetricResourceApi provides read and write access to time-series data — one of the most frequently used modules.
Method Summary
| Method | HTTP | Description |
|---|---|---|
| apiV1MetricsIdHistoryGet | GET /api/v1/metrics | List metrics |
| apiV1MetricsIdHistoryGet | GET /api/v1/metrics/{id}/history | Query historical data |
| apiV1MetricsIdHistoryGet | GET /api/v1/metrics/{id}/latest | Get latest value |
| apiV1MetricsIdHistoryGet | POST /api/v1/metrics/{id}/data | Write data points |
Query Historical Data
Query data points within a time range, with optional aggregation.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Metric ID |
| from | long | Yes | Start time, Unix milliseconds |
| to | long | Yes | End time, Unix milliseconds |
| interval | string | No | Aggregation window, e.g. 1m, 1h. Omit for raw data. |
| aggregate | string | No | Aggregation function: avg, max, min, sum |
Returns MetricDataDTO
Example
- Python
- Java
import time
metric_api = idmp_sdk.MetricResourceApi(api_client)
now_ms = int(time.time() * 1000)
one_hour_ago_ms = now_ms - 3600 * 1000
# TODO: fill in actual method name from OpenAPI spec
# result = metric_api.apiV1MetricsIdHistoryGet(
# id="metric-id-123",
# from_ts=one_hour_ago_ms,
# to_ts=now_ms,
# interval="1m",
# aggregate="avg"
# )
// TODO: fill in actual method name from OpenAPI spec
note
Method names marked apiV1MetricsIdHistoryGet need to be filled in from the OpenAPI spec (idmp-v\{SDK_VERSION\}.json).
