Functional Weave
Code in Python

monitor.uptime-bars@1.0.0

README.md

1,701 bytes · view raw

# monitor.uptime-bars

The row of daily bars under each component on a status page ("90 days ago
... today"): one `DayBar` per UTC day, oldest first, each with the seconds
up, degraded, down and unknown, the day's uptime in basis points and a state
to colour it by.

Each day is measured by `monitor.uptime` over that day's window, with the
same `maxGapSeconds` rule: a check's status holds until the next check, for
at most `maxGapSeconds`, and the latest check before midnight carries into
the day. So an outage that crosses midnight shows on both days.

## Days

- Days are UTC calendar days, `date` is `YYYY-MM-DD`. Status pages that show
  local days shift `now` first.
- The last bar is today, and it ends at `now`, not midnight, so the part of
  today that has not happened yet is not reported as unknown. At exactly
  midnight today's bar is empty (`no-data`).
- Midnight is found by flooring, so a `now` before 1970 still lands on the
  right day (`-1` is 1969-12-31).
- Checks after `now` are ignored.
- `days` is 1 to 366; 90 is the usual status page.

## State

In order: `no-data` when nothing that day is known; `outage` if any second
was down; `degraded` if any second was degraded; otherwise `operational`.
Unknown time alone does not change the colour of a day that has some known
time: a monitor gap is not an outage. The worst moment decides, the way
status pages colour their bars; the uptime figure says how bad the day was.

## Errors

- `now must be whole seconds`
- `days must be 1 to 366, received X`
- Everything `monitor.uptime` refuses: `maxGapSeconds must be a whole number
  of at least 1`, `checks must be in strictly ascending time order`,
  `unknown check status: X`.