Reference
Look up what an install runs with. This page covers the environment each instance reads, the settings kept in the database, the layout of a setup file, and the options every endpoint takes. The table below links the rest of the reference.
| Reference | What it covers |
|---|---|
| Command line | Every hourd, hourctl and houradm command and flag, with examples. |
| Admin API | Access, conventions and errors of the HTTP API. |
| Endpoints | Every admin API operation: parameters, bodies, answers and errors. |
| Events | What each event type means and when it is sent. |
| Event schemas | The JSON Schema of every event type, field by field. |
| Scaling | Fixed limits and how an instance sizes itself. |
| Metrics | The Prometheus metrics on /metrics. |
Environment
Section titled “Environment”An instance has no config file. The setup is kept in the database. What an
instance needs before it reaches the database comes from environment
variables. Some are also given as hourd run flags. A flag wins over its
variable.
A variable marked _FILE can instead be given as a file. Add _FILE to the
variable’s name, and set that to the path of a file holding the value (the
Docker and Kubernetes secrets layout). One trailing line break is ignored.
Setting both the variable and its _FILE form is refused.
| Variable / flag | Default | Meaning |
|---|---|---|
HOURADVANTAGE_DATABASE_URL (_FILE), --database-url | required | The Postgres URL, shared by every instance: postgres://houradvantage:secret@db/houradvantage. sslmode works as in libpq. Its values are disable, prefer, require, verify-ca (signed by the CA in the root certificate file, any host name) and verify-full (the host’s own certificate). Give a private CA in sslrootcert= in the URL or in PGSSLROOTCERT (TLS). |
HOURADVANTAGE_DATABASE_SESSION_URL (_FILE), --database-session-url | the database URL | The database itself, for the connections that keep a session (the sink leases, the migration). This is for when the database URL leads to PgBouncer in transaction mode (Operations, PgBouncer). |
HOURADVANTAGE_CACHE_URL (_FILE), --cache-url | none | The Valkey the instances share, to tell each other what changed and keep what they read of the devices: redis://, redis-sentinel://, redis-cluster:// or rediss://. With it any number of instances may share the database. Without it the instance is the only instance: a second one, or one with a Valkey beside one without, refuses to start (Operations, a shared Valkey). |
HOURADVANTAGE_CACHE_RECONNECT_FIRST_MS, --cache-reconnect-first-ms | 100 | The pause before the first try to reach the Valkey again after its connection is lost, in milliseconds. Each later pause is twice the one before, up to the longest. Must be at least 1. |
HOURADVANTAGE_CACHE_RECONNECT_LONGEST_MS, --cache-reconnect-longest-ms | 30000 | The longest pause between tries to reach the Valkey again, in milliseconds. Not shorter than the first. |
HOURADVANTAGE_CACHE_INSTALL, --cache-install | default | The install’s id in the Valkey, the first part of every key, so that installs may share one Valkey. |
HOURADVANTAGE_SECRET_KEY (_FILE) | none | The key that seals the secrets kept in the database. These are broker passwords, webhook secrets, device keys, and the templates and PINs a sync group keeps. The key is 32 bytes, base64 or hex, from houradm gen-secret-key. Every instance needs the same key. Without one, an instance whose database keeps secrets refuses to start, and a request to keep a secret is refused (409). The exception is when HOURADVANTAGE_ALLOW_PLAIN_TEXT_SECRETS is set (secrets at rest). |
HOURADVANTAGE_SECRET_KEYS_OLD (_FILE) | none | Previous keys, separated by commas, spaces or line breaks. They are used to read what they sealed while you change the key (changing the key). |
HOURADVANTAGE_ALLOW_PLAIN_TEXT_SECRETS | none | true to start without HOURADVANTAGE_SECRET_KEY while the database keeps secrets, keeping them as plain text. Without it, such an instance refuses to start (secrets). |
HOURADVANTAGE_ADMIN_LISTEN, --admin-listen | 127.0.0.1:9090 (container image: 0.0.0.0:9090) | Where the admin API and /metrics listen, as IP:port. Any address other than loopback needs an admin login. hourd healthcheck reads it too. |
HOURADVANTAGE_ADMIN_USERNAME, HOURADVANTAGE_ADMIN_PASSWORD_HASH (each _FILE) | none | The admin API’s login: a user name and an argon2id hash from houradm hash-password. It asks for the password. --stdin reads it from the first line of stdin. Set both or neither. Once set, every admin request needs the login or an API token, on loopback too. |
HOURADVANTAGE_INSTANCE_ID | the host name (HOSTNAME, else COMPUTERNAME, else /etc/hostname, lower-cased) | This instance’s name. It must be unique among the instances sharing the database. A second instance under a name in use waits at startup, with a warning, until the first is gone, and then starts. The name is a lock of the instance’s database session. It must stay the same across restarts (MQTT persistent sessions are kept under it). It must be under 50 characters (instance ids). |
HOURADVANTAGE_CPUS | detected (honours a container’s CPU limit) | The processors this instance sizes its work for. That covers its database connections, its async runtime, Time and Attendance’s recalculation and cost threads, and the package VMs it keeps ready. Set it in a pod without a CPU limit. Such a pod otherwise sees the whole node. A value that is not a whole number above 0 is ignored with a warning. |
HOURADVANTAGE_MEMORY_MIB | detected (the container’s memory limit, else the host’s) | The memory this instance sizes what it holds at once for, in MiB. The sync passes’ windows are a share of it (Operations, Capacity planning). |
HOURADVANTAGE_ADVERTISE_ADDR, --advertise-addr | detected | Where the other instances reach this one’s admin API, for live views across instances. It is host:port, a host (the admin port is added), or http(s)://host:port. Detected: the admin listener’s address. When it listens on every address, POD_IP, else the address this host reaches the database from (live views). |
HOURADVANTAGE_ENVIRONMENT | none | The cluster’s environment name, free text (production, test). It is shown in GET /api/instance and hourctl peers, and by hourctl before every change (environments). Give every instance the same. |
HOURADVANTAGE_ATTEND | off | on (or true, yes, 1) runs Time and Attendance on this instance. That covers its schema, the in-process receiver attendance, /api/attendance/... and recalculation workers, for every tenant of the install. Unset, empty, off, false, no or 0: this instance runs only Connect, and answers /api/attendance/... with 503. |
HOURADVANTAGE_PRODUCTION | false | true (or 1, yes) marks a production cluster. hourctl prints changing PRODUCTION (host) before every change. Any value other than true, 1, yes, false, 0, no or empty stops the instance at startup. |
RUST_LOG | unset | A log filter that wins over the stored log.level at startup, for debugging. |
hourctl reads its own:
| Variable / flag | Default | Meaning |
|---|---|---|
HOURADVANTAGE_ADMIN_URL, --admin | http://127.0.0.1:9090 | The admin API to talk to. |
HOURADVANTAGE_ADMIN_USERNAME (_FILE), --admin-user | none | The user name to log in as. It is the same variable the gateway reads its login from. |
HOURADVANTAGE_ADMIN_PASSWORD (_FILE) | none | The password. It is never taken on the command line, where the process list would show it. |
HOURADVANTAGE_ADMIN_TOKEN (_FILE) | none | An API token (hourctl token create), sent instead of the login. |
HOURADVANTAGE_TENANT, --tenant, -t | Connect: default | The tenant a command works on. In Connect, that is whose listeners, endpoints, sinks, sync groups, devices, jobs, vars and secrets. In Time and Attendance (hourctl attend), that is whose time. Every command but attend tenants and attend test needs it named. |
--install | off | Work on the install’s own setup instead of a tenant’s. That is the install-level sinks, and apply and export of an install file (the install’s setup). |
These flags, and --json (print the API’s JSON answer), go anywhere after
hourctl.
Settings
Section titled “Settings”Settings are shared by every instance and kept in the database. You change
them while the gateway runs, with hourctl settings set key=value,
PATCH /api/settings, PATCH /api/logs (the log level) or a setup file.
| Setting | Default | Meaning |
|---|---|---|
limits.max_body_bytes | 4194304 (4 MiB) | The largest device message accepted, in bytes. Larger ones are refused. Above 0. |
limits.max_pending_devices | 100 | Devices waiting to be allowed, per endpoint. 0 for no limit. Beyond it, new devices are answered 429 until some are allowed or removed. A pending device that stops calling is forgotten after a day. |
limits.set_aside_days | 7 | Days an MQTT message set aside is kept. Past it, the message is dropped and its device’s tenant is told (device.set_aside.expired). |
limits.traffic_body_bytes | 16384 (16 KiB) | How much of each message body the traffic log keeps. The traffic log is /api/tenants/{tenant}/traffic, each instance’s last 1000 messages, in memory. 0 keeps none. Bodies can hold credentials and biometric data. |
limits.tenants | none | The install’s defaults for every tenant’s limits: devices, pending_devices, people, messages_per_second and set_aside (default 10000). A tenant’s own limits override them. Absent or 0, no limit. |
retention_days | 30 | Days a finished command, a finished job, a delivered event or a sync group’s deleted row is kept. Audit entries have audit_retention_days. An event a sink has not taken is never removed for its age. It waits for the sink, and a sink behind is told with sink.behind (retention). Above 0. Lowering it removes delivered events sooner and is never refused. PATCH /api/settings takes a force parameter that has no effect. |
audit_retention_days | unset | Days an audit entry is kept. Unset, entries are kept for ever. hourctl settings set audit_retention_days=365 keeps a year. audit_retention_days= (empty) puts it back. Above 0 (the audit trail). |
trusted_proxies | none | Load balancers in front of the device listeners, as addresses or CIDR ranges (10.0.0.0/8, 192.0.2.7). X-Forwarded-For (and a PROXY header) is believed only from these (client addresses). |
tenant_destinations | none | Internal addresses, CIDR ranges or host names that tenants’ webhook sinks and MQTT brokers may reach, besides public addresses. A listed name may resolve to any address. The install’s own sinks are not filtered (where a tenant’s setup reaches). |
log.level | info | The log level on every instance, in RUST_LOG syntax: hourctl logs level "info,houradvantage=debug". |
hourctl settings set takes the limits settings with or without their
limits. prefix:
hourctl settings set max_pending_devices=50 retention_days=14hourctl settings set trusted_proxies=10.0.0.0/8,192.0.2.7Everything else is fixed, or sized from the processors (scaling).
Setup file
Section titled “Setup file”hourctl apply <file> [--dry-run] makes the running gateway match a
TOML file. hourctl export prints the current setup in the same
layout, with secrets left out.
A setup file is one tenant’s (--tenant, default unless named). It holds
its listeners, endpoints, sinks, sync groups and devices’ labels, and the
install’s settings if you like. An install file (hourctl --install apply)
has [[tenant]] and the install-level [[sink]]s, and the settings.
apply refuses a section that belongs in the other kind of file, saying
which (tenants).
The gateway never reads this file itself. apply goes through the admin
API. It creates what is missing, updates what differs, and never removes
anything. A key not listed below is refused before anything is sent.
examples/setup.toml
is a commented example.
trusted_proxies = ["10.0.0.0/8"] # top-level settings come before the first [section]retention_days = 30
[[listener]]id = "public"type = "http" # or "mqtt"listen = "0.0.0.0:8080"
[[sink]]id = "payroll"type = "webhook"url = "https://example.com/hooks/clock"secret_env = "HOURADVANTAGE_WEBHOOK_SECRET"events = ["punch", "command.result"]
[[sync_group]]id = "hq"domains = ["people", "punches"]
[[endpoint]]id = "office"listener = "public"path = "/office"options = { timezone = "America/Chicago" }sinks = ["payroll"]sync_group = "hq"
[[device_labels]]endpoint = "office"device = "CG0001"labels = { area = "warehouse" }
[limits]max_pending_devices = 100
[log]level = "info"| Table | Fields |
|---|---|
| top level | retention_days, audit_retention_days, trusted_proxies, tenant_destinations. |
[[listener]] | id, type (http or mqtt). http: listen (IP:port), allow_from, deny_from, proxy_protocol (networking). mqtt: broker (mqtt:// or mqtts://host:port), username, password_env (the variable holding the password, read where hourctl apply runs), window and ack_wait_secs. window is required. It is how many unacknowledged messages the broker gives the listener at once, 1 to 65535. It is the broker’s own setting, Mosquitto’s max_inflight_messages (MQTT). ack_wait_secs is the seconds a message may hold back the acknowledgements of those after it, before the listener starts no new message. Default 30 (MQTT). |
[[sink]] | id, type (webhook or in_process), url (a webhook’s http or https URL). secret_env is the variable holding the secret. That is a webhook’s signing secret, or for an attendance sink a delivery key its tenant issued. receiver is an in_process sink’s receiver, attendance. It takes no url. tenant is the receiver’s tenant: the Time and Attendance tenant an attendance sink delivers to, which it must name. events are the types it is sent. Empty or absent: the default set. sources are systems whose posted events it is sent. connect is for Connect’s own events about the tenant. Then match, latest_only, max_per_second, batch, batch_bytes (choosing what, and how fast). system is the system the sink speaks for, e.g. payroll. It is sent the punches routed there. Each event about a person carries their id in it as person_id. With tenant, it is the tenant in that system. |
[[sync_group]] | id, domains, sinks, people, access, lists, settings, punches (each domain’s table). [[sync_group.placement]] (people and devices selectors). routes (default routes). external_ids, metadata (sync groups). |
[[endpoint]] | id, listener, path (http) or topic and reply_topic (mqtt), package. policy (its policy package). back_after_minutes (how long away is back). routes (default routes), sinks. new_devices (hold, allow or refuse; new devices). options (below). sync_group, labels, metadata, allow_from, deny_from. |
[[device_labels]] | endpoint, device, labels: a device’s own labels. The device must already be known. |
[[tenant]] (install file only) | id (1 to 64 letters, digits, - or _; it cannot be changed), name, status (active, the default, suspended or stopped), external_ids, metadata, limits (tenants). |
[limits] | max_body_bytes, max_pending_devices, set_aside_days, traffic_body_bytes. |
[log] | level. |
The API takes the same fields as JSON, with password and secret in
place of the _env names.
Endpoint options
Section titled “Endpoint options”An endpoint’s options are those its package declares (typed; hourctl pkg show <name> --json lists them). Every endpoint also takes two options the
gateway reads itself, whatever its package:
| Option | Default | Meaning |
|---|---|---|
biometrics | false | Collect templates, photos and identity documents (biometric, biometric.photo, user.photo, photo and id_card events). Without it, those events are dropped before they are stored, and packages do not ask devices for them (biometric data). |
drop_events | none | Event types dropped before they are stored, as a list (["user", "photo"]) or comma-separated text ("user,photo"). Types match exactly. It applies to events the package emits, command.result, action.result and job events. The gateway’s other events (command.unanswered, device.new, biometric.refused, device.held, device.released) are always stored. |
One package option is common enough to list here:
| Option | Default | Meaning |
|---|---|---|
timezone | (package) | Declared, and required, by packages whose devices send times without an offset (ZKTeco). It is an IANA zone name (America/Chicago) or a fixed offset (-05:00). It is also the zone a job’s window is read in for the endpoint’s devices. |
The ZKTeco packages’ options are listed under endpoint options.