2.6. QuasarDB REST server#
2.6.1. Introduction#
The QuasarDB REST server, qdb_rest, gives access to one QuasarDB cluster over HTTP and over Arrow Flight SQL.
A client of the server needs no QuasarDB client library.
The server has these functions:
The REST API runs queries, manages tables and reads and writes rows.
The Arrow Flight SQL endpoint lets applications and tools that support this open standard connect without custom code.
An embedded SQL engine, DuckDB with the Quasar extension, runs SQL queries on the two interfaces.
Health probes and Prometheus metrics give the state of the server to your monitoring system.
One server connects to one cluster. The server keeps no state between requests, so you can operate many servers behind a load balancer.
This page is for the system administrator who operates the server.
2.6.2. Installation on Linux#
The qdb-rest package contains the server.
To install it, see the Debian packages or the RPM packages.
The package installs these files:
File |
Function |
|---|---|
|
The server. |
|
The configuration file. All keys in it are comments, so the server uses the defaults. |
|
The systemd unit. |
The service operates as the user qdb and reads /etc/qdb/qdb_rest.yaml.
The Debian package enables and starts the service.
After the installation of the RPM package, enable and start the service yourself:
systemctl enable --now qdb_rest
After a change to the configuration file, start the service again:
systemctl restart qdb_rest
The service writes its log to the systemd journal:
journalctl -u qdb_rest
A package upgrade keeps your changes to the configuration file.
The package generates no TLS certificate. See TLS.
2.6.2.1. Archive#
The server is also available as an archive, qdb-<version>-<os>-<arch>-rest.tar.gz.
The archive contains the server as bin/qdb_rest and the reference configuration as etc/qdb_rest.yaml.
Extract the archive and start the server as the next section shows.
2.6.3. Start the server#
The server needs no configuration to connect to an insecure cluster on the same computer:
qdb_rest
Without options, the server connects to qdb://127.0.0.1:2836 and listens on the ports 40443 and 40493.
The server writes its log to the standard output.
The two warnings tell you that the server uses a temporary token key and a temporary certificate.
See Tokens and TLS.
{"time":"2026-11-11T09:40:54.039628Z","level":"INFO","msg":"starting","version":"3.15.0.dev0","commit":"e97f563dc07e030b1c3aab674723ee981402593d","build_mode":"release","qdb_api_version":"3.15.0.dev0"}
{"time":"2026-11-11T09:40:54.040077Z","level":"WARN","msg":"no auth.token_secrets configured; tokens are sealed under an ephemeral key and die with this process"}
{"time":"2026-11-11T09:40:54.041755Z","level":"WARN","msg":"no tls certificate configured; generated an ephemeral self-signed certificate","fingerprint_sha256":"1E:F8:84:3F:D3:38:A8:10:1B:18:86:91:85:47:6E:48:62:49:71:83:68:ED:95:DF:4E:F7:81:A5:4F:4F:55:11","hint":"the identity changes on every start; set listen.tls.certificate_file and listen.tls.private_key_file for a stable one"}
{"time":"2026-11-11T09:40:54.041993Z","level":"INFO","msg":"listening","proto":"https","addr":":40443","certificate":"ephemeral-self-signed","not_after":"2036-11-11T09:40:54Z"}
{"time":"2026-11-11T09:40:54.042333Z","level":"INFO","msg":"listening","proto":"flight","addr":":40493","certificate":"ephemeral-self-signed","not_after":"2036-11-11T09:40:54Z"}
To make sure that the server can connect to the cluster, call the readiness probe:
curl -k -i https://127.0.0.1:40443/api/status/readiness
The probe answers status 200 when the server can connect to the cluster.
To connect to a different cluster, give its URI:
qdb_rest --cluster-uri qdb://192.168.1.10:2836
For a production system, write a configuration file and give it to the server:
qdb_rest --config qdb_rest.yaml
2.6.4. Listeners#
The server has three listeners.
Listener |
Key |
Default |
Function |
|---|---|---|---|
HTTPS |
|
|
The REST API, the probes and the metrics, with TLS. |
Flight SQL |
|
|
Arrow Flight SQL, with TLS. This listener has no plain text mode. |
HTTP |
|
Off |
The REST API, the probes and the metrics, without TLS. |
The HTTPS listener and the Flight SQL listener start always.
The HTTP listener starts only when listen.http has a value, for example :40080.
An address has the format <ip>:<port>.
Without an IP address, the server listens on all network interfaces.
Warning
On the HTTP listener, the access tokens travel in plain text. An access token contains the credentials of its user in an encrypted form. Use the HTTP listener only when the network between the clients and the server is already encrypted. The server writes a warning to its log when the HTTP listener is on and the cluster is secure.
2.6.5. Configuration#
Each configuration key has three forms.
Form |
Rule |
Example for |
|---|---|---|
Key in the configuration file |
The path of the key |
|
Environment variable |
|
|
Command-line option |
|
|
The server reads the values in this sequence, and a later source replaces an earlier source:
The defaults.
The configuration file.
The environment variables.
The command-line options.
2.6.5.1. Configuration file#
The configuration file is a YAML file.
The --config option or the QDB_REST_CONFIG environment variable gives its path.
The server reads no configuration file by default.
This example is a configuration for a secure cluster:
listen:
tls:
certificate_file: "/etc/qdb/qdb_rest.cert.pem"
private_key_file: "/etc/qdb/qdb_rest.key.pem"
cluster:
uri: "qdb://192.168.1.10:2836,192.168.1.11:2836"
public_key_file: "/etc/qdb/cluster_public.key"
user_security_file: "/etc/qdb/qdb_rest_user.key"
auth:
token_secrets:
- "${QDB_REST_TOKEN_SECRET}"
These rules apply to the file:
The server replaces
${VAR}in a value with the value of the environment variableVAR. Use this to keep a secret out of the file.The server does not start when the file refers to an environment variable that is not set.
The server does not start when the file contains an unknown key. Thus an error in the name of a key cannot stay hidden.
A duration is a number with a unit, for example
8s,5mor336h.
2.6.5.2. Command-line options#
- --config <file>#
Reads the configuration from the file.
- --version#
Prints the version of the server and of the libraries that it contains, then stops.
- --help#
Prints each option with its default value, then stops.
Each configuration key is also an option.
A boolean option needs its value, for example --observability-pprof=true.
2.6.5.3. Reference#
This is the reference configuration file. It shows each key with its default value.
2.6.6. TLS#
The HTTPS listener and the Flight SQL listener use the same certificate.
Key |
Description |
|---|---|
|
The certificate, in the PEM format. |
|
The private key of the certificate, in the PEM format. |
Set the two keys together.
Without the two keys, the server generates a self-signed certificate at each start. The server keeps that certificate in memory and writes its SHA-256 fingerprint to the log. A client cannot verify such a certificate, and the certificate changes at each start. This is usually sufficient for a server behind a load balancer. It is not sufficient for a server that clients connect to directly from a public network.
2.6.7. Secure clusters#
For a secure cluster, the server needs the public key of the cluster and a user of its own.
Key |
Description |
|---|---|
|
The public key file of the cluster. An empty value means an insecure cluster. |
|
The user security file of the user that the server uses for the readiness probe. Mandatory when |
To create a user for the server, use quasardb user adder. For more information about users and keys, see the security manual.
The server does not use its own user for the requests of clients. Each client sends its own credentials to the login route. The server then connects to the cluster as that user, so the permissions of that user apply to each request.
The clients do not need the public key of the cluster.
2.6.8. Tokens#
After a login, the server gives an access token and a refresh token to the client. A token contains the credentials of its user in an encrypted form. The server keeps no list of tokens.
Key |
Default |
Description |
|---|---|---|
|
Empty |
The passphrases from which the server calculates the encryption keys of the tokens. |
|
|
The validity of an access token. |
|
|
The validity of a refresh token. The default is 14 days. |
2.6.8.1. Token secrets#
Without a token secret, the server generates a temporary encryption key at each start. This has two effects:
All tokens become invalid when the server starts again.
A token from one server is not valid on a different server.
Thus set auth.token_secrets for each production system.
Use a long, random passphrase.
Each person who knows the passphrase can read the credentials in a token.
When you operate more than one server behind a load balancer, give the same values to all servers for these keys:
auth.token_secrets
auth.argon2id.time,auth.argon2id.memory_mibandauth.argon2id.parallelism
A client can then send each request to each server.
2.6.8.2. Change a token secret#
The first passphrase in the list encrypts new tokens. The server accepts tokens from all passphrases in the list. Thus you can change the passphrase while clients stay connected:
Add the new passphrase as the first entry of the list. Keep the old passphrase as the second entry.
Start all servers again.
Wait for the duration of
auth.refresh_ttl. Each client that refreshes gets tokens from the new passphrase. After that time, no token from the old passphrase is valid.Remove the old passphrase from the list and start all servers again.
auth:
token_secrets:
- "new passphrase"
- "old passphrase"
The server has no operation that makes one token invalid.
2.6.9. Cluster sessions#
The server keeps open sessions to the cluster and uses them again for subsequent requests. Each user has a pool of sessions, because a session operates with the credentials of one user.
Key |
Default |
Description |
|---|---|---|
|
|
The maximum number of sessions that the server holds for all users together. |
|
|
The maximum number of sessions for one user. The anonymous user is one user. |
|
|
The server closes a session that had no request for this time. |
|
|
The server closes a session that is older than this time. |
pool.max_sessions is the limit on the load that this server puts on the cluster.
When all sessions are in use, a new request waits until a session becomes available.
The sessions of SQL queries are not part of this pool. See SQL engine.
2.6.9.1. Circuit breaker#
When the cluster does not answer, the server stops sending requests to it for a short time.
In that time, the server answers each request immediately with status 503 and a Retry-After header.
Thus requests do not collect on a cluster that cannot answer.
Key |
Default |
Description |
|---|---|---|
|
|
The number of consecutive connection errors or timeouts after which the server stops. |
|
|
The time that the server waits before it tries the cluster again. |
An error that the cluster reports for one request, for example an incorrect query, does not count as a failure.
2.6.10. SQL engine#
The server opens one instance of the SQL engine for each user who runs an SQL query.
The limits in the duckdb block apply to each instance.
Key |
Default |
Description |
|---|---|---|
|
1 GiB |
The memory limit of one instance, in bytes. |
|
|
The number of worker threads of one instance. |
|
Empty |
The directory for temporary files when a query needs more memory than the limit. With an empty value, such a query fails. |
|
|
The maximum size of the temporary files of one instance, in bytes. |
|
|
The maximum number of instances that are open at the same time. |
To calculate the maximum memory of the SQL engine, multiply duckdb.memory_limit by duckdb.max_instances.
With the defaults, the result is 16 GiB.
When all instances are in use, an SQL query from one more user gets status 503 with a Retry-After header.
Each instance has its own sessions to the cluster.
These sessions do not count against pool.max_sessions.
The duckdb.quasar block of the reference configuration contains their limits.
2.6.11. Logging#
The server writes its log to the standard output. The service manager or the container runtime collects and rotates the log.
Key |
Default |
Description |
|---|---|---|
|
|
|
|
|
|
|
|
The number of bytes of a query text that a |
The server writes one request line for each request and one query line for each query:
{"time":"2026-11-11T09:40:25.291191Z","level":"INFO","msg":"query","request_id":"01a1c9fa-e43b-73be-aaa8-d8edd82e416d","plane":"http","user":"tintin","session":"01a1c9fa-e40e-7785-9491-65f010660fc5","engine":"duckdb","duration_ms":15,"rows":1,"outcome":"ok"}
{"time":"2026-11-11T09:40:25.291237Z","level":"INFO","msg":"request","request_id":"01a1c9fa-e43b-73be-aaa8-d8edd82e416d","plane":"http","method":"POST","path":"/api/v2/query","status":200,"bytes":54,"duration_ms":16}
The request_id is the value of the X-Request-Id header of the response.
Use it to find all log lines of one request.
The session is the same for all requests that follow from one login.
2.6.12. Monitoring#
2.6.12.1. Health probes#
The probes need no token and return an empty body.
Route |
Response |
|---|---|
|
Status 200 when the server process runs. The probe does not connect to the cluster. |
|
Status 200 when the server can connect to the cluster and run a query. If not, status 503. |
The server also serves the two probes at /api/v2/status/liveness and /api/v2/status/readiness.
For the readiness probe, the server connects to the cluster as its own user and runs the query of observability.status.readiness_query.
The default query is SELECT 1.
The server writes the cause of a status 503 to its log.
Give the readiness probe to a load balancer as its health probe. Use the liveness probe to find a process that must start again.
2.6.12.2. Metrics#
The server serves metrics in the Prometheus format at GET /metrics, on the HTTP and HTTPS listeners.
The route needs no token.
Key |
Default |
Description |
|---|---|---|
|
|
|
|
|
The prefix of the metric names. |
Metric |
Description |
|---|---|
|
The version, the commit and the build mode of the server. |
|
The sessions in use and the maximum, for the limit |
|
The sessions of each user, for each state. |
|
The state of the circuit breaker: |
|
The number of read operations that the server tried a second time after a failure. |
|
The duration of the requests on the data routes of the REST API. |
|
The duration of the Flight SQL calls. |
|
The duration of the queries, for each engine and user. |
|
The duration of the operations on a cluster session. |
|
The time from the start of a request to the first byte of its result. |
|
The number of bytes in the results before compression, for each format. |
|
The number of rows in the results and in the write requests, for each format. |
The route also gives the standard metrics of the Go runtime.
This is a scrape configuration for Prometheus:
scrape_configs:
- job_name: qdb_rest
scheme: https
static_configs:
- targets: ["192.168.1.20:40443"]
2.6.12.3. Profiler#
With observability.pprof set to true, the server serves the Go profiler below /debug/pprof/.
These routes are not secured.
They are for debugging only, so keep the profiler disabled in normal operation.
2.6.13. Stop the server#
To stop the server, send the SIGTERM signal or the SIGINT signal to the process.
The server then does these steps:
It closes its listeners, so a load balancer cannot open a new connection.
It lets the requests in progress continue for the time of
listen.shutdown_grace. The default is8s.It closes the sessions to the cluster and stops.
Send the signal one time only. A second signal stops the server immediately and cuts the requests in progress.
2.6.14. Migration from the previous server#
This section is for a system administrator who replaces the previous REST server with this server.
The previous server is the qdb_rest that used a JSON configuration file.
2.6.14.1. Compatible parts#
These parts of the previous server continue to operate:
The login route
POST /api/loginand the query routePOST /api/query. The server also serves them as/api/v1/loginand/api/v1/query.The probes
/api/status/livenessand/api/status/readiness.The HTTP listener and the HTTPS listener, with their ports
40080and40443. The HTTP listener is off by default in this server.
Thus the QuasarDB plugin for Grafana and client programs that use the two routes need no change. For new client programs, use the version 2 routes.
2.6.14.2. Configuration#
The server does not read the JSON configuration file of the previous server. Write a new YAML file from the reference configuration.
The names of the options and of the environment variables are different. This table shows the new key for each option of the previous server.
Previous option |
New key |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These options of the previous server have no new key:
Previous option |
Cause |
|---|---|
|
The server writes its log to the standard output only. |
|
The server contains no dashboard. |
|
The server sends no CORS headers. |
|
The reference configuration replaces the generated file. |
|
The server has no configuration presets. |
2.6.14.3. Package upgrade#
An upgrade of the qdb-rest package from the previous server has these effects:
The service starts with the defaults of the new file
/etc/qdb/qdb_rest.yaml, and the package prints a notice that names this file.The previous files
/etc/qdb/qdb_rest.conf,/etc/qdb/qdb_rest.cert.pemand/etc/qdb/qdb_rest.key.pemstay on the disk. The server does not read them.The server writes no file below
/var/log/qdb. Read the log withjournalctl -u qdb_rest.
After the upgrade, copy your settings into the new file and start the service again.
To continue with your previous certificate, set listen.tls.certificate_file and listen.tls.private_key_file to the two previous files.
2.6.14.4. Changes in behavior#
The HTTP listener is off by default. The previous server listened on port
40080. To get the same behavior, setlisten.httpto:40080.The server listens on all network interfaces by default. The previous server listened on
localhostby default.Port
40493is the Flight SQL listener.The server needs no certificate file. Without one, it generates a self-signed certificate at each start.
The server rejects the tokens of the previous server. A client gets status 401 and must send its credentials to the login route again.
A token of the login route
/api/loginis valid for the time ofauth.access_ttl, which is 15 minutes by default. A token of the previous server was valid for 12 hours. Increaseauth.access_ttlif your client programs do not handle status 401.On a secure cluster, the login route answers status 401 for incorrect credentials. The previous server answered status 200 and the subsequent request failed.
The query route
/api/querywrites timestamps in UTC. The previous server used the time zone of its process.The query route
/api/querygives the typeint64to acountcolumn. The previous server gave the typecount.The server compresses a response with
gziporzstdas theAccept-Encodingheader of the request specifies.
2.6.14.5. Removed routes#
The server answers status 404 for these routes of the previous server.
Previous route |
Replacement |
|---|---|
|
|
|
|
|
|
|
None. |
|
The keys |
|
None. The server is not a remote storage for Prometheus. |
The server also has no dashboard. The address of the previous dashboard answers status 404.