Skip to content

Operations

This page is for the people who keep Hour Advantage running once it is installed. It covers what the instances need from Postgres. It covers how they start, stop and share work. It also covers how long data is kept, backups, upgrades, logs and metrics. Installation is in deploy. Ports and load balancers are in networking. Every variable and setting is in the reference.

WhereWhat
PostgresEverything that lasts. That is: packages and every revision pushed, the setup, devices and their keys, commands, actions and jobs. It is also events, where each sink is, failed device messages, API tokens, vars and secrets, and the audit trail.
EnvironmentThe database URL, the secret key, the admin login, the admin and advertise addresses, the instance id, the CPU count and the environment name (reference). Any secret can be given as a file (*_FILE). There is no config file.
Instance memoryThe traffic log (the last 1000 device messages), the live stream, and when devices were last seen. Last-seen times are written to the database within a few minutes and at shutdown.
Files on the hostNone: the log goes to stdout. The Windows service keeps its secret files in %ProgramData%\houradvantage. It writes its log to logs\houradvantage.<date>.log there. That is a file a day, and the newest 30 are kept.
NowhereRaw device traffic. A wire capture (hourctl wire) goes from the connection to the reader. It is never written to the database, a file or a log.
Requirement
VersionPostgres 14 or newer. No extensions.
RightsHour Advantage creates and migrates its own tables in the public schema. On Postgres 15 and later only the schema’s owner may create there. Make the role the database owner (CREATE DATABASE houradvantage OWNER houradvantage). Or run GRANT CREATE ON SCHEMA public TO houradvantage.
SessionsAn instance keeps a few connections that hold a session. They hold advisory locks (for the sink leases and the migration) and the ring. The ring is a view ring_<n> that the instance’s session holds locked. It sits in a transaction that stays idle in transaction for as long as the session lasts, so the others hear when it ends. Because of the ring, the role needs to be able to create a view in its schema. An alert on sessions idle in a transaction should leave out the application name houradvantage-ring-hold. The views of sessions that ended are dropped by the next instance that starts. Everything else is one transaction at a time on a pooled connection. Connect directly. Or put PgBouncer 1.21 or later (tested with 1.21.0 and 1.26.1) in transaction pool mode in front of the pooled connections, and give the others the database itself (PgBouncer). Statement pooling does not work. Neither does connecting through RDS Proxy.
SettingsOver TCP, the role the instance connects as must have the keepalives set: tcp_keepalives_idle, tcp_keepalives_interval, tcp_keepalives_count and tcp_user_timeout. It must have none of statement_timeout, lock_timeout and idle_in_transaction_session_timeout (Database role settings). An instance refuses to start otherwise, and prints the SQL.
ConnectionsEach instance uses up to 36. That is a pool of 4 per CPU (at least 8, at most 32) and four more. The four are: the session connection (advisory locks); the two of the ring that tells the others when an instance dies (one holds a lock on this instance’s session, one waits on the next instance’s); and the one a log’s housekeeping takes while it runs. With Time and Attendance on there are two logs, so five more, up to 37. Set max_connections to the sum over all instances, plus a few for administration.
TLSFor a database across a network, put sslmode=require (or verify-full with the provider’s CA) in the URL. The default, prefer, falls back to plain text. See database failover and TLS.

Nothing the program waits for on the database is ended by how long it has waited. A device’s turn that needs a row another instance’s step holds waits for that step’s commit. A schema change waits for the table live work is using, as long as that work takes. The queries of that table wait behind it meanwhile, which is that long too. A statement runs as long as it takes. What ends a wait is the holder: its commit, or its connection, which the server ends when it finds the other end gone.

So every connection must carry the keepalives that find it. Set them once on the role the instances connect as. Every connection carries them, including those a pooler makes. None of the three limits that end a wait by its length may be set. An instance reads them on several of its pooled connections when it starts. It refuses to start, naming the setting, if a keepalive is unset or 0, or if a limit is set. The keepalive check is over TCP: a connection through a unix socket has none to find. Set them as a database administrator:

ALTER ROLE houradvantage SET tcp_keepalives_idle = 10;
ALTER ROLE houradvantage SET tcp_keepalives_interval = 5;
ALTER ROLE houradvantage SET tcp_keepalives_count = 3;
ALTER ROLE houradvantage SET tcp_user_timeout = '30s';

A host that goes away without closing its connections (a power cut, a cut network) is found by the server in about 25 seconds, and the locks it held go. The operating system’s own keepalive would take two hours, and what waits on those locks would wait as long. An instance that is only frozen (a paused container, a process stopped with its connection open) is not gone. What it holds is held until it goes on or its connection ends. Nothing takes it over from under it.

If the role had statement_timeout, lock_timeout or idle_in_transaction_session_timeout from an earlier version’s instructions, take them off before the new version starts. Do this as a database administrator:

ALTER ROLE houradvantage RESET statement_timeout;
ALTER ROLE houradvantage RESET lock_timeout;
ALTER ROLE houradvantage RESET idle_in_transaction_session_timeout;

They may also be set in other places. One is the database (ALTER DATABASE ... RESET). Another is the server’s configuration (a -c statement_timeout=... to the server). A third is the connection’s options. None may be set in any of them. The compose files set the keepalives for the bundled database as server settings (-c tcp_keepalives_idle=10 ...). A role setting (ALTER ROLE) or a database setting (ALTER DATABASE) works as well.

Many instances can share fewer server connections through PgBouncer in transaction pool mode. The program needs two URLs:

HOURADVANTAGE_DATABASE_URLThe pool: every device message, request and housekeeping step that is one transaction at a time. It points at PgBouncer.
HOURADVANTAGE_DATABASE_SESSION_URL (or _FILE, or --database-session-url)The few connections that hold a session: the sink leases and membership (advisory locks), the schema migration and a log’s housekeeping lock. It points at the database itself, or at a PgBouncer in session mode. Without it, the first URL serves for both. That is only right when the first URL does not share server connections.
[databases]
houradvantage = host=db.example.com port=5432 dbname=houradvantage
[pgbouncer]
pool_mode = transaction
max_prepared_statements = 200 ; 1.21 or later; the program prepares its statements
default_pool_size = 40 ; server connections per database and role
max_client_conn = 400 ; every pooled connection of every instance

The program checks what it is given when it starts. It refuses, with the reason, a pooled URL that:

  • leads to statement pooling (a transaction is not kept on one server connection);
  • shares server connections and has no prepared statements (max_prepared_statements is 0, or PgBouncer is older than 1.21);
  • reaches a role without the limits above.

It also refuses a session URL that leads to a pooler that shares server connections. No ignore_startup_parameters is needed. The pool’s connections are named houradvantage-pool <instance> in pg_stat_activity. The instance’s session connections are named houradvantage <instance>.

Take n instances, counting one surge pod during a rollout. Each has a pool of p (4 per CPU, 8 to 32). PgBouncer takes up to n x p client connections (max_client_conn). Postgres sees default_pool_size from PgBouncer, plus the direct connections: n x 2 (n x 3 with Time and Attendance on). Those are the session connection and the housekeeping one. max_connections needs that sum and some for administration.

Instances create and migrate the schema on startup, one at a time.

  1. The admin listener opens. Until startup is done it answers /livez (200), /api/health ("starting": true), /api/ready (503, "why": ["it is starting"]) and /metrics. /metrics asks for the login as ever. An API token cannot be checked before the database is connected. So a request with an API token is answered 503 saying so, not 401. Every other admin route answers 503.
  2. The instance connects to Postgres and migrates the schema.
  3. It seals any secret not yet sealed with the current key (secrets at rest).
  4. It reads the setup and loads the active package revisions.
  5. It starts the listeners and deliveries, and the full admin API opens.

An instance starts even without a package revision it cannot run (packages). An endpoint whose package it does not have is not served on that instance. The log says endpoint not served on this instance. The endpoint shows as unavailable in hourctl endpoints and the API. A stop requested during startup is honoured.

Suppose the database cannot be reached, or takes no writes (a standby, or a failover in progress). Then the instance retries every 1 to 30 seconds and logs each attempt. Its listeners stay down and it is not ready. A wrong password, a server older than Postgres 14 or a malformed URL stops it at once.

ProbeAnswers
GET /livez200 ok whenever the process answers. Use it for liveness probes and container health checks.
GET /api/ready200 while the instance takes work, 503 otherwise. The body has ready, config_version, why (the reasons it is not ready) and database. Use it for load balancer health checks.
GET /api/health200 whenever it answers. The body has ok (ready and the database answers), ready, and starting (only while starting). It has nothing else: not which instance, its version or the environment (what the probes tell anyone).
GET /api/instanceBehind the login or an install token. It gives the instance’s name, version, tzdb, ready, database, environment and production. hourctl status and the environment hourctl names before a change read it.
GET /metricsPrometheus metrics (metrics). Needs the admin login or an install token.

/livez, /api/ready and /api/health need no login. An instance is ready when:

  • it has started and is not shutting down;
  • every HTTP listener not stopped by hand has its port;
  • it is not behind the config version with a refusal of the newest change. An instance that is applying a change stays ready. One that refused it is not ready from that moment, and the body says why.

Whether the database answers does not affect readiness. Watch it as database in GET /api/instance (behind the login) and as houradvantage_database_up. See health checks.

For a container health check, hourd healthcheck asks /livez (or /api/ready with --ready) on HOURADVANTAGE_ADMIN_LISTEN. It exits 0 on a 200, 1 otherwise.

On Ctrl-C, SIGTERM or a Windows service stop, the instance:

  1. reports not ready (/api/ready answers 503);
  2. keeps serving for 6 seconds so the load balancer stops sending it work. A cloud load balancer can take longer, so the Kubernetes example adds a 20 second preStop sleep before SIGTERM. Meanwhile the Time and Attendance workers, if it runs them, end the batch they have under way;
  3. stops the listeners and deliveries (up to 5 seconds) and writes last-seen times;
  4. waits for the attendance workers to end the batches they have under way. It does not give up after a time;
  5. gives the admin API up to 5 seconds to finish, and exits.

