Repository navigation
Monitoring and Alerts
What kingresd watches, the alerts it raises, the metrics it exposes and the logs it keeps. All of it is built and matches kingres/control-plane/internal/monitor and the contract (AlertKind has 45 kinds; the ones that nothing raises are listed below). No metrics store is bundled (ADR 0020); for history, scrape /metrics with your own Prometheus. See Operations for the rest of the operator's pages.
- A monitor round runs on every server every
monitor-interval(default10s, envKINGRES_MONITOR_INTERVAL). It raises and clears alerts in the system database (kingres_cp.alert) for its own server. The manager leader raises the alerts about other servers and about the cluster. - There is one open alert per kind and subject. A condition that holds again updates the open alert (severity and message) and never raises a second one. A kind whose reading was not measured is neither raised nor cleared. An open alert survives a restart of
kingresd. - A condition that ends clears the alert (state
resolved). A person can acknowledge an open alert (acknowledgeAlert, rolekingres_ops); that changes its state toacknowledgedand does not clear it. Listing alerts needskingres_readonly. - Where to see them: the REST operations
GET /api/v1/alerts(filter by state and severity) andPOST /api/v1/alerts/{alertId}/acknowledgement(REST API Reference), and the console (Web Console). Since contract 0.5.0 the listing is cluster-wide: a server collects the alerts of the others, and an alert id carries the number of the server that holds it. Severities areinfo,warningandcritical. - Each alert has a typed subject (server, group, database, task, aspect) that a client reads instead of parsing text.
| Kind | Raised when | Severity | Cleared when |
|---|---|---|---|
serverDown |
The instance of this server is not running (own check). The manager leader also raises it for another server whose heartbeats stopped for failure-timeout (default 10s) |
critical |
The instance runs again, or the server is heard again. An outage that ended is also recorded as a resolved alert |
serverSuspect |
A server sent no heartbeat for suspect-timeout (default 5s) but is not yet dead |
warning |
The server is heard again |
diskSpaceLow |
The data disk is at least 90% full (warning) or 95% (critical) |
warning, critical
|
Below 90% |
memoryPressure |
Less than 10% of the memory of the server is available | warning |
Back above 10% |
replicationLagHigh |
A standby of the server is more than 60 seconds behind, or the replication slot of a standby of a group holds more WAL than the warning limit (then the slot is dropped at the retention limit and the standby is rebuilt) | warning |
The lag is below the limit |
certificateExpiring |
The server's own certificate has less than half of the part of its lifetime at which it is renewed left: warning; less than an eighth, or expired: critical. For the cluster certificate authority (subject aspect ca): less than a year left is a warning, less than 30 days is critical. The CA is not rotated |
warning, critical
|
The certificate was renewed |
certificateRenewalFailed |
Three renewals in a row failed on that server |
warning; critical when less than a tenth of the lifetime is left |
A renewal succeeds, or the certificate was renewed by other means |
ledgerPendingTooOld |
The oldest pending ledger transaction of a database has waited ledger-pending-max-age (default 5m, env KINGRES_LEDGER_PENDING_MAX_AGE). The age is what the monitor observed: a restart of kingresd forgets it, and a new oldest entry starts it again, so it can only under-estimate |
warning; critical at twelve times the limit |
The queue of the database is empty or its oldest entry changed |
versionMismatch |
The servers that answer report different versions of KingresDB, of PostgreSQL or of an extension (kingres_shard, kingres_ledger). The manager leader checks every version-check-interval (default 1m). Needs at least two answers |
warning |
The servers agree |
replicationPending |
The manager leader keeps a change of roles, grants or settings waiting for a server it could not reach. Until the change arrives a role that was disabled, changed or dropped may still work on that server |
warning after 1 minute, critical after 10 |
The server has applied the change |
leaseLost |
The kingresd that runs the primary of a group could not renew the group's lease in time. With a standby, the primary was stopped (fenced). Without one, it keeps running and writes are not protected by a lease |
critical |
The lease is held again |
groupWithoutSynchronousStandby |
A group's standbys have not streamed for longer than the grace period (standby-sync-grace, default 30s) and the primary no longer waits for them: commits exist on one server only |
critical |
A synchronous standby streams again |
groupUnderReplicated |
Fewer standbys stream than the replica count, for three checks in a row. A cluster of one server never raises it | warning |
The count is reached |
clockDifference |
The clock of a server differs from the manager leader's by more than clock.maxDifferenceMs (default 1000 ms, a cluster setting), less the uncertainty of the measurement. kingresd does not set the clock: run NTP or chrony |
warning; critical at ten times the limit |
Back within the limit. An unreachable server is left to serverDown
|
Raised by the failover task and the standby code. See High Availability. Failover is new in the first release: test your recovery procedure on your own cluster before you rely on it.
| Kind | Meaning |
|---|---|
failoverNeedsDecision |
critical. A failover could lose data and waits for allowDataLoss
|
failoverBlocked |
warning or critical. A failover cannot proceed: no standby to promote, the deciding server cannot hear a majority, the old lease holder is still heard, or the catalogs cannot be followed |
failoverDataLoss |
warning. check_cluster() reported lost or rolled back transactions after a failover |
splitPromotion |
critical. Two instances of a group are out of recovery, or an instance was promoted outside the failover |
oldPrimaryNotStopped |
critical. The old primary could not be stopped; the lease keeps it from acting |
oldPrimaryRunning |
critical. The old primary runs after the catalog moved; it is being stopped |
oldPrimaryNotRebuilt |
warning. After the shorter of ten minutes and half of standby-replace-after (default 30m) the old primary is still not a standby |
autoFailoverTriggered |
info. An automatic failover ended |
autoFailoverLimitReached |
critical. The limit autoFailover.maxCount is reached; fail over by hand or reset the counter |
certificateAuthorityUnavailable |
critical, subject cluster. After a failover of the map group the new leader holds no key of the certificate authority (the escrow was off or its copy was not current); no certificate can be issued, renewed or revoked until pki/ca.key and pki/revoked.json of the old leader are restored from its backup |
taskFailed |
warning. A rebalance ended failed (subject task:<id>); a cancelled rebalance raises none |
rebalanceFailed |
warning, subject cluster. The last automatic rebalance failed; the automatic mode is suspended until an operator starts a rebalance or looks at the report |
| Kind | Meaning |
|---|---|
partitionsAheadLow |
warning. The last partition of a table with a time-partition policy ends before the lookahead floor (subject: the table) |
partitionPolicyFailed |
warning. The last run of a time-partition policy did not succeed, or the policy is not run (subject: the table) |
transferStagingLow |
warning when the staged files of the data transfer hold 90 percent of dataTransfer.stagingQuotaBytes, critical at 98 percent. Raised by the server that holds the files, the manager leader |
extensionSchemaUntrusted |
critical. The schema of a KingresDB extension in a database is not owned by a superuser, holds an object that is not a member of the extension, or lets a role that is not a superuser create objects in it; the readings of that database that depend on the extension are not available until the owner and privileges are restored |
extensionSkipped |
warning, one alert for each skipped extension (subject: server and database, aspect extension:<name>). An extension of a database was not installed on a server because a role of the tenant made the schema of the extension its own. Adding the server again re-applies it; see operator guide, section 10
|
The alert kinds were added to the contract in 0.11.0; the subjects are in the AlertSubject schema. See Ledger Signing and Publication and Ledger Anchoring for these parts.
| Kind | Meaning |
|---|---|
ledgerNotAnchored |
A database has ledger tables and no anchor target is enabled. info, warning when the setting anchor.required is on |
ledgerAnchorBehind |
The anchoring of a target is behind. warning, critical
|
ledgerAnchorFailed |
An anchor record is failed or expired. critical
|
ledgerAnchorConflict |
The store holds a different object under the name of an anchor. critical
|
ledgerChainDiverged |
A chain no longer extends its published log. critical. Needs an operator (Runbooks) |
ledgerGroupUnread |
The chain of a shard group could not be read. warning, critical
|
ledgerPublicationBehind |
In the contract (the newest signed checkpoint of a chain is older than five publication intervals while its head advanced; warning); in 0.2.0 nothing raises it. In release 0.2.1, the scheduled audit of the publication raises it (warning) when the head of the database has advanced and the newest checkpoint is older than five publication intervals, or a log has leaves and no checkpoint |
ledgerPublicationAltered |
(since 0.2.1) The scheduled audit found that a tile, a stored checkpoint, a signature or a block of the database is not what it must be, or that the publication was emptied, shrunk or rolled back against the high-water mark. critical, and sticky: it stays until an administrator acknowledges it (acknowledgeLedgerPublicationAlteration, kingres-cli ledger audit-ack), whatever a later audit finds. See Ledger Anchoring
|
ledgerPublicationUnreadable |
(since 0.2.1) The store, the key set or a shard group could not be read, so the audit cannot say (an unreadable store is never reported as altered). warning, critical after three audits in a row |
ledgerSignerUnavailable |
No checkpoint could be signed for two rounds, the key set is damaged, the key file is missing on the leader, or (subject published-state) the database is behind the record of what was published. critical
|
ledgerDigestOverdue |
No digest within twice digestIntervalSeconds. warning
|
The enumeration AlertKind in the contract also lists underReplicatedBuckets, unavailableBuckets, rebalanceNeeded, mapGroupUnavailable, ledgerVerificationFailed and ledgerPublicationBehind. The control plane code contains no place that raises them. Clients must tolerate kinds they do not know.
-
Sampler. Every 10 seconds
kingresdfills a bounded in-memory ring (1440 points per series, 2000 series). Series:connections,cpuUsagePercent,memoryUsedBytes,diskUsedBytes,replicationLagSeconds,replicationLagBytesper server;databaseSizeBytesandtransactionsPerSecondper database; and, for the data transfer,transferStagingUsedBytes,transferStagingFreeBytes,transfersRunningandtransfersStaged. The ring is lost at a restart. -
GET /api/v1/metrics/queryresamples the ring (average per step, at most 5000 points per series, 422 beyond).queriesPerSecondandbucketsUnderReplicatedare in the contract and have no samples yet. The console charts read this operation. -
GET /metricsis Prometheus text, one gauge per series namedkingres_<name in snake case>(for examplekingres_disk_used_bytes, with labelsserveranddatabase). It is outside the REST contract and requires authentication: a bearer token of a session with the rolekingres_statsor better, or the scrape tokenmetrics-token(envKINGRES_METRICS_TOKEN); without either it answers 401. -
Client entry point counters. When the client entry point is on,
/metricsalso carrieskingres_client_connections_accepted,_active,_refused,kingres_client_connect_failures,kingres_client_connections_moved,kingres_client_connections_idle_closed,kingres_client_bytes_in,kingres_client_bytes_outand the same withkingres_client_standby_for the standby entry point. They are listed in the contract's metric enumeration for/metrics/queryasclient...andclientStandby...series. - Cluster-wide: the metrics and alerts reads are gathered from every server within
gather-timeout(default 3s); a server that does not answer is left out. - Health:
GET /healthzandGET /readyzneed no sign-in.
-
Manager log.
kingresdlogs throughslog, to the journal when run by the unit:journalctl -u kingres.log-level(debug,info,warn,error; defaultinfo) andlog-format(textorjson) are settings; the level can be changed at run time from the console (updateThisServerSettings) and a saved level wins over the configured one until changed again. Values are quoted, and the audit sink cleans actor and text, so a request cannot forge a line. -
Instance log. The PostgreSQL log of a package install is in
/var/lib/kingres/instances/1/pgdata/log/(weekday-rotated). The console andGET /api/v1/this-server/logsread the last part of it (from at most the last 1 MiB of at most 8postgresql-*.logfiles);GET /api/v1/logsgathers the logs of all servers. - Event lines of the client entry point are logged at debug level and carry no address and no data.
Every changing operation writes an event to audit.jsonl in the data directory of the server that handled it (setting audit-file); the file rotates at 64 MiB into audit.jsonl.<first id> and segments are never deleted. GET /api/v1/audit reads it. An event names the actor, the action (the contract lists many, for example login, loginFailed, setupTokenRejected, failoverServer, autoFailover, startRebalance, acknowledgeAlert, createLedgerSigningKey, revokeLedgerSigningKey, acknowledgeLedgerDivergence, certificateRenewalFailed, leaseLost), the outcome and the request id (X-Request-Id). Credentials are never in an entry. The signing and anchoring rounds write no entry per round; their failures are alerts and log lines. The audit file survives a reset of the server when it leaves a cluster. See Security Model.
This is a reading of the tables above, not a rule from the sources: serverDown, leaseLost, groupWithoutSynchronousStandby, splitPromotion, ledgerChainDiverged, ledgerSignerUnavailable and certificateAuthorityUnavailable are the critical kinds that say the cluster or its evidence is at risk; start with Runbooks.
- kingres/control-plane/internal/monitor/alerts.go
- kingres/control-plane/internal/monitor/kinds.go
- kingres/control-plane/internal/monitor/leases.go
- kingres/control-plane/internal/monitor/liveness.go
- kingres/control-plane/internal/monitor/replication.go
- kingres/control-plane/internal/monitor/metrics.go
- kingres/control-plane/internal/monitor/runner_checks.go
- kingres/control-plane/internal/standby/agent_primary.go
- kingres/control-plane/internal/standby/leader.go
- kingres/control-plane/internal/pgconfig/time.go
- kingres/control-plane/internal/membership/certjob.go
- kingres/control-plane/internal/failover/steps.go
- kingres/control-plane/internal/failover/auto.go
- kingres/control-plane/README.md
- kingres/api/openapi.yaml
- kingres/packaging/README.md
- kingres/docs/adr/0020-no-bundled-metrics-store.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations