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).
What the key needs
Section titled “What the key needs”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.
Samples or series
Section titled “Samples or series”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.
Raw samples
Section titled “Raw samples”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.
windowis read afterfromand up toto. - Samples come oldest first, each
[t, value]withtin epoch milliseconds as pushed. Two samples pushed at one time are both listed. - A page holds up to
per_pagesamples (limitis the same): 1 to 10,000, 1,000 by default. The samples page by time: sendnext_cursorback ascursorfor the next page, with the same parameters; the cursor keeps the first page’s window, so aperioddoes not slide between pages.next_cursorisnullon the last page.pageis not taken here. totalis how many samples the window holds, counted on the first page and carried by the cursor, so every page of one walk answers the sametotal. It is0for an approved metric with no sample in the window, andnullwhile the metric awaits approval.- Each page first counts the samples left in its window. More than 100,000 is
422 invalid_requestonperiod(onfromwhen you sentfromandto), naming the count: ask for a shorter window.
Series: aggregation and step
Section titled “Series: aggregation and step”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.
Days in your time zone: tz
Section titled “Days in your time zone: tz”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:
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.
Long windows
Section titled “Long windows”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.
A whole source at once
Section titled “A whole source at once”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:
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
/seriesanswer withoutwindow; the window and the step are given once, inmeta. period,from,toandstepwork as on/series.aggregationtakesavg,min,maxorlast, and applies to the source’slevelmetrics: acountmetric always reads its sum, and its item sayssum.aggregation=sumis refused.- 25 metrics a page (
per_page1 to 25;limitis the same); sendpagefor 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_approvaland no series.
Summaries
Section titled “Summaries”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.
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
nullwhen 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_upsays so. Everything is exact exceptp50andp95, which are approximated from the histogram: within about 14% of the exact value, andnullwhen 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: falsewithreason: "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 smallerper_page, then answers.
Metrics with alarms
Section titled “Metrics with alarms”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:
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_UUIDhealth_status unknown covers both a metric with no alarm and one whose alarms are not yet evaluated: alarms_count tells them
apart.
Incidents of a source
Section titled “Incidents of a source”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:
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=7dAnother organisation’s source, or a deleted one, is 404 not_found.