Skip to content
v1
Docs

REST API

Charting custom metrics

This guide charts and summarises your organisation’s custom metrics with the API alone: each value as it was pushed, a series at the aggregation and step you choose, every metric of a source in one call, a window’s statistics, the metrics that carry alarms and the incidents of a source. Times are epoch milliseconds and windows take period, or from and to, as everywhere in the API (times and windows).

Every read below needs custom_metrics.view, besides the same permission on the role of the key’s owner. Reading alarms adds alarms.view, and incidents incidents.view. See authentication and keys.

A series answers one point a step, and a level metric read without an aggregation answers its value at each step: one push can read as a flat stretch over several steps, and two pushes of the same value one after the other look like one. When each push matters (a deploy’s duration, a job’s run), read the samples: each value with the time it was pushed.

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/custom-metrics/$METRIC_UUID/samples \
-H "Authorization: Bearer $WT15_API_KEY" \
-d period=6h \
-d per_page=1000
{
"data": {
"available": true,
"reason": null,
"metric": { "uuid": "<metric uuid>", "name": "Deploy duration", "metric_key": "deploy.run.seconds", "metric_type": "level", "unit": "s" },
"window": { "from": 1795000000000, "to": 1795021600000 },
"samples": [[1795003512431, 442], [1795011207118, 440]],
"next_cursor": null,
"total": 2
}
}
  • The window defaults to the last hour and spans at most 1 day. window is read after from and up to to.
  • Samples come oldest first, each [t, value] with t in epoch milliseconds as pushed. Two samples pushed at one time are both listed.
  • A page holds up to per_page samples (limit is the same): 1 to 10,000, 1,000 by default. The samples page by time: send next_cursor back as cursor for the next page, with the same parameters; the cursor keeps the first page’s window, so a period does not slide between pages. next_cursor is null on the last page. page is not taken here.
  • total is how many samples the window holds, counted on the first page and carried by the cursor, so every page of one walk answers the same total. It is 0 for an approved metric with no sample in the window, and null while the metric awaits approval.
  • Each page first counts the samples left in its window. More than 100,000 is 422 invalid_request on period (on from when you sent from and to), naming the count: ask for a shorter window.
Terminal window
curl -sS -G https://rest.watchtower15.com/v1/custom-metrics/$METRIC_UUID/series \
-H "Authorization: Bearer $WT15_API_KEY" \
-d period=31d \
-d aggregation=max \
-d step=1d
{
"data": {
"available": true,
"reason": null,
"aggregation": "max",
"metric": { "uuid": "<metric uuid>", "name": "Deploy duration", "metric_key": "deploy.run.seconds", "metric_type": "level", "unit": "s" },
"window": { "from": 1792321600000, "to": 1795000000000 },
"source": "custom",
"step_seconds": 86400,
"series": [
{
"name": "deploy.run.seconds",
"unit": "s",
"labels": { "mount": null, "device": null, "interface": null, "state": null, "cpu": null },
"point_meaning": "value_per_step",
"points": [[1792368000000, 431], [1792454400000, 442], [1792540800000, 418]]
}
]
}
}

aggregation is what each point holds of the samples in its step. The metric’s supported_aggregations (on GET /v1/custom-metrics/{custom_metric_uuid}) lists what it takes:

Metric type Takes Omitted
level avg, min, max or last the value at each step
count sum the sum, the same as sum

Another value is 422 invalid_request on aggregation (“A level metric takes the aggregation avg, min, max, last.”). The answer’s aggregation is the one sent, or null. With an aggregation a step with no sample is a missing point, never a zero.

step is the width of a point: 30s, 1m, 5m, 30m, 2h, 6h, 1d or 1w, and step_seconds says it in seconds. Omitted, the window’s length chooses it:

Window up to 1 hour 6 hours 1 day 7 days 31 days 92 days 400 days longer
Step 30s 1m 5m 30m 2h 6h 1d 1w

A step that cuts the window into more than 720 points is 422 invalid_request on step, naming the smallest step allowed: step=2h takes 60 days, and 61 days asks for 6h.