Step 4 waits for the batches, so how long a stop takes depends on them. The platform that stops the instance (Kubernetes, Docker, the service manager) ends the process when its own grace period is over. The examples here use 40 seconds (Kubernetes: 60, which also holds the preStop sleep).

Ending the process ends the instance’s session with the database. Whatever the instance had claimed is free at that moment: people whose ledgers a batch was working out, messages set aside that it was taking in, requests it was running under an Idempotency-Key. Another instance takes them up. Nothing waits for a time to pass first.

A message a device had in flight is not acknowledged, so the device sends it again. Everything acknowledged is already in the database.

After an instance stops without closing, its sinks resume within their delivery timeout.

Some of what an instance runs it cannot do without. These are following the other instances’ changes, delivering to sinks, keeping its leases, working the Time and Attendance queue, and keeping its database session. Suppose one of those tasks panics. The instance does not carry on with it dead. A worker that has died while the instance lives still holds the instance’s claims, and what it owned would stop with nothing to say so.

So the instance writes the panic to the log (an error with the task’s name and the panic’s message). It counts the panic (houradvantage_task_panics_total{task,essential="true"}) and exits with status 70. Its database session ends with it, so its leases are free at once. The other instances take its shards, groups and work. Restart it as for any exit. A service manager or an orchestrator does this.

A panic in any other task (a device’s message, a single delivery) is logged and counted (essential="false"). It ends that task only.

Report an instance that exits this way and comes back. The log line names where it happened.

Run as many instances as you need against one database, once they share a Valkey (below). All of them are active, behind any load balancer, with no affinity. A clock’s requests may reach a different instance each time.

WhatBehavior
DevicesA device’s messages are handled one at a time, whichever instance they reach.
SinksOne instance at a time delivers to each sink. If it stops, another continues from the sink’s stored position within a few seconds.
Event orderA sink receives events in the order they were stored.
SetupA change made through any instance is applied by every instance, usually within a second (config versions). Package activations, vars and secrets reach the instances the same way.
Sync groups and jobsEach group and each job runs on one instance at a time. Another takes over when it stops (sync, jobs).
HousekeepingRetention runs hourly, on one instance at a time.

A cluster is one environment (production, test) with its own database. Give every instance the same HOURADVANTAGE_ENVIRONMENT and HOURADVANTAGE_PRODUCTION (environments).

The cluster has one config version, a number. Every instance reports the version it has applied. The version goes up with every change to:

  • listeners, endpoints, sinks, settings and sync group settings;
  • what is stopped or started by hand;
  • the active package revisions;
  • vars and secrets;
  • a device’s status or keys, a device registered or removed by hand, and pending devices forgotten by housekeeping.

Device traffic (events, commands) does not change it.

A change is in use on every instance within about a second. houradvantage_config_catch_ups_total counts the times an instance found itself behind and caught up. An instance that cannot apply a change (for example, another process holds a listener’s port) stays on its previous version. It shows why as config_error and keeps trying. From the moment it refuses a change, it reports not ready until it catches up. No time has to pass first. An instance that is behind and has not refused is still applying the change, and stays ready.

A change through the admin API answers with the version it made, in the houradvantage-config-version header. hourctl then waits for every instance to reach it, or to refuse it and say why. It does not give up after a time. While it waits, it says who it is waiting for, and says so again when that changes. An instance whose session with the database has ended drops out of the list, so it is no longer waited for. It prints one of:

applied on 3/3 instances (config version 42)
applied on 2/3 instances (config version 42); not yet on gw-3 (at 41)

The change is made either way, so hourctl exits 0. With --json the line goes to stderr. hourctl peers (GET /api/peers) shows each instance’s applied version, config_error and the current version.

A device blocked, unblocked or given a new key through any instance is treated that way by every instance within the same bound. A key changed a moment ago on another instance is accepted at once.

Every connection gives up on a database server that stops answering within about 30 seconds. So after a failover, queries to the old primary fail rather than hang. Instances use only a server that takes writes (target_session_attrs=read-write, unless the URL sets it). Work cut off by a failover is answered “database unavailable, try again” (503 with Retry-After: 5 to a device). The instance reconnects by itself.

sslmode in the database URL works as in libpq:

sslmodeBehaviour
disablePlain text.
prefer (default)TLS if the server offers it, else plain text.
requireTLS. The certificate is checked, host name included, against the public roots and PGSSLROOTCERT.
verify-caTLS. Needs sslrootcert=FILE (or PGSSLROOTCERT). It trusts only that file. It does not check the host name.
verify-fullTLS. With sslrootcert=FILE (or PGSSLROOTCERT) it trusts only that file. It checks the host name.

Managed databases (RDS, Azure, Cloud SQL) sign with their own CA. Download its bundle and give it as sslrootcert.

Each instance needs its own HOURADVANTAGE_INSTANCE_ID, stable across restarts and under 50 characters. The default is the host name: the container id in Docker, the pod name in Kubernetes.

  • Unique. The id is a lock of the instance’s database session. An instance starting under an id another session holds waits for it. It says so once in a warning (“instance name … is held by a connection from …”). It waits until that session ends, however it ends (a clean stop, or the kernel closing a connection that died). Then it starts. Two live instances given one id show as one running and one waiting, never both running.
  • Stable for MQTT. MQTT client ids (houradvantage-<listener>-<instance>) and persistent sessions are built from the id. An instance that returns under a new id leaves its broker session, and the messages queued in it, behind. Compose replicas get a new container id when recreated. With MQTT listeners, run one compose service per instance with its own id (gateway-1, gateway-2), or run a Kubernetes StatefulSet.
  • Shared subscriptions. Every instance subscribes to an MQTT listener’s topics in one shared subscription ($share/houradvantage-<listener>/<topic>). So the broker hands each message to one instance. The broker must support shared subscriptions (MQTT 5 brokers, Mosquitto, EMQX, HiveMQ, VerneMQ).

Each instance keeps these for itself:

WhatNotes
Traffic log (/api/tenants/{tenant}/traffic)The instance’s own last 1000 messages.
MetricsScrape every instance.
Last seenhourctl devices asks every instance about the devices it lists and shows the latest.
Log linesEach line names its instance (instance in JSON logs). A refused message is logged by each instance it reaches, then at most once a minute with a repeat count.

Behind a round-robin load balancer a clock’s requests are spread over every instance. hourctl wire and hourctl stream (/api/tenants/{tenant}/stream) still show all of it. The instance you reach gathers the same view from every other instance, and each line names its instance. An instance that cannot be reached is reported in the stream with the reason. The capture’s last line says the view was partial.

