2.0 KiB
2.0 KiB
Weights API (Metric Correlations)
Same scoring engine as desktop Find Correlations. Available over REST and P2P RPC.
REST
GET /api/v1/weights
GET /api/v2/weights
GET /api/v3/weights
Query parameters
| Param | Default | Description |
|---|---|---|
method |
volume when windows set; else alerts |
volume | ks2 | anomaly-rate | value | alerts |
after |
— | Highlight start (unix seconds, or relative) |
before |
— | Highlight end |
baseline_after |
auto | Baseline start (MC methods) |
baseline_before |
auto | Baseline end |
points |
500 |
Cap samples per series (max ~10000) |
time_group |
cv for value |
Aggregation for value method |
contexts |
— | Filter contexts |
chart / charts |
— | Filter chart ids |
dimensions |
— | Dimension filter |
limit |
— | Max results |
timeout |
— | Scoring budget (ms) |
Without highlight windows, the agent returns legacy alert weights (method=alerts) so Related-panel boosts keep working.
Example
# Highlight last 60s; baseline auto (≈4× preceding)
curl -sG 'http://127.0.0.1:18888/api/v3/weights' \
--data-urlencode 'method=volume' \
--data-urlencode 'after=-60' \
--data-urlencode 'before=0' \
--data-urlencode 'limit=30'
(Default REST port is 18888; override with PEARDATA_REST_PORT.)
Response shape (conceptual)
{
"method": "volume",
"view": {
"highlight": { "after": 0, "before": 0 },
"baseline": { "after": 0, "before": 0 }
},
"results": [
{ "id": "system.cpu", "weight": 0.92, "context": "system.cpu", "family": "cpu" }
],
"stats": { "scored": 120, "elapsed_ms": 40 }
}
Higher weight ⇒ more changed for MC methods.
RPC
Method: getWeights
Same argument fields as the query table. Used by the desktop Charts tab and Related alert boost.
See also docs/REST-API.md and docs/PROTOCOL.md.