Each point summarises the step that ends at its time. With step=1d the point at 00:00 UTC on a day holds the whole day before (00:00 to 24:00 UTC), so a sample pushed at 02:00 UTC on 3 November is in the point at 00:00 UTC on 4 November. The window is widened to whole steps, so the first point can sit one step before window.from.

By default a 1d point sits at 00:00 UTC. Send tz, an IANA time zone name such as Europe/London, and the 1d points sit at the zone’s local midnights (a 1w point on the zone’s Monday), each still holding the step that ends at it:

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/custom-metrics/$METRIC_UUID/series \
-H "Authorization: Bearer $WT15_API_KEY" \
-d from=2026-10-22T00:00:00Z -d to=2026-10-28T00:00:00Z \
-d step=1d -d tz=Europe/London
{ "data": { "tz": "Europe/London", "step_seconds": 86400, "series": [{ "points": [[1792882800000, 12], [1792972800000, 25], [1793059200000, 11]] }] } }

London’s clocks went back on 25 October, so that local day was 25 hours long: the point at midnight on the 26th (1792972800000) is 90,000,000 ms after the one before it, not 86,400,000. Across a clock change the points’ own times govern, not window.from plus step_seconds. The sum or value in each point is exact for its local day. A zone whose clock skips midnight has no 00:00 that day, so its point sits at the day’s first local instant (America/Santiago’s change in September: 01:00). tz=UTC puts 1w points on Mondays where no tz keeps them on Thursdays. With any other step tz changes nothing. An unknown zone is 422 invalid_request on tz; backward names such as US/Eastern are accepted.

A series window reaches back as far as the metric is kept, 1,095 days (its retention_days). The store reads at most 30,000,000 samples of one metric in one query, whatever the step, so a dense metric’s longest window is shorter: about 300 days for a metric pushed at the default 100,000 points a day. A longer window, on any read in this guide, is 422 invalid_request on period (or from): “This window holds more samples than the store reads in one query; ask for a shorter window.” Read a long history in shorter windows, one after the other.

GET /v1/metric-sources/{metric_source_uuid}/series answers the series of every metric of a source, the metrics that GET /v1/custom-metrics?metric_source_uuids= lists for it, ordered by name, then key:

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/metric-sources/$SOURCE_UUID/series \
-H "Authorization: Bearer $WT15_API_KEY" \
-d period=7d \
-d aggregation=avg
{
"data": [
{
"available": true,
"reason": null,
"aggregation": "avg",
"metric": { "uuid": "<metric uuid>", "name": "Deploy duration", "metric_key": "deploy.run.seconds", "metric_type": "level", "unit": "s" },
"series": [{ "name": "deploy.run.seconds", "unit": "s", "labels": { … }, "point_meaning": "value_per_step", "points": [[1794396600000, 436.5], …] }]
},
{
"available": true,
"reason": null,
"aggregation": "sum",
"metric": { "uuid": "<metric uuid>", "name": "Deploys", "metric_key": "deploy.runs", "metric_type": "count", "unit": null },
"series": [{ "name": "deploy.runs", "unit": null, "labels": { … }, "point_meaning": "count_per_step", "points": [[1794396600000, 2], …] }]
}
],
"current_page": 1,
"per_page": 25,
"last_page": 1,
"total": 2,
"meta": { "window": { "from": 1794395200000, "to": 1795000000000 }, "step_seconds": 1800 }
}
  • Each item is the metric’s /series answer without window; the window and the step are given once, in meta.
  • period, from, to and step work as on /series. aggregation takes avg, min, max or last, and applies to the source’s level metrics: a count metric always reads its sum, and its item says sum. aggregation=sum is refused.
  • 25 metrics a page (per_page 1 to 25; limit is the same); send page for another (pagination).
  • A step over 720 points is refused for the whole call. A metric whose window passes the store’s sample limit ends the page with the 422 above, and a store that does not answer within 10 seconds with 503 store_unavailable: no item is ever left empty because a read failed.
  • A metric awaiting approval is listed with available: false, reason: awaiting_approval and no series.