For this to work:

  • Every instance has an address the others reach. Set HOURADVANTAGE_ADVERTISE_ADDR (host:port, a host, or http(s)://host:port). Without it an instance advertises its admin listener’s address. When that listens on every address (0.0.0.0:9090, as the image does), it advertises POD_IP or the host’s own address. hourctl peers lists every instance and its address. An admin API on loopback is reached only by instances on the same host.
  • Every instance has the same HOURADVANTAGE_SECRET_KEY. Instances sign the requests they send each other with a key derived from it. A signature is valid for 30 seconds either side of its time, so keep instance clocks in sync (NTP). Without a secret key, the caller’s login or API token is passed on to the other instances. That works when every instance has the same login. Over http://, as the admin API is by default, a password then crosses the network between the instances in the clear. Give every instance the key. Live views then send no credential of the caller’s. Also put the instances’ admin ports on a network only they and their operators reach.
  • The firewall lets them through (below).

Watching does not slow a device. When a reader falls behind, records are dropped and counted ("kind": "dropped" in the stream, houradvantage_wire_records_dropped_total).

Each instance must reach every other instance’s admin port (9090 by default) over TCP. On a compose network and between pods this already holds. A Kubernetes NetworkPolicy must allow gateway pods to reach each other on 9090. On separate hosts (Windows services, systemd units):

  1. Make the admin API listen on an address the other instances reach (--admin-listen 0.0.0.0:9090). This needs the admin login.

  2. Open the admin port to the other gateway hosts and the operators only.

    Terminal window
    New-NetFirewallRule -DisplayName "houradvantage admin" -Direction Inbound -Protocol TCP -LocalPort 9090 -RemoteAddress 10.0.0.11,10.0.0.12 -Action Allow
    Terminal window
    sudo ufw allow from 10.0.0.11 to any port 9090 proto tcp
    sudo ufw allow from 10.0.0.12 to any port 9090 proto tcp
  3. Check with hourctl peers that every instance is listed with an address.

Instances that run side by side share a Valkey. They tell each other through it what changed: that a device changed, that a setting changed, that events were stored. They also keep what they read of the devices in it, so what one instance has read, the others need not read from the database again.

Give every instance the same Valkey (redis://, redis-sentinel://, redis-cluster:// or rediss://). Set it with HOURADVANTAGE_CACHE_URL (or _FILE, the file it is in) or --cache-url. Any number of instances may then share the database.

Without a Valkey, an instance tells itself in its own process. It is then the only instance there may be. This is claimed in the database, on the instance’s session, so nothing has to be cleaned up if the instance dies:

  • A second instance without a Valkey refuses to start. It says that another instance is running and that more than one instance needs a shared Valkey.
  • An instance with a Valkey refuses to start beside one without. It says that an instance without a shared cache is running, and that you should stop it first or give it one.
  • When the first instance ends, however it ends, its claim goes with its session, and the next instance may start. No time has to pass.

An instance that cannot reach its Valkey does not start. It says so. Once running, an instance that loses its Valkey keeps trying to reach it again: the first try comes after HOURADVANTAGE_CACHE_RECONNECT_FIRST_MS (default 100), and each pause after that is twice the one before, up to HOURADVANTAGE_CACHE_RECONNECT_LONGEST_MS (default 30000). Meanwhile its devices are read from the database, and what it has to tell the other instances is kept and told once the Valkey is back.

What the instances tell each other is a stream in the Valkey. Each instance reads it from where it last read, and the server answers when there is something new, with no polling. What nobody still needs is cut away: the stream is cut to where the slowest instance that is alive has read, and an instance that has died is not waited for. An instance that finds it has missed something (it was away, or the Valkey lost it) does not guess what: it reads the database again. An instance alone, without a Valkey, tells itself in its own process.

A Valkey that restarts, or is replaced by another server, drops its clients’ connections, and an instance whose connection is made again reads the database again, whatever the new server holds. Wiping the Valkey of a running install by hand (FLUSHALL) drops no connection, so the instances are not told: restart them. Do not flush the Valkey of an install that is running.

Installs may share one Valkey. Each says which it is with HOURADVANTAGE_CACHE_INSTALL (or --cache-install), the first part of every key. The default is default, so set it where installs share a Valkey. hourd dev is one instance on its own, and claims the database the same way.

How to size instances, scale up and out, and run for high availability is in sizing and scaling. The settings are these:

SettingEffect
InstancesAdd more behind the load balancer. Any instance serves any clock.
HOURADVANTAGE_CPUSThe processors the instance sizes itself for. These are its database pool, the worker threads of its async runtime, the threads Time and Attendance recalculates and estimates costs on, and the package VMs it keeps ready. Defaults to the processors available (a container’s CPU limit on Linux). Instances may differ in size.
limits.max_body_bytesLargest device message (default 4 MiB).
limits.max_pending_devicesWhere new_devices = "hold", at most this many unregistered devices wait per endpoint (default 100, 0 for no limit; beyond it 429).
limits.set_aside_daysDays an MQTT message set aside is kept (default 7).

Limits you meet without setting them:

  • A device has at most 10 000 commands waiting. Beyond that new ones are refused.
  • Pending devices are forgotten after 24 hours without a call (or retention_days, if sooner).
  • When a listener’s connection limit is reached, more connections wait in the operating system’s queue (houradvantage_http_connections_refused_total).

Each connection a listener holds is an open file. A listener holds up to 10 000 (more wait in the operating system’s queue). A process starts with a soft limit on open files that is often 1024 (systemd’s default, and many containers’). So at startup the server raises its soft limit to the hard one. It logs where it stands (the limit on open files, with was, now and hard), with a warning when that is under 10 000. The hard limit is the operator’s to set:

  • systemd: the unit sets LimitNOFILE=65536.
  • Docker Compose: a container normally starts with a high hard limit (the Docker daemon’s, 1 048 576 by default). To set it, give the gateway service ulimits: { nofile: { soft: 65536, hard: 65536 } }.
  • Kubernetes: the limit is the container runtime’s (containerd’s default is 1 048 576). A runtime configured lower needs it raised in its configuration, as a pod cannot set it.
  • Windows has no such limit.
  • Load comes from polls. Every clock polls every few seconds (its delay, typically 10-30) whether anyone punches or not. Idle polls are answered from memory, so the database’s load follows what clocks upload. One million punches a day comes from roughly 5 000 to 10 000 clocks, which one small instance carries. A single instance serves tens of thousands of clocks.
  • Instances. Run at least two for availability, each able to carry the full load while the other is stopped or upgraded.
  • Memory. Give each instance at least 1 GiB (the compose stack’s default GATEWAY_MEMORY). The limits on what a process holds for senders that are not proven are sized to that. Device request bodies are limited to 256 MiB. Deliveries into Time and Attendance read before their signature is checked are limited to 128 MiB. Watch houradvantage_memory_bytes{part="process_rss"} against the limit while the load is at its highest. Watch the parts beside it to see what grows.
  • Sync work is bounded by the memory. The sync passes of an instance share one budget for the members’ work they hold at once. The budget is 20% of the memory the instance may use (the container’s limit, or HOURADVANTAGE_MEMORY_MIB). That is about 205 MiB at 1 GiB (houradvantage_sync_window_budget_bytes). Each member costs what it can hold at the most: its window of rows and its room’s rows (about 5.5 MiB for a clock whose package declares 200). So a group is reconciled in chunks of as many members as fit. A larger group takes more round trips, not more memory. The groups are shared among the instances as the sinks are. A group goes back to its instance when that instance returns after a restart. An instance serving 1 000 clocks runs in about 500 MiB. A process keeps the memory it has used for reuse, so its resident size stays near its highest after a burst of work.
  • The database. Uploads, commands and sync are database work. Run it with a standby (or a managed high-availability setup) and size its connections for the instances (Postgres).
  • Storage. About 2 million stored rows a day takes roughly 60-100 GB at the default retention_days of 30. It scales with the days kept. A sink that is down keeps the events it has not taken for as long as it stays down, and its tenant pays for them. They are the only thing kept past retention_days, and nobody else’s events are kept for it (retention).

Measure your own clocks and database before relying on any estimate.

retention_days (default 30, at least 1) decides how long data is kept:

Terminal window
hourctl settings set retention_days=14

Housekeeping runs at startup and then hourly.

WhatRemoved when
EventsTheir UTC day is older than retention_days. A sink that has not taken every event of such a day does not keep the day. The events it has yet to take are kept apart, and so are those of any other sink in the same case. The day’s other events go. A kept event goes when no sink needs it any more, because the sink took it or was moved past it. houradvantage_events_held{log,tenant} counts them. Readers of GET /api/tenants/{tenant}/events are not tracked.
CommandsFinished (succeeded, failed or unanswered) more than retention_days ago.
ActionsFinished more than retention_days ago, once none of their steps is waiting.
Failed device messagesOlder than retention_days.
Audit entriesOlder than audit_retention_days, when it is set. Never otherwise (retention).
JobsFinished more than retention_days ago, with their devices’ executions.
Pending devicesNot seen for 24 hours or retention_days, whichever is sooner, with their commands. Pending devices registered by hand and never seen stay.
Sync groups’ deleted rowsOlder than retention_days and applied on every member. A change feed reader must read within retention_days to see every delete.
Data of a removed sync groupAt the next housekeeping run.

Lowering retention_days removes delivered events sooner on the next round. It never removes an event a sink has not taken.

A sink taken off an endpoint is still owed what came before. A sink removed from an endpoint’s sinks (or a sync group’s, or the endpoint removed from the sink’s sources) is still sent the events that endpoint stored before the edit, and they are kept for it. Deleting is the operator’s decision. Once the endpoint, sync group or sink is deleted, nothing of it is owed, and its events go after retention_days. Ids cannot be changed, so renaming an endpoint is deleting it and adding another.

A sink that falls behind is reported, not dropped. A sink that is down, refuses everything, is paused or belongs to a suspended tenant keeps its place. Its events wait for it, however long that is, and the log grows. When housekeeping finds a sink that has not taken events older than retention_days, it says so:

  • sink.behind carries the sink, how many such events wait for it, the oldest, and retention_days. It is sent once. Then sink.caught_up is sent once the sink has taken them. They are Connect’s own events about the sink’s tenant (endpoint source:connect). The tenant’s sinks that name connect in their sources are sent them, and so are the install’s.
  • A warning in the log naming the sink.

To let go of what a sink has not taken, move the sink ahead. A Time and Attendance sink whose tenant is missing or suspended is a sink that refuses. It keeps every punch that waited and delivers them once the tenant takes them.

Move a sink along the stored events when it refuses an event for good, when its backlog no longer matters, or when a consumer lost data and needs events again.

  1. Find where the sink is. hourctl sinks --json (or GET /api/tenants/{tenant}/sinks/status) shows its position, the sequence number of the last event it has. hourctl sinks shows how many events wait and whether it is failing. For an install-level sink use hourctl --install sinks and /api/sinks/status.

  2. Move it:

    Terminal window
    # skip everything the sink has not taken
    hourctl sink position <sink> latest
    # send the events after sequence number 12000 next
    hourctl sink position <sink> 12000

    The API equivalent is POST /api/tenants/{tenant}/sinks/{id}/position (/api/sinks/{id}/position for an install-level sink) with {"seq": "latest"} or {"seq": 12000}. A number lower than the position sends events again. A higher one skips events.

  3. Delivery continues from the new position within a second. Events that were on their way when you moved the sink may arrive once more, as any event may. Receivers deduplicate on the event id.

Every move is recorded in the audit trail and sent as sink.moved, from where to where. Events the sink skipped are removed by the next housekeeping run once no other sink waits for them.

Everything is in Postgres, including every package revision pushed.

  1. Back up the database with pg_dump, or the provider’s backup and point-in-time recovery.

  2. Keep the environment the instances are given (on Windows, the service’s folder %ProgramData%\houradvantage).

  3. Keep a copy of HOURADVANTAGE_SECRET_KEY apart from the database backups. The database holds device keys, sink secrets, broker passwords and package secrets sealed with it. A backup cannot be used without the key. Protect both.

  4. Optionally, keep the setup as a file for hourctl apply. The export leaves secrets out:

    Terminal window
    hourctl export > houradvantage-setup.toml

A restored database numbers what it stores from where the backup left off. So everything stored after the backup (lost with the old database) is numbered a second time. Anything that pages by a sequence number would pass over what is stored under a number it has already been given, silently. That covers after= on the events, the audit trail and a sync group’s rows, and a sink’s position. A restore is not finished until the sequence numbers have been moved past anything handed out:

  1. Stop every instance.

  2. Load the backup into an empty database.

  3. Run the after-restore step, once, on the restored database:

    Terminal window
    psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f after-restore.sql

    after-restore.sql moves the events sequence, Time and Attendance’s, the audit trail’s and every sync group’s to the time now in microseconds. A database that hands out fewer than a million numbers a second from the day it was made has not passed it. One already past it stays where it is, so running it twice does no harm. Compose has the commands.

  4. Give the instances the same HOURADVANTAGE_SECRET_KEY and start them.

  5. Tell whoever pulls events (a script on GET /events?after=, a sync rows reader, an audit follower) the following. The numbers they were handed before the restore are below the new ones. No event from before the backup is given again. They carry on from the cursor they hold and receive everything stored from now on. What was stored between the backup and the loss is gone, and was already seen by whoever read it. A sink that delivered an event is not asked to again. One that had not goes back to its position in the backup and delivers events again, which receivers deduplicate on the event id.

  6. Get back the punches the lost database held. Connect tells each ZK clock how far it has been taken in (ATTLOGStamp=, kept with the device). The clock sends again from there. After a restore that is the backup’s place. So punches a clock still holds from after the backup are uploaded again, as the same events, by themselves. Punches a clock no longer holds (its log cleared, a clock replaced) are in no other place. For clocks that do not resend (push 2.0, Brightlink), and those you want to be sure of, ask every clock for its punches from the time of the backup:

    name = "punches after the restore"
    action = "query_punches"
    params = { from = "2026-10-26 02:00:00" } # the clock's wall time at the backup
    lane = "bulk"
    [targets]
    endpoints = ["office", "plant"] # every endpoint with clocks

    Run hourctl job create punches-after-restore.toml. See jobs. A package that does not offer query_punches (push 2.0) fails the job for its clocks, and those resend by themselves as above. Time and Attendance takes the punches again once. A punch is kept once, whatever number it arrives under.

Security covers sealed secrets and changing the key, where a tenant’s webhooks and brokers may connect, held device keys, devices nobody registered, and delivery signatures. In short:

  • The admin API controls the clocks. It shows device traffic (which can hold passwords and biometric templates) and sends commands. It listens on 127.0.0.1 by default. It refuses Host headers that are not loopback names and requests from other web origins. It will not listen on any other address without a login. With a login set, every request needs it, on loopback too. Every change is recorded in the audit trail, with secrets removed.
  • Device listeners are plain HTTP, which is what most clocks speak. Give devices keys, keep new_devices at hold or refuse, use a path that cannot be guessed, and limit who can connect (IP lists). A key over plain HTTP stops guessing, not eavesdropping. For MQTT the topic is the identity. The broker’s ACLs must bind each topic to its device (setting up the broker).
  • Strangers are bounded. Rate limits are per device, unregistered devices are capped per endpoint, and body size, package time and memory and connections are limited (devices nobody registered). The request bodies a process holds in memory at once are held to 256 MiB (a quarter of the 1 GiB each instance is given). Past that, a message is answered 503 with Retry-After and the device sends it again (houradvantage_http_body_budget_refused_total). No one client address holds more than a tenth of a listener’s 10 000 connections. Its next is closed at once (houradvantage_http_source_connections_refused_total). The proxies in trusted_proxies are not held to it. Behind a proxy that passes the client on with PROXY protocol the client is counted. A proxy not listed in trusted_proxies is one address to the listener, so every client behind it shares the limit. The log then says “many clients behind one address? declare it in trusted_proxies, or turn on proxy_protocol”, once a minute for the address. Limit connections and request rates per address in a reverse proxy as well.
  • Biometric data is stored only where you allow it (biometrics).
  • Sensitive command parameters (passwords, PINs, card numbers, templates, photos, device keys) show only as <redacted N bytes> in the audit trail, the command history and the stream.
  • Secrets are sealed with HOURADVANTAGE_SECRET_KEY (secrets at rest). API tokens are kept only as hashes. The API never shows a password or secret, only whether one is set.
  • Packages are trusted code. They run sandboxed (no file, network or process access; time and memory limits). But anyone with the admin login can push and activate one, and bundles are not signed. A tenant’s own token can push and activate that tenant’s packages too (Connect’s and Time and Attendance’s). So whoever holds one can run script in the server’s process. What keeps tenants apart is the time and memory limit of each call, not fairness. The gateway runs at most four calls for each CPU at once, for every tenant together, in the order they arrive. A tenant whose package is slow and whose devices are many can fill them and make other tenants’ calls wait. Give a tenant that is not trusted a messages_per_second limit. Push only packages you trust.

The admin API speaks plain HTTP. hourctl will not send the admin login or an API token over http:// to a machine other than the one it runs on, because anyone on the way can read them. Reach the admin API through a TLS proxy with an https:// URL. Or give --insecure (or set HOURADVANTAGE_INSECURE=1, as the Compose and Kubernetes setup jobs do for the private network they run on) to send them anyway. Without a login it answers only on loopback, only to requests naming a loopback host, and refuses any request carrying Forwarded, X-Forwarded-For or X-Real-IP (403).

To reach it from another machine:

  1. Set the admin login (HOURADVANTAGE_ADMIN_USERNAME and HOURADVANTAGE_ADMIN_PASSWORD_HASH, from houradm hash-password).
  2. Listen on a reachable address (HOURADVANTAGE_ADMIN_LISTEN=0.0.0.0:9090).
  3. Put a TLS-terminating proxy (nginx, Caddy, a cloud load balancer) in front of it. The login and tokens travel in headers and can be read by anyone on the path without TLS.

Password logins are throttled: one beyond the limit is answered 429 with Retry-After. API tokens are not throttled.

A private certificate authority. hourctl trusts the public certificate authorities built into it and the certificates the host trusts. Those are the operating system’s store. Or, where SSL_CERT_FILE (a PEM file) or SSL_CERT_DIR is set, those files in its place. The built-in roots stay either way. A proxy whose certificate a private CA signed is trusted once that CA is installed on the machine hourctl runs on. On Linux, that means in the system bundle, then update-ca-certificates. On Windows, it means in the Local Computer’s Trusted Root Certification Authorities store, which every account reads, the service’s too. Or the CA can be named in SSL_CERT_FILE for one run:

Terminal window
SSL_CERT_FILE=/etc/ssl/acme-ca.pem hourctl status

Webhook sinks trust the same way, on the machine each instance runs on.

Give scripts, CI jobs and other tools a named token instead of the admin login, one per tool, so you can revoke each alone.

  1. Create a token. The secret is printed once:

    Terminal window
    hourctl token create backup-job

    A token for one tenant only (its operators, or a customer’s own system) names its scope:

    Terminal window
    hourctl token create acme-ops --scope connect:acme
  2. Use it from hourctl by setting HOURADVANTAGE_ADMIN_TOKEN (or HOURADVANTAGE_ADMIN_TOKEN_FILE, naming a file that holds it):

    Terminal window
    HOURADVANTAGE_ADMIN_TOKEN=hadv_... hourctl status
    Terminal window
    $env:HOURADVANTAGE_ADMIN_TOKEN = "hadv_..."; hourctl status

    Other clients send it as Authorization: Bearer hadv_....

  3. List tokens (name, created, by whom, last used) with hourctl token list.

  4. Revoke one with hourctl token revoke backup-job.

PropertyValue
Formathadv_ followed by 256 random bits. The prefix lets secret scanners find a leaked token.
RightsUnscoped: the same as the admin login. connect:<tenant>: only that tenant’s Connect routes. attend:<tenant>: only its Time and Attendance routes. A scoped token never reaches another tenant, an install-level route, or the tenant’s own record, suspend, resume, stop, delete, or whole export or import (tokens).
NameAt most 64 characters.
StorageOnly the token’s SHA-256 is stored.
RevokingRefused at once by the instance that revoked it. An install token is refused by every other instance as soon as it is told: a revoked token says so to all of them, with no time to wait. An install token that has checked out is remembered until then, so its last_used_at is written when the database is asked, not at every request. A tenant’s token is asked of the database each time, so it is refused everywhere at once. A token of a deleted tenant does not reach a tenant made again under the same id.
AuditChanges made with a token are recorded as token:<name>.

The admin login stays required. It creates the first token, and it is what lets the admin API listen off loopback.

The admin password. The login is HOURADVANTAGE_ADMIN_USERNAME and HOURADVANTAGE_ADMIN_PASSWORD_HASH (or ..._HASH_FILE), read when an instance starts.

  1. Make the new hash: houradm hash-password.
  2. Put it in the environment of every instance and restart them one at a time (upgrades says how for each deployment). An instance not yet restarted still takes the old password.
  3. On Windows, replace the contents of admin-password-hash in %ProgramData%\houradvantage and restart the service. Installing the service again keeps the file as it is.
  4. Give the new password to everything that logs in with it (HOURADVANTAGE_ADMIN_PASSWORD for hourctl).

API tokens. A token does not expire. A revoked token’s name stays taken, so a replacement has another name. To rotate one:

  1. hourctl token create backup-job-2 (with the same --scope), printing the new secret once.
  2. Give it to the tool that used backup-job.
  3. hourctl token revoke backup-job. Every instance refuses it within a minute.

A webhook sink’s secret. A sink has one secret. It signs every delivery, and the receiver checks the signature (signatures). A change takes effect at the sink’s next delivery. A delivery the receiver does not yet accept is refused, kept, and sent again until it is accepted. So nothing is lost, but the sink is behind meanwhile. To change it without a refusal:

  1. Have the receiver accept a signature made with either the old or the new secret.
  2. hourctl sink set payroll --secret-env NEW_SECRET (or --secret @new-secret.txt). A secret on the command line is in the process list and the shell’s history.
  3. Once the sink’s deliveries are being accepted, have the receiver drop the old secret.

A sink that feeds Time and Attendance signs with a delivery key. Issue a new key, set it as the sink’s secret, then revoke the old key.

The secret key that seals what the database keeps has its own steps (change the key).

These are sealed before they are written to the database: broker passwords, webhook signing secrets, device keys, delivery keys and the secrets packages read. Sealed means encrypted with AES-256-GCM.

Each sealed value names the key it was sealed with. It names it by a hash of the key, never by the key. Neither the key nor the secrets are logged.

The key. houradm gen-secret-key prints one. It is 32 random bytes as base64. 64 hex digits are also accepted. Give it to every instance as HOURADVANTAGE_SECRET_KEY or HOURADVANTAGE_SECRET_KEY_FILE. Every instance sharing a database needs the same key. Back it up apart from the database.

Without a key, an instance refuses to start while the database keeps any secret. It names the first kind it found. The one exception is HOURADVANTAGE_ALLOW_PLAIN_TEXT_SECRETS=true, set on every instance to keep secrets as plain text (secrets).

An install with no secrets yet starts without a key and warns. A request to keep a secret on it is refused with 409, and nothing is kept. The 409 names HOURADVANTAGE_SECRET_KEY. Such requests are, for example, a delivery key issued, a sink’s secret, a broker password, a secret value, and a key given to a device.

An instance without a key that finds a sealed value refuses to start. Storing biometrics or photos in a sync group needs a key.

A wrong key. A value sealed with a key the instance does not have, or altered in the database, is refused with the key’s id. The instance does not start.

Sink URLs are not sealed. A webhook sink’s url is stored, shown and written to the audit trail as it is. Put no credentials in it. That means no user:password@ and no token in the query string. The receiver checks the signature made with the sink’s secret, which is sealed.

  1. Make a key: houradm gen-secret-key.
  2. Set it as HOURADVANTAGE_SECRET_KEY on every instance.
  3. Restart the instances. At startup each seals every secret not yet sealed and logs how many. Everything written afterwards is sealed.
  1. Make a new key: houradm gen-secret-key.
  2. On every instance, set the new key as HOURADVANTAGE_SECRET_KEY. Set the old one in HOURADVANTAGE_SECRET_KEYS_OLD (or HOURADVANTAGE_SECRET_KEYS_OLD_FILE). Separate several keys with commas, spaces or line breaks.
  3. Restart the instances one at a time. They keep sealing with the old key until every running instance has the new one. Then everything kept is sealed again with the new key, once (changing the key).
  4. Once every instance has run with the new key, remove the old key.
  1. On every instance, unset HOURADVANTAGE_SECRET_KEY, set the key in HOURADVANTAGE_SECRET_KEYS_OLD, and set HOURADVANTAGE_ALLOW_PLAIN_TEXT_SECRETS=true.
  2. Restart the instances. At startup the secrets are opened and stored as plain text.
  3. Remove HOURADVANTAGE_SECRET_KEYS_OLD, and keep HOURADVANTAGE_ALLOW_PLAIN_TEXT_SECRETS=true.

A time a device records without an offset is placed in the endpoint’s timezone. This uses the IANA time zone database built into the binary. The host’s zone files are never used. So every instance gives the same offsets, whatever its operating system or image.

To see which tzdb release a version carries:

  • hourd --version prints it: hourd 0.1.0 (tzdb 2026c).
  • Each instance logs it at startup (tzdb=2026c).
  • GET /api/instance has it as tzdb, with the instance and its version. To compare instances, ask each one at the address hourctl peers lists.

Changes to a zone’s rules arrive with Hour Advantage releases. Upgrade before a change takes effect. During a rolling upgrade each instance uses its own copy until all are replaced.

A new version migrates the schema on startup, one instance at a time. The others wait.

  1. Back up the database (backups).
  2. Replace instances one at a time. The drain on shutdown keeps a rolling restart from dropping requests.
    • Compose: set HOURADVANTAGE_IMAGE to the new image. Then run rolling-update.ps1 or rolling-update.sh (compose).
    • Kubernetes: the Deployment’s rolling update.
    • systemd: on each host in turn, run sudo systemctl stop houradvantage. Replace /usr/local/bin/hourd. Run sudo systemctl start houradvantage. Check hourctl peers before the next host. The environment file and the unit stay as they are.
    • Windows service: on each host in turn, run houradm service stop. Replace hourd.exe and houradm.exe, which stay beside each other. Run houradm service start. The service is not installed again. It keeps its folder and environment.
  3. Check with hourctl peers that every instance runs and has applied the current config version.
  4. Keep hourctl and houradm at the version of the instances. A command line from another version may not know a route or a flag.

A release and the one before it run on the same database together. This happens during a rolling upgrade, when an old instance restarts half way, and after a rollback (kubectl rollout undo).

  • Schema. A version that finds schema changes it does not know starts if every one of them allows the older version. It logs a warning to finish the upgrade or rollback. If any does not, it refuses to start and names them. To roll back to a version that refuses the current schema, restore the backup taken before the upgrade.
  • A schema change that does not allow the older version. Only a version that starts is checked. An instance of the older version that is already running goes on running against the new schema. It may read or write what it does not know. A release whose notes name such a change needs care: stop every instance before the first of the new version starts. Do not replace them one at a time. Schema 50 is one such change. It keeps events a sink has not taken apart from the day’s.
  • Settings. Stored settings may contain fields from a newer version. An older version ignores them, logging which. It keeps them when it saves the settings. A new value in a list of choices cannot be ignored. A new kind of sink is an example. Use such a value only once every instance runs the new version.
  • Busy tables. A schema change waits a few seconds at most for a table in use, then gives up. The instance retries its start. Device traffic waits no longer than that.

hourd run logs to stdout. Other commands print results on stdout and log to stderr. At a terminal the log is text. Anywhere else, such as in a container, under a service manager or through a pipe, the log is one JSON object per line.

Each object has these fields:

  • timestamp, level, target, instance and message.
  • severity, which is the same level under the name Google Cloud Logging reads.
  • The event’s fields.
  • The fields of the device message it concerns (request_id, listener).

Rotation and retention belong to the platform. Examples are the journal, Docker’s log driver and the cluster’s collector. The compose example keeps 5 files of 20 MB per container. There is no log file setting.

A caller that needs a pooled connection waits until one is free or made, or the attempt fails. The attempt fails if the connection drops. It also fails if the kernel’s user timeout ends a connection the database no longer answers on. Nothing gives up on a clock. So there is no pool timeout and no “pool exhausted” episode.

A connection that comes free goes to the work waiting for it, in this order:

  1. Work that answers a client that waits comes first, in the order it asked. That is admission, poll, upload, ack, device and admin.
  2. Background work comes next. That is sync, sink, follow, presence, jobs, tidy and attend.

Waiting for a turn does not time out. Work waits until it is its turn, or until what asked for it is gone (a device that hung up). Only the wait for the connection, once it is the work’s turn, can fail.

Nothing is kept back for either kind. Background work takes every connection that no clock-facing work is waiting for. Clock-facing work takes every one that is free.

The background kinds that wait share the free connections by the work each has waiting. A sink counts by the events it is behind. A sync group counts by the members with work. So a kind with much waiting gets most of them. One with little still gets its turn.

A clock waits for its answer before it sends the next message. So clock-facing work is bounded. Background work waits for long only while clock-facing work holds every connection. houradvantage_db_pool_background_blocked says when.

A device message that takes 5 seconds or more is slow. When it ends, the program says so in a warning (“a device message took long”). The warning has its route, endpoint, device, total_seconds and account.

The account says where the message’s time went, in seconds, under fixed names:

  • pool_wait is time spent waiting for a pooled database connection. It happens inside the other phases, and shows in them too.
  • mailbox_wait is waiting in this instance’s queue of the device. Every message of a device waits there. It waits for the step that has the device’s messages in hand, and for the steps before its own.
  • store_turn is waiting for the device’s row in the database at the start of a step. That means a pooled connection, then the row. Another instance may be keeping something in the row. This wait gives up after 10 seconds.
  • script_slot is waiting for a thread to run the package on. Only the runs that identify and verify a message wait for it. A step has a thread of its own.
  • package_run is running the package.
  • store_writes is keeping what the message changed.
  • pin_held is how long the step kept the connection pinned to its work.

A message that waits in a device’s queue holds nothing: no connection, no thread, no lock.

A step starts when its device is next in line and a connection of the pool is free for it. The devices of each tenant are taken in the order their messages came, the tenants one after another. So a device with many messages waiting does not keep another’s single message waiting. Nothing else limits the steps.

Here is what a step does:

  • It answers the messages that change nothing from what this instance holds of the device, with no connection.
  • At the first message that has something to keep, it takes one connection. It takes the device’s row. That is the one thing it may wait for: another instance’s step of the same device, which is one commit. It reads what the device holds.
  • Suppose the device is not as the message was run on. This happens if another instance kept a message of it, or commands were queued for it. Then the package runs again on the device as it is now.
  • Only that run’s log lines are written. A warning or an error of a run that was thrown away is written with them. It is said to be from a run that was redone. These reruns are counted in houradvantage_device_turn_reruns_total{package,cause="device_moved",route}.
  • A device that may have commands takes its row first.
  • The rest of the step’s messages run in the order they came, each on what the one before it left. What they changed is kept in one transaction.
  • A message whose package fails is answered with its own failure and changes nothing.
  • If the transaction cannot be kept, every message of the step is answered that it was not stored. The device sends it again.
  • A message that comes while a step is under way is for the next one.
  • The log lines of a message are written once its step is kept.

The phases are not meant to add up to the total. What is left is time in none of them.

Five seconds is chosen because the shipped HAProxy ends a request at 20 seconds (timeout server) and a clock does not wait for long. A message that reaches five seconds has waited on something more than once. It is a quarter of the way to being cut off.

The first slow message of a spell warns. The rest are only counted in houradvantage_device_requests_slow_total{route}. When none has been slow for 10 seconds, one info line (“device messages are no longer taking long”) closes the spell. It gives these:

  • How long the spell lasted.
  • How many slow messages there were.
  • How many for each route.
  • The longest one with its account (slowest).

Separately, every HTTP answer with a status that is not a success is logged once at info (“a request was answered with an error status”). The line has its request_id, listener, status, route, device and ms. These are not collapsed into a spell. A status seen in a proxy’s log or by a device can be followed by its request id (X-Request-Id) to the gateway’s line.

A message whose device went away before it was answered is dropped by the program at that moment. The device may have given up. So may the proxy in front of the program: HAProxy answers its client 504 after timeout server and closes its connection to the program.

It is counted in houradvantage_device_requests_abandoned_total{route}, with unknown as the route if it had not been routed yet. It is said the same way as a slow message. The first of a spell is a warning (“a device went away before its message was answered”). The warning has the account the message had when it was dropped. One info line follows when none has been for 10 seconds, with the longest one and its account (longest).

houradvantage_device_request_phase_milliseconds_total adds up where the time of every slow and abandoned message went. Nothing of the message is kept in that case, as for any message not answered. The device sends it again.

When the database cannot be reached, the program says so once, in a warning from houradvantage::outage. When it is reachable again, the program says so again. That line gives how long the outage lasted and how many lines were left out.

Meanwhile each part that needs the database logs a failure that is about its being unavailable. It logs it once every 30 seconds for each message, not once for each attempt. Warnings about anything else are untouched.

CommandDoes
hourctl logsShows the log level, and the format of the instance that answered.
hourctl logs level "info,houradvantage=debug"Changes the level on every instance while running. debug, off and filters also work. When RUST_LOG is set, it overrides the stored level at startup. Use it for debugging only.
hourctl audit [-f]Every change made through the admin API, with who and when. -f keeps following it. --by, --action, --since, --until, --request and -t limit it (the audit trail).
hourctl statusWhether the gateway is up and counts of what it runs. A part the gateway refuses to give is shown as unavailable. For example, it may be a login the gateway does not accept, or an error. The command then exits 1, after the rest is printed. A part an older gateway has no route for is only shown as unavailable.
hourctl failuresDevice messages that failed, newest first (devices).
hourctl wireEvery byte devices send and receive, live, on every instance (below).

Messages that carried events are logged at info, idle polls at debug.

The wire capture shows every byte the HTTP listeners receive and send. This includes requests that are not valid HTTP and connections that send nothing. Use it to find out what a device really sends.

Terminal window
hourctl wire --device <device> --for 30m
OptionEffect
--device DEVICEOnly requests that name the device as a whole word (SN=<device>, /<device>/), with their answers. Filtering is per request, since a proxy can send every clock down the same connections.
--endpoint EOnly requests for that endpoint, with their answers.
--for DURATIONHow long: 90s, 15m, 2h. Default 15 minutes, at most 2 hours.
--hexEach record’s bytes as a hex dump instead of text.
--save FILEAlso write the exchanges to FILE as a capture for hourctl pkg replay (HTTP listeners only).
--jsonPrint the records as JSON lines.

The capture ends when --for is up, after 64 MiB, or on Ctrl-C. Each record has conn, listener, endpoint, peer, dir, bytes and data. The dir is one of open, rx, tx, eof, error or closed. In data, unprintable bytes are escaped.

  • It shows traffic as it is. That includes device keys, PINs, card numbers and biometric templates. It needs the admin login. Every capture started is in the audit trail, with who, which device or endpoint, and for how long.
  • Nothing of it is stored or logged.
  • Capturing does not slow a device. When the reader falls behind, records are dropped and counted.

GET /metrics serves Prometheus metrics on the admin listener. Its labels name tenants and their endpoints and sinks. So it is an install-level route. It needs the admin login or an install token. A scoped token is refused (403). Without an admin login set, it answers on a loopback address, as the whole admin API does. No label names a device.

Each instance has its own metrics. Scrape them all. List the instances as targets, or discover them. A Kubernetes pod carries no prometheus.io/* annotations, as those cannot send the token. Kubernetes, Metrics has a PodMonitor.

Give Prometheus an install token:

scrape_configs:
- job_name: houradvantage
authorization:
credentials_file: /etc/prometheus/houradvantage-token
static_configs:
- targets: ["gateway-1:9090", "gateway-2:9090"]

The metrics are grouped by what they are about. Each name is followed by what it measures.

  • houradvantage_info{version,instance}
    Always 1.
  • houradvantage_ready
    1 while the instance takes work.
  • houradvantage_config_version
    The config version this instance has applied.
  • houradvantage_config_catch_ups_total
    Times this instance found itself behind the config version and caught up.
  • houradvantage_database_up
    Whether the database answered this instance’s last check.
  • houradvantage_build_info{version,commit}
    1 for the version and the commit the program was built from (unknown for a build made without it). Read it to know which program an instance runs.
  • houradvantage_task_panics_total{task,essential}
    Tasks that panicked, by the name of the work and whether it is one the instance cannot do without. With essential="true" the instance logs it and exits (see An instance that cannot go on). It should stay at 0. Each is a defect, and the log line names the place. The counter exists at 0 from the start, with task="none", so a scrape without it is a broken scrape and not a quiet run. Sum over the labels.
  • houradvantage_memory_bytes{part}
    What the process holds. process_rss is what the operating system counts against a container’s memory limit. process_rss_peak is the most it has counted since the program began. The allocator keeps freed pages for reuse, so the process may hold more than the parts add up to. request_bodies is device request bodies held until answered, of their 256 MiB limit. lua_idle_vms{package} is the memory of the loaded packages’ idle script instances (a package’s versions added together).
  • houradvantage_memory_items{part}
    How many of what an instance keeps. lua_idle_vms{package} is idle script instances, a package’s versions added together. unsaved_sightings is devices dropped from memory whose last-seen time is not yet written. Also counted are devices_with_commands and devices_with_commands_lately. timers is commands and hooks waiting for their time. attend_jobs_running is people being worked out. Devices kept in memory are houradvantage_device_cache_devices.
  • houradvantage_requests_total{endpoint,route,status}
    Device messages. route="none" means refused before a package saw it.
  • houradvantage_request_duration_seconds{endpoint,route}
    Histogram of device message handling time.
  • houradvantage_device_rows_refused_total{endpoint,row}
    Rows a device reported whose key is longer than a registry key may be (128 characters). The key is, for example, a user id, or a list item’s. Counted by endpoint and kind of row. Each is recorded as an unparsed event. The rest of the upload is taken.
  • houradvantage_tenant_messages_limited_total{tenant}
    Messages refused because the tenant’s devices exceeded the tenant’s messages_per_second (tenant limits).
  • houradvantage_device_failures_dropped_total
    Failed device messages not recorded because too many were waiting to be written.
  • houradvantage_commands_total{status}
    Commands by status reached: queued, offered, succeeded, failed, unanswered and so on.
  • houradvantage_http_connections{listener}
    Open device connections.
  • houradvantage_http_connections_refused_total{listener}
    Times the connection limit made a connection wait.
  • houradvantage_http_source_connections_refused_total{listener}
    Connections closed at once because their client address held as many as one address may.
  • houradvantage_http_body_budget_refused_total{listener}
    Messages answered 503 because the request bodies being read held all the memory set aside for them.
  • houradvantage_http_connection_errors_total{listener,kind}
    Connections cut. The kind is timeout (headers or body too slow), idle, proxy_protocol or other. The proxy_protocol kind means no valid PROXY header where one is required, or not from a trusted proxy.
  • houradvantage_http_accept_errors_total{listener}
    Accepts that failed (out of file descriptors, say). The log says it once for a streak.
  • houradvantage_admin_refused_total{reason}
    Admin API requests turned away before any route saw them (refused requests).
  • houradvantage_ip_refused_total{listener}
    Requests refused by a listener’s or endpoint’s allow_from/deny_from.
  • houradvantage_device_connection_hold_microseconds_total
    How long steps held a connection for their device’s turn, in all.
  • houradvantage_device_turn_statement_microseconds_total
    How long the statements of steps’ turns took, in all, including the wait for the device’s lock. The rest of houradvantage_device_connection_hold_microseconds_total is time the connection a step holds waits for the program.
  • houradvantage_device_blocking_queue_microseconds_total
    How long package calls of steps waited for a thread, in all. It is time a connection the step holds is not used.
  • houradvantage_device_requests_slow_total{route,package}
    Device messages that took 5 seconds or more to answer, by the route the package chose and the package that took them. Logs says where their time went.
  • houradvantage_cache_reads_total{kind,result}
    Reads the shared cache answered for the store. kind is what was read: state (a device’s row) or open (the commands in a device’s hand). result is hit, miss, dirty (being changed, so the database was read), down (the cache can’t be reached or isn’t trusted) or unreadable.
  • houradvantage_bus_batches_skipped_total
    Batches of notes between instances that this instance never got. It happens when the instance lost its link to Valkey, or fell so far behind that Valkey had already dropped them. Nothing is lost: the instance reads the database again instead. A count that keeps rising means the link to Valkey keeps breaking or this instance can’t keep up.
  • houradvantage_device_turn_reruns_total{package,cause,route}
    Package runs thrown away and run again. The cause is device_moved, pending or in_hand. Each exists at 0 from the start, with package="none"; sum over the labels. The route is the route that ran, for device_moved, and empty for the other causes. pending means a route asked for the commands waiting for the device, which are read first, and the package ran again with them. device_moved means the device changed between the run and the keeping of what it did. The package ran again on the device as it was then. in_hand means a route asked for the commands in the device’s hand, ctx.in_hand(), which are read first.
  • houradvantage_device_mailbox_devices
    Devices with messages waiting in this instance’s queues for a connection for their step.
  • houradvantage_device_mailbox_messages
    Messages waiting in them, not counting those a step has in hand.
  • houradvantage_device_step_messages
    A histogram of how many messages a step kept, observed as each ends.
  • houradvantage_device_step_seconds
    A histogram of how long a step took, from the step taking the device to the keeping of what it did. A step is as long as the queue it found.
  • houradvantage_device_package_run_microseconds_total{package}
    Time spent running packages for device messages, in microseconds, by package. Divided by houradvantage_device_messages_handled_total{package}, it is the cost of a message of each.
  • houradvantage_device_messages_handled_total{package}
    Device messages answered, by the package that took them.
  • houradvantage_device_messages_kept_total{package}
    Of those, the messages that kept something in a transaction. The rest changed nothing and were answered without one.
  • houradvantage_device_requests_abandoned_total{route}
    Device messages dropped before they were answered because the device, or a proxy in front of the program, closed the connection. unknown is for one not yet routed.
  • houradvantage_device_request_phase_milliseconds_total{phase,kind,package}
    The time of the slow (kind="slow") and abandoned (kind="abandoned") device messages, by where it went and by the package that took them. The phase is pool_wait, mailbox_wait, store_turn, script_slot, package_run, store_writes or pin_held (logs). Phases overlap: a pool wait happens inside the others.
  • houradvantage_script_slots_in_use
    Package calls running now.
  • houradvantage_device_turn_slow_waits_total{holder_route,holder_phase,package}
    Device messages (and pushes to a device) that waited 5 seconds or more for their device’s turn. They are counted by what held the turn when they had waited that long. holder_route is the route of the message the step in progress was on (push_flush for a push of queued commands). holder_phase is the phase it was in then: pool_wait, script_slot, package_run, store_writes, sync_top_up, mailbox_wait, store_turn, pin_held or none. package is the package of the message that waited. The slow warning of a message that waited for its device’s turn says what held the turn when its wait began (“the device’s turn was held by … in …”). A wait for the device’s row in the database, held by another instance, names no holder.
  • houradvantage_device_turn_held_seconds{route}
    A histogram of how long a device’s turn was held, by the route that held it, observed when a message waited for it. A message’s slow warning says how long the turn before it was held and by what (“the turn before it was held for … by …”).
  • houradvantage_device_cache_devices
    Devices kept in memory.
  • houradvantage_device_cache_evictions_total
    Devices dropped from memory.
  • houradvantage_device_catchups_total
    Times an instance looked for devices registered a moment ago that it had not yet heard of, because a message came from a serial number it did not have. At most one look is in flight at a time, however many messages come. So a flood of made-up serial numbers costs the database one light read at a time.
  • houradvantage_package_call_seconds{package,entry}
    Histogram of package calls. The entry is load, identify, route, outbound, build, set_key, action, verify, sync or lookup.
  • houradvantage_package_errors_total{package,entry}
    Package calls that failed (an error, or the work or memory limit).
  • houradvantage_mqtt_blocked_total{endpoint}
    MQTT messages from blocked devices, acknowledged and not taken in.
  • houradvantage_mqtt_received_total{listener}
    Messages the broker gave an MQTT listener. A message given twice counts twice.
  • houradvantage_mqtt_handled_total{listener}
    Messages an MQTT listener has finished with and acknowledged. Its rate is how fast the listener takes messages in. Received less handled is what it holds.
  • houradvantage_mqtt_unroutable_total{listener}
    MQTT messages on a topic no endpoint takes, acknowledged and not taken in.
  • houradvantage_mqtt_oversized_total{endpoint}
    MQTT messages over limits.max_body_bytes. They are acknowledged and refused as HTTP answers 413.
  • houradvantage_set_aside_at_cap_total{tenant}
    MQTT messages that could not be set aside because the tenant was at its set_aside limit.
  • houradvantage_set_aside_total{tenant}
    MQTT messages set aside.
  • houradvantage_set_aside_taken_in_total{tenant}
    Messages set aside that were taken in later.
  • houradvantage_set_aside_expired_total{tenant}
    Messages set aside and dropped for waiting longer than limits.set_aside_days.
  • houradvantage_wire_records_dropped_total
    Wire capture records dropped.
  • houradvantage_db_pool_in_use
    Pooled database connections in use.
  • houradvantage_store_oldest_xmin_age_xids
    How many transactions back the oldest snapshot or transaction id reaches. It is the oldest one held by one of this instance’s database sessions (backend_xmin in pg_stat_activity, not counting the session that reads it). An instance holds none while it waits. So this is small and does not grow. A value that keeps growing means a session of this instance holds a snapshot while it waits. Then VACUUM cannot remove what died after it in the whole database. Look at pg_stat_activity for the session whose backend_xmin is oldest. It reads 0 for an instance whose connections have an application_name of the URL’s own.
  • houradvantage_db_pool_waiting
    Callers waiting for a pooled connection, of every kind.
  • houradvantage_db_pool_clock_facing_held
    Pooled connections held by work that answers a client that waits. That is a device’s message, a poll, an upload, an answer to a command, an admin request.
  • houradvantage_db_pool_clock_facing_waiting
    That work waiting for a connection. It is given the next free connection before any background work.
  • houradvantage_db_pool_background_waiting{kind}
    Background work waiting for a connection, by kind (sync, sink, follow, presence, jobs, tidy, attend). Free connections go to it when no clock-facing work waits. They are shared among the kinds by the work each has waiting.
  • houradvantage_db_pool_background_blocked
    1 while background work waits and clock-facing work holds every connection of the pool. A warning says so when it begins (“background work is waiting for a database connection: clock-facing work holds every connection”). Otherwise 0. The pool is too small for the clock-facing load.
  • houradvantage_db_pool_wait_seconds{class,caller}
    How long work waited for a pooled connection, by class (clock for clock-facing work, background) and by who asked. A connection that was free is a wait of zero. The clock class stays short. Background work waits as long as clock-facing work holds every connection.
  • houradvantage_db_pool_hold_seconds{caller}
    How long each kind of holder kept a connection: a device’s message, a poll, an upload, a sync pass, a sink. A kind whose holds are long keeps the pool from clock-facing work that waits.
  • houradvantage_db_pool_grants_total{to,other_class_waiting}
    Connections given to waiting work when one was released. They go to clock-facing work first, always. to="background",other_class_waiting="yes" is a defect and never counts.
  • houradvantage_db_pool_callers_waiting{caller}
    The same, by who is asking (by the name of the work that asked). It shows whether the callers waiting are devices’ messages or background work.
  • houradvantage_db_connections_held{caller}
    Pooled database connections held now, by who holds them (by the name of the work that asked). With houradvantage_db_pool_in_use it says who holds the pool when callers wait.
  • houradvantage_db_unnamed_checkouts_total
    Times work that has no caller name took a pooled database connection. It should stay at 0. Such work is counted under other and the first places are written to the log.
  • houradvantage_partition_connections_total{log,for}
    Database connections opened outside the pool to make the events’ daily partitions, one at a time on an instance. They count against the database’s connection limit, not the pool’s. for="missing" is a day’s partition being made. It is made ahead, so this is rare. for="past day" is a late event naming a day before today. Its partition is looked for each time.
  • houradvantage_db_oldest_hold_seconds{caller}
    How long the longest current hold of each caller has lasted. A hold that does not end shows here.
  • houradvantage_store_sync_advance_seconds{step}
    The steps of the write that keeps sync members’ marks and moves their watermarks, by step.
  • houradvantage_events_stored_total{type}
    Events stored.
  • houradvantage_events_not_stored_total{endpoint}
    Events a cursor or none package’s message made that could not be stored.
  • houradvantage_events_dropped_total{endpoint,type,reason}
    Events a device sent that its endpoint dropped before storing them. The reason is biometrics_off or drop_events. biometrics_off means a biometric or photo type, and the endpoint does not collect biometrics. drop_events means the endpoint’s option names the type.
  • houradvantage_sink_behind{log,sink}
    How many events the log has stored after the sink’s position, from the instance delivering to it. It is 0 on the others. It counts the log’s sequence numbers. So it includes events of other tenants and numbers that a write which was rolled back used. It is 0 for a sink that has taken everything stored. That includes a sink that takes only some of the events: a sink that is filtered is moved past those it does not take.
  • houradvantage_sink_oldest_waiting_seconds{log,sink}
    Age of the oldest event after the sink’s position that is for it. 0 when there is none.
  • houradvantage_sink_failing{log,sink}
    1 while the sink refuses deliveries from this instance.
  • houradvantage_sink_deliveries_total{log,sink,result}
    Deliveries. The result is ok or failed.
  • houradvantage_events_held{log,tenant}
    Events past retention_days that a sink has yet to take, kept for it, by tenant. It comes from the instance that last tidied, so take the maximum over the instances. 0 when there are none. The only way out is the sink taking them or the operator moving it past them (hourctl sink position).
  • houradvantage_event_horizon_waiting{log}
    1 while this instance waits for a transaction that stores events to end. A sink cannot read past an event whose transaction is still open, so the events after it wait too. It goes back to 0 when the transaction ends, whether it commits or rolls back. A 1 that does not go means a transaction is held open: look for it in the database.
  • houradvantage_event_horizon_wait_seconds{log}
    How long each of those waits lasted.
  • houradvantage_event_horizon_looks_total{log,from}
    Looks at how far the events are in place. from is cache (the number kept in the shared cache was still exact) or database.
  • houradvantage_sink_shards_held{log}
    Share of the sinks this instance delivers to.
  • houradvantage_sink_ready{log}
    Sinks with events waiting for a turn on this instance.
  • houradvantage_sink_turns_total{log}
    Delivery turns given to sinks.
  • houradvantage_sink_turn_phase_seconds{log,sink,phase}
    How long each part of a delivery to a sink took (a histogram, buckets from half a millisecond to ten seconds). batch is reading the batch. For a sink that is behind, batch includes horizon (the position below which events can be read), pool (waiting for a connection) and read. A sink that has caught up is given events as they are stored, and records none of these. ids is finding the people’s ids. send is the send. settle is recording the delivery. A measurement: nothing decides on it.
  • houradvantage_sync_rows_put_back_total{why}
    Rows the sync engine put back to be sent to a member again, by the step that did it. The steps are inventory_all, inventory_differs, id_change_refused, redeclared, placement, recheck_or_change and replace. For what a device reported that differs from the group’s, the steps are person_unsent, person_edit, person_extra, credential_bytes, credential_extra, setting, item_extra, item_deleted and item_differs. A rising count with no change on the clock means the same rows are being sent twice.
  • houradvantage_sync_inventory_extra_users_total
    Users a clock reported that it still carries from a group it left. The group does not hold them and does not delete them. Each is told to the app by an inventory.extra_user event. Present from the engine’s start, at 0.
  • houradvantage_sync_replace_unverifiable_total
    Id changes that went on unverified because the member cannot confirm the old user is gone. It can only upload its inventory, and an upload without the user may be partial. The daily inventory finds a user still there.
  • houradvantage_sync_inventory_asked_total
    Inventories asked of clocks. Present from the engine’s start, at 0.
  • houradvantage_sync_inventory_compared_total{result}
    Inventories whose upload was compared with what the clock should hold. The result is same, or differs (the differing users are sent again). Present from the engine’s start, at 0.
  • houradvantage_sync_inventory_uncompared_total{why}
    Inventories closed without comparing what the clock uploaded. The why is unverifiable (the package declares no inventory_complete), duplicate (more users came than the clock holds), superseded or failed (the inventory action failed). superseded means the member’s next inventory was asked, or it left, while one was still waiting for its upload to be complete. A clock that is always superseded never finishes uploading, or its count never settles.
  • houradvantage_sync_shared_loads_total
    Times a sync group’s shared part (its access rows, id changes and lists) was read from the store. A pass uses the one kept while the group has not changed.
  • houradvantage_sync_shared_load_seconds
    How long reading it took.
  • houradvantage_sync_after_reply_under_way
    Pieces of work that device messages left to be done after their replies, under way now on this instance. This work is: punch state pushed to the group’s members, biometric data refused and reported, a device’s own sync rows settled, and punches set aside worked out again. The work of one device or group that is asked again while it is under way is done together in the one that is. So this follows the number of devices and groups with such work, not the number of messages. It grows while the database is slow. It returns to 0 when it has caught up.
  • houradvantage_sync_window_bytes_in_flight
    Bytes of members’ windows of sync work the passes of this instance hold now (what each member can hold at the most). A pass reconciles a group’s members in chunks. A chunk holds its members’ windows until its effects are written. All the passes of the instance (every group’s) share one budget. So what they hold follows the budget and not the size of a group.
  • houradvantage_sync_pass_phase_seconds{phase}
    Where a sync group’s passes spend their time. The phase is one of these. roster is members read and tidied. shared is the registry’s shared part. work is which members have work. settle is also a phase. walk is windows read and rows looked at. build is actions built through the packages. start is actions saved. advance is marks and watermarks written.
  • houradvantage_sync_passes_in_flight{group}
    Sync passes under way now, by group: at most one per group on an instance.
  • houradvantage_asks_failed_total{what}
    Asks of the database that could not be answered, by what was asked: sync_lease (whether this instance holds a sync group’s lease) or shards (which sink shards it holds). Each is asked again after a wait of up to 30 seconds. Normally 0; a count that keeps rising means the database is failing these asks.
  • houradvantage_sync_window_budget_bytes
    The most bytes of members’ windows the passes of this instance may hold at once. It is 20% of the memory the instance may use (the container’s limit, or HOURADVANTAGE_MEMORY_MIB). A member costs its window of rows and its room’s rows, each held a few times. That is about 5.5 MiB for a clock whose package declares 200 commands a reply. The budget is about 205 MiB at 1 GiB.
  • houradvantage_attend_people_marked{tenant}
    Time and Attendance: people waiting to be worked out again. It is set every 10 seconds from the database, and is the same on every instance.

  • houradvantage_attend_oldest_mark_seconds{tenant}
    How long the oldest of them has waited. Alert on it growing, not on the count. A change made while the person is being worked out waits from its own time, not from the first mark.

  • houradvantage_attend_oldest_job_seconds{tenant}
    How long the oldest person this instance is working out for the tenant has been worked on. It is set every 10 seconds, and is 0 when none. One job running for minutes is one that is not ending. Look at that tenant’s people (their punches, the policy).

  • houradvantage_attend_deliveries_total{tenant,result}
    Punch deliveries. The result is accepted, refused_signature or refused_other. refused_signature means no key of the tenant’s proves it. refused_other means no tenant named, none by that name, or it is suspended. A name that is no tenant is counted under none. The counters below measure how much work recalculating takes. Nothing decides on them.

  • houradvantage_attend_redo_people_total{tenant}
    People worked out.

  • houradvantage_attend_redo_days_worked_total{tenant}
    Workdays worked out.

  • houradvantage_attend_redo_days_read_total{tenant}
    Days of facts read.

  • houradvantage_attend_redo_full_reads_total{tenant}
    People worked out from all of their facts, as after a change to the whole tenant.

  • houradvantage_attend_redo_full_reads_by_start_total{tenant,set_by}
    The same, by what started it. A person’s first working out is always unrecorded.

  • houradvantage_attend_redo_ledgers_total{tenant}
    Ledgers worked out.

  • houradvantage_attend_redo_reworked_total{tenant}
    Ledgers worked out a second time because a rule asked about days outside the period. Low compared with the ledgers.

  • houradvantage_attend_redo_started_at_total{tenant,stage}
    People worked out, by the step the work started from. none means nothing had changed.

  • houradvantage_attend_read_start_days{tenant,set_by}
    How far back a person’s facts are read (a histogram, in days).

  • houradvantage_attend_read_before_start_total{tenant,read}
    People whose working out had to read further back than planned, by what asked. Normally 0 after the first working out.

  • houradvantage_attend_read_everything_total{tenant}
    People whose facts had to be read in full after reading further back was not enough. Always 0. Report it if it is not.

  • houradvantage_attend_prework_total{tenant}
    People whose facts began to be read. Above the people worked out means reads were repeated.

  • houradvantage_attend_earlier_served_total{tenant}
    People whose earlier periods were served from kept ledgers instead of being worked out again.

  • houradvantage_attend_kept_healed_total{tenant}
    After an upgrade: kept ledgers that came out the same under the new build, so they are served again.

  • houradvantage_attend_kept_differs_total{tenant}
    After an upgrade: kept ledgers that come out differently under the new build. Normally 0. They are left as they are.

  • houradvantage_attend_redo_by_cause_total{tenant,cause}
    People worked out, by what changed: punch, fact, correction, setup, metadata, load, relay or other. A person can count under more than one.

  • houradvantage_attend_redo_days_worked_by_cause_total{tenant,cause}
    Workdays worked out, by cause.

  • houradvantage_attend_redo_days_read_by_cause_total{tenant,cause}
    Days of facts read, by cause.

  • houradvantage_attend_redo_full_reads_by_cause_total{tenant,cause}
    Full reads, by cause.

  • houradvantage_attend_mark_wait_seconds{tenant,cause}
    How long a mark had waited when a worker claimed it, counted from the first mark since the person was last worked out. It is by the cause of that first mark (a histogram, buckets from 1 s to an hour). This is the wait to be claimed, not yet to be worked out. A mark made while the person is worked out waits from its own time.

  • houradvantage_attend_mark_done_seconds{tenant,cause}
    As houradvantage_attend_mark_wait_seconds, to when the person was worked out.

  • houradvantage_attend_punch_done_seconds{tenant}
    How long the first punch among the marks that waited had waited when the person was worked out. A punch that joins a person marked for something else is measured from its own mark.

  • houradvantage_attend_policy_errors_total{tenant}
    Times a person’s ledgers failed to be worked out.

  • houradvantage_attend_unreadable_total{tenant}
    Punches delivered that could not be read (unreadable punches).

  • houradvantage_attend_package_updates_failed_total
    Time and Attendance: times its package.updated events could not be told. They wait and are tried again at the next run.

  • houradvantage_attend_package_updates_unreadable_total
    Kept package.updated rows that could not be read and were dropped (the log says what each held).

  • houradvantage_attend_relay_trail{tenant}
    A histogram of how many passes a change had been through when a worker’s record passed it on to the worker’s other records: one reading at each pass. A chain that settles is short. One that keeps growing is records whose policies keep changing each other without ever repeating a state: the engine caps nothing and says only what it sees. A cycle (a state that came back) is parked with recalculation.parked, reason unsettled; a work or turn limit that parks such a person names the passes in its event.

ConditionWhy
houradvantage_database_up == 0 on any instance for more than a minuteClocks are being told to try again. Readiness does not show it.
houradvantage_ready == 0 on every instance, or on one for longNo instance, or one fewer, takes work.
houradvantage_config_version differing between instances for more than a few secondsAn instance cannot apply a change (hourctl peers shows config_error).
Rising rate of houradvantage_requests_total{status=~"5.."}Devices are being told to try again.
houradvantage_sink_failing == 1, houradvantage_sink_oldest_waiting_seconds growing, houradvantage_sink_behind growing, or a sink.behind eventA sink is down or falling behind. Its events wait for it, and the log grows.
houradvantage_events_held growing for a tenantThat tenant’s sink has not taken events past retention_days. The storage is the tenant’s own. Fix the sink or move it past them.
houradvantage_http_connections_refused_total risingA listener is at its connection limit.
houradvantage_http_source_connections_refused_total risingOne address holds a tenth of a listener’s connections. The log names it and says how many it holds. Many clients behind one address is a proxy the install has not declared. Put it in trusted_proxies, or turn on proxy_protocol so each client is counted on its own address.
houradvantage_attend_oldest_mark_seconds growingPeople are not being worked out as fast as they are marked.
houradvantage_attend_oldest_job_seconds over a few minutes for a tenantOne person’s working out is not ending. It holds a thread, and its claim for as long as the instance lives. With houradvantage_attend_oldest_mark_seconds growing for the same tenant, it is a stuck job, not a backlog.