18. Configuration reference

Every key emfor 0.8.0 accepts. Any other key is an error (<path>: unknown key). The options of each check are in chapter 6 (tcp, http, exec) and chapter 7 (emfor-check).

Value formats

TypeFormExamples
durationA string of number-and-unit terms; units ms, s, m, h (and spelled out, seconds, minutes…). "0" alone is allowed. A bare number is refused."500ms", "1.5s", "1h 30m"
percentageA string with %"10%"
sizeA string with B, KiB, MiB or GiB"64MiB"
modeAn octal string, at most 0777"0640"
address"IPv4:port" or "[IPv6]:port", port 1–65535, never a host name"10.0.0.11:8080", "[2001:db8::11]:8080"
site1–63 of a-z, 0-9, -, not starting or ending with -"dc1"
service nameLabels of a-z, 0-9, - (1–63 each), dots between, at most 253; case and a trailing dot are ignored"db.svc.emfor"

Top level

KeyTypeDefaultNotes
sitesitenoneThis host’s data centre. Required with [peers]; used by locality.
include_dirpathnoneA directory of *.toml files merged in name order; relative to the main file. Main file only. Must come before the first table.

[store]

Main file only. No key can be changed by a reload.

KeyTypeDefaultNotes
pathpath/var/lib/emfor/state.mdbClients read EMFOR_STORE, so keep the two equal. The directory must exist.
map_sizesize"64MiB"At least 1MiB, rounded up to 64 KiB. How big to make it: chapter 12.
file_modemode"0640"Set on the store at every start.
lock_file_modemode"0660"Set on <path>-lock at every start. A mode others can write gives a warning.
syncbooleanfalsetrue flushes every commit to disk before it completes.

[log]

KeyTypeDefaultNotes
level"trace", "debug", "info", "warn", "error""info"RUST_LOG overrides it.
format"text", "json""text""json" writes one JSON object per line (chapter 12). Restart to change; a reload that changes it is rejected.

[dns]

The DNS server runs only when this table exists.

KeyTypeDefaultNotes
listenarray of addresses["127.0.0.1:5300"]Not empty, no duplicates. Restart to change.
zonename"svc.emfor"At most 242 characters.
ttlduration, whole seconds"1s"0–3600.
rate_limitinteger100UDP answers per second per /24 or /56; 0–1,000,000; 0 is off.

[metrics]

The metrics server runs only when this table exists.

KeyTypeDefaultNotes
listenarray of addresses["127.0.0.1:5301"]Restart to change.

[peers]

KeyTypeDefaultNotes
listenaddress (a string)requiredNot 0.0.0.0 or ::; one of members. Restart to change.
membersarray of addressesrequired2–64, no duplicates, one address family.
secret_fileabsolute pathrequiredOwner root or the daemon’s user; not readable by others; not writable by group or others; 32 bytes to 64 KiB.
previous_secret_fileabsolute pathnoneSame rules. Read at start only.
encryptbooleantrue
accept_plaintextbooleanfalse if encrypt, else truefalse with encrypt = false is an error.
cipherstring"chacha20-poly1305""chacha20-poly1305" or "aes-256-gcm"; the latter needs encrypt = true. See chapter 11.

[defaults]

Settings for every service; a service overrides each one.

KeyTypeDefaultRule
intervalduration"2s"100 ms to 24 h.
timeoutduration"1s"At least 10 ms, at most interval.
riseinteger2At least 1.
fallinteger3At least 1.
jitterpercentage"10%"0–50%.
on_all_down"open", "closed""open"
balance"round-robin", "sticky", "failover", "weighted", "locality", "fastest""round-robin"
peersbooleantruefalse keeps services out of the peer group on this host.
slow_startduration"0s"0s or 1 s to 1 h.

[plugins.“NAME”]

NAME is 1–63 of a-z, 0-9, _, -, not tcp, http or exec.

KeyTypeDefaultNotes
commandarray of stringsrequiredThe first element is an absolute path to an executable.
env_passarray of variable names[]Not EMFOR_IP, EMFOR_PORT, EMFOR_SERVICE. Changing it restarts the plugin.

[services.“NAME”]

KeyTypeDefaultNotes
check"tcp", "http", "exec" or a plugin namerequired
backendsarray of addresses or backend tablesrequiredAt least one; no duplicates; at least one not a backup.
check_optionstable{}Depends on check.
dns_ttlduration, whole seconds[dns] ttl0–3600. Not allowed in [defaults].
every key of [defaults]from [defaults]

A backend table:

KeyTypeDefaultNotes
addraddressrequired
weightinteger11–100. Used by weighted (also its slow start) and by sticky with a key; other methods ignore it.
sitesitenoneUsed by locality.
backupbooleanfalseUsed only while no primary passes.
drainbooleanfalseNever chosen; checks go on. A reload, no state reset.

Reloading

[store], the listen keys of [dns], [metrics] and [peers], and adding or removing those tables need a restart; everything else is applied by a reload. What each change does to the backends’ states is in chapter 5.

A complete example

site = "dc1"

[store]
path = "/var/lib/emfor/state.mdb"
map_size = "64MiB"

[log]
level = "info"

[dns]
listen = ["127.0.0.1:5300"]
zone = "svc.emfor"
ttl = "1s"

[metrics]
listen = ["127.0.0.1:5301"]

[defaults]
interval = "2s"
timeout = "1s"
rise = 2
fall = 3
jitter = "10%"

[plugins."pgsql"]
command = ["/usr/bin/emfor-check", "pgsql"]

[services."api.svc.emfor"]
check = "http"
balance = "locality"
slow_start = "30s"
backends = [
  { addr = "10.1.0.11:8080", site = "dc1" },
  { addr = "10.1.0.12:8080", site = "dc1", weight = 2 },
  { addr = "10.2.0.11:8080", site = "dc2", backup = true },
]
check_options = { path = "/healthz", expect_status = ["200"] }

[services."db.svc.emfor"]
check = "pgsql"
balance = "failover"
on_all_down = "closed"
dns_ttl = "0s"
backends = ["10.1.3.1:5432", "10.1.3.2:5432"]
check_options = { user = "emfor", database = "postgres", role = "primary", password_file = "/etc/emfor/secrets/pg.pass" }

[services."ssh.svc.emfor"]
check = "tcp"
interval = "10s"
backends = ["10.1.0.11:22", "10.1.0.12:22"]
check_options = { expect = "SSH-" }

The commented example config of the repository, examples/emfor.toml, lists every key too.

Built with Hugo
Theme Stack designed by Jimmy