GET /v1/custom-metrics/{custom_metric_uuid}/summary answers statistics of the metric’s raw samples over a window, and GET /v1/metric-sources/{metric_source_uuid}/summary the same for every metric of a source, 25 a page, ordered and paged as the source’s series is, with the window once in meta. The window defaults to the last day and has no longest window: it reaches back to the metric’s retention, 1,095 days, and an earlier start is served from it. It holds the samples after from and up to to.

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/custom-metrics/$METRIC_UUID/summary \
-H "Authorization: Bearer $WT15_API_KEY" \
-d period=7d
{
"data": {
"available": true,
"reason": null,
"metric": { "uuid": "<metric uuid>", "name": "Deploy duration", "metric_key": "deploy.run.seconds", "metric_type": "level", "unit": "s" },
"rolled_up": false,
"window": { "from": 1794395200000, "to": 1795000000000 },
"sample_count": 38,
"sum": 16416,
"min": 391,
"max": 471,
"avg": 432,
"p50": 434,
"p95": 462.15,
"first_at": 1794401013220,
"last_at": 1794987530904,
"last": 440
}
}
Field Meaning
sample_count The number of samples in the window.
sum, min, max, avg The sum, smallest, largest and average of their values.
p50, p95 The median and the 95th percentile of the values. Over 31 days they are approximations (below).
rolled_up true when the window is over 31 days and was read from the daily summaries; false when it was read from the samples.
first_at, last_at When the first and the last sample were taken, in epoch milliseconds.
last The last sample’s value.
  • Every field is null when the window holds no sample, and for a metric awaiting approval (available: false).
  • Over 31 days the answer is read from the daily summaries WatchTower15 keeps (count, sum, lowest, highest, first and last time, last value and a histogram of the values for each UTC day), for the whole days up to the start of yesterday, and from the samples for the rest. rolled_up says so. Everything is exact except p50 and p95, which are approximated from the histogram: within about 14% of the exact value, and null when the window holds a negative value, which the histogram cannot place. A window up to 31 days reads the samples and is exact.
  • A metric whose history is not summarised yet (it has just been added, or WatchTower15 is catching up), or with a day in the window not recomputed yet, answers available: false with reason: "rollup_pending", and on the source form only that item does. A value pushed for an earlier day, or a reset, reaches the longer windows within about an hour: ask again later.
  • A window the store refuses for its sample limit is the 422 above. Data denser than the default 100,000 points a day (a backfilled history, for example) can also take the store more than 10 seconds: the answer is then 503 store_unavailable. A shorter window, or on the source form a smaller per_page, then answers.

The custom metric list and view carry alarms_count: the metric’s alarms, switched on or off, that GET /v1/alarms lists for it. List the metrics, keep those with an alarms_count above 0, and read the alarms of only those:

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/custom-metrics \
-H "Authorization: Bearer $WT15_API_KEY" \
-d "metric_source_uuids=$SOURCE_UUID" \
-d per_page=100
curl -sS -G https://rest.watchtower15.com/v1/alarms \
-H "Authorization: Bearer $WT15_API_KEY" \
-d entity_type=custom_metric \
-d entity_uuid=$METRIC_UUID

health_status unknown covers both a metric with no alarm and one whose alarms are not yet evaluated: alarms_count tells them apart.

GET /v1/incidents takes metric_source_uuids, a list: the incidents of those sources’ custom metrics, deleted metrics included, at most 100 sources. Repeat it for several sources, or send one; the bracket form, metric_source_uuids[]=<source uuid>, reads the same (see pagination). It combines with status, entity_type and entity_uuid and a window:

Terminal window
curl -sS -G https://rest.watchtower15.com/v1/incidents \
-H "Authorization: Bearer $WT15_API_KEY" \
-d "metric_source_uuids=$SOURCE_UUID" \
-d status=open \
-d period=7d

Another organisation’s source, or a deleted one, is 404 not_found.