Skip to content

Configuration reference

Flagnetic is configured with environment variables and, optionally, a YAML file named by FLAGNETIC_CONFIG_FILE. Each setting is read from its environment variable when that is set, even to the empty string; otherwise from the file; otherwise it takes its default. An empty value means the default, except where a setting says it switches something off.

The file is a mapping from the keys in the File key column to single values:

database_url: postgres://flagnetic@db:5432/flagnetic?sslmode=require
listen_addr: ":8080"
log_format: text

A value that is not a single value, a value that does not parse or lies outside the range shown, a key that is not written like a setting name and the key of a setting that only the environment sets are refused when the replica starts, with exit code 2 and a message naming the setting. A well-formed key that is not listed here is ignored with a warning in the log, and so is an environment variable that starts with FLAGNETIC_ but is no setting and no variable of the command line: a binary rolled back to an earlier version still starts with the file or the environment written for a newer one, and a mistyped setting is noticed.

Durations are written as a number and a unit: 500ms, 15s, 2m.

Variable File key Default Description
DATABASE_URL database_url required PostgreSQL connection string, as a URL or as keyword/value pairs. PostgreSQL 16 or newer. What it leaves out is taken from the standard PostgreSQL variables, such as PGPASSWORD, so the password need not be in it. Example: postgres://flagnetic@db:5432/flagnetic?sslmode=require.
FLAGNETIC_SECRET_KEY secret_key required by serve The instance’s secret key: stored secrets are sealed under it, sessions are signed with it. Keep it for the life of the instance: on its first start the instance stores a canary sealed under the key, and serve refuses to start under a key that does not open it. At least 32 bytes: use a long random value, such as the output of openssl rand -base64 32. Example: q3S0k1p2Rk7Jt0E5m9xV8bYcN4wZ6hL2aU1dG7fH0eI=.
FLAGNETIC_BASE_URL base_url — The public URL the console is reached at, such as the address of the reverse proxy in front. Its scheme decides whether the session cookie is Secure, and its origin is trusted for requests signed in through the console even when the proxy rewrites Host. Invitation links start with it. When unset, the scheme and origin of each request are used. Auth providers need it: a provider’s redirect URI, which the identity provider is told, is built from it, so creating, editing or enabling one is refused with base_url_required while it is unset, and so is configuring an SMTP server, since every mailed link is built from it. Example: https://flags.example.com.
FLAGNETIC_INSECURE_COOKIES insecure_cookies false Send the session cookie without Secure over plain HTTP on a host other than localhost, for a trial without TLS. On localhost the cookie works over plain HTTP without it. Never set it where the console is reached over a network you do not trust. Example: true.
FLAGNETIC_PASSWORD_HASH_CONCURRENCY password_hash_concurrency 4 How many passwords one replica hashes or verifies at once. Each takes 64 MiB of memory for about a tenth of a second, so the bound keeps a burst of sign-ins from exhausting the replica. A sign-in that waits more than 2 seconds for a slot is answered 503 busy with Retry-After. Range: 1 to 64. Example: 8.
FLAGNETIC_DEFAULT_LOCALE default_locale en The console’s language when the member has not chosen one and the browser asks for none the console offers: en (English) or ru (Russian). Example: ru.
FLAGNETIC_TEST_CLOCK_FILE — — Test only: a file holding a duration, such as 25h, that moves the server’s clock ahead, read again on every use. Accepted only by the end-to-end test harness, listening on loopback; refused anywhere else. Environment only. Example: /tmp/flagnetic-clock-offset.
FLAGNETIC_CONFIG_FILE — — YAML file of settings, keyed by the names in the File key column. Environment only. Example: /etc/flagnetic/flagnetic.yaml.
FLAGNETIC_LISTEN_ADDR listen_addr :8080 Address of the public listener: the APIs, the console, /healthz and /readyz. Example: :8080.
FLAGNETIC_METRICS_LISTEN_ADDR metrics_listen_addr 127.0.0.1:9090 Address of the metrics listener, which serves Prometheus metrics on /metrics and nothing else. It listens on this host only by default; set an address on another interface for a scraper elsewhere, and keep it off the internet. Set it empty to switch metrics off and open no port. Example: 10.0.0.5:9090.
FLAGNETIC_AUTO_MIGRATE auto_migrate true Whether serve applies pending migrations on start. Set it to false when migrations run as a job (flagnetic migrate). Example: false.
FLAGNETIC_DB_MAX_CONNS db_max_conns 10 Size of the PostgreSQL connection pool of one replica. When unset, pool_max_conns in DATABASE_URL applies if present; when both are set, this wins and a notice is logged. Unit: connections. Range: 1 to 10000. Example: 25.
FLAGNETIC_SHUTDOWN_DRAIN shutdown_drain 5s How long a replica told to stop keeps serving while /readyz answers 503, so load balancers route away from it before it stops accepting requests. 0 skips the drain. Unit: duration. Range: 0s to 1h. Example: 5s.
FLAGNETIC_SHUTDOWN_GRACE shutdown_grace 15s How long in-flight requests may run once the drain is over and the replica stops accepting new ones; then they are cancelled. Unit: duration. Range: 0s to 1h. Example: 15s.
FLAGNETIC_LOG_LEVEL log_level info Lowest level logged: debug, info, warn or error. Example: debug.
FLAGNETIC_LOG_FORMAT log_format json Format of the log written to standard error: json, one object per line, or text. Example: text.
FLAGNETIC_TRUSTED_PROXIES trusted_proxies — Comma-separated CIDR prefixes or single addresses of the reverse proxies in front of the server. Their X-Forwarded-For and X-Forwarded-Proto headers are believed, so the client’s address and scheme are the real client’s; from any other peer the headers are ignored, so a client cannot choose the address it is seen with. Example: 10.0.0.0/8,192.168.1.10.
FLAGNETIC_HTTP_READ_HEADER_TIMEOUT http_read_header_timeout 10s How long a client may take to send a request’s headers on the public listener. Unit: duration. Range: 100ms to 24h. Example: 10s.
FLAGNETIC_HTTP_IDLE_TIMEOUT http_idle_timeout 120s How long a keep-alive connection may stay idle before the server closes it. Unit: duration. Range: 100ms to 24h. Example: 120s.
FLAGNETIC_HTTP_BODY_READ_TIMEOUT http_body_read_timeout 30s How long a client may take to send a request’s body; a body still arriving then is answered 408. Long-lived streams are excepted. Unit: duration. Range: 100ms to 24h. Example: 30s.
FLAGNETIC_HTTP_WRITE_TIMEOUT http_write_timeout 30s How long a client may take to accept what the server writes to it: each chunk of a response, or each frame of a stream, must be taken within it, or the server drops the connection. It bounds a stalled reader, not the length of a response or a stream. Unit: duration. Range: 100ms to 24h. Example: 30s.
FLAGNETIC_HTTP_MAX_BODY_BYTES http_max_body_bytes 1048576 Largest request body accepted, unless a route declares a larger limit of its own; a larger body is answered 413. Unit: bytes. Range: 1 to 1073741824. Example: 1048576.
FLAGNETIC_EVENTS_RETENTION_DAYS events_retention_days 30 The window of the raw events SDKs post. An event whose time is older, after the batch’s clock-skew shift, is rejected out_of_window. Raw events are kept as long: each day is dropped once it is wholly older. An event ID is recognised as a retry and the event stored once for a year, or the window plus a day when that is longer, so it outlives the raw events. Unit: days. Range: 1 to 3650. Example: 30.
FLAGNETIC_EVENTS_LOSS_WARNING_HOURS events_loss_warning_hours 72 How many hours before retention drops a raw event a sink that has not delivered it is flagged at risk: the sink’s at_risk is set and sink.at_risk is told once, for disabled and stopped sinks too. A sink that falls behind by less than the retention window minus this loses nothing. A value of the retention window or more flags every sink with an undelivered event. Unit: hours. Range: 1 to 87600. Example: 72.
FLAGNETIC_EVENTS_PARTITIONS_AHEAD events_partitions_ahead 3 How many days after today the raw event tables’ daily partitions are created ahead of time, so that events received after midnight never wait for one. Unit: days. Range: 1 to 31. Example: 3.
FLAGNETIC_SDK_INVENTORY_RETENTION_DAYS sdk_inventory_retention_days 90 How long an environment’s SDK inventory keeps an SDK after it was last seen. An SDK seen again afterwards appears again, with a new first-seen time. Unit: days. Range: 1 to 3650. Example: 90.
FLAGNETIC_ALIAS_LINKS_LIMIT alias_links_limit 5000000 The most alias links an environment keeps. Links are kept as long as the environment exists, so the limit is what stops a client key from growing them without end. Once an environment holds this many, an alias linking a new pair is refused quota_exceeded, while one for a pair already linked is still accepted. The count is exact for batches one after another and may be exceeded by the batches in flight at the moment the limit is reached. Unit: links. Range: 1 to 1000000000. Example: 5000000.
FLAGNETIC_FIRST_EXPOSURES_LIMIT first_exposures_limit 10000000 The most units whose first exposure an experiment keeps in an environment. Once the rollup has counted this many, an exposure of another unit is refused quota_exceeded, while one of a unit already counted is still accepted. Exposures received before the rollup has counted them are not refused, so the limit is approximate by the rollup’s lag. Unit: units. Range: 1 to 1000000000. Example: 10000000.
FLAGNETIC_WEBHOOK_ALLOW_HTTP webhook_allow_http false Accept webhook subscriptions and webhook sinks whose target is plain http, which sends events and their signatures unencrypted. Without it such a target is refused insecure_url. Meant for a receiver on the same host or a trusted network. Example: true.
FLAGNETIC_WEBHOOK_ALLOW_PRIVATE_NETWORKS webhook_allow_private_networks false Accept webhook targets that resolve to anything but a global unicast address: loopback, private, link-local, carrier-grade NAT (100.64.0.0/10), benchmarking, reserved, documentation and other special-purpose ranges, and NAT64 or 6to4 addresses that embed one. Without it such a target is refused private_network_target when a subscription or a webhook sink is written, so that whoever manages webhooks or sinks cannot reach the network the instance runs in. ClickHouse and object storage sinks may reach private networks regardless, and never a link-local address, EC2’s IPv6 metadata address fd00:ec2::254, or a NAT64 or 6to4 address embedding a link-local one. Example: true.
FLAGNETIC_WEBHOOK_TICK webhook_tick 5s How often a replica turns new events into webhook deliveries and sends the deliveries that are due. An event reaches a receiver about this long after its change at the earliest. Unit: duration. Range: 100ms to 1h. Example: 5s.
FLAGNETIC_SINK_TICK sink_tick 1s How often a replica looks for sink streams that are due and delivers their next batch. A stream still waits its sink’s flush_interval between batches once it has caught up, and goes on at once while batches are full. Unit: duration. Range: 100ms to 1h. Example: 1s.
FLAGNETIC_SINK_LAG_WARNING sink_lag_warning 15m How old the oldest event a sink has not delivered may be before the sink’s health is lagging. A long transaction anywhere in the database holds every sink back, and shows as lag. Unit: duration. Range: 1s to 720h. Example: 15m.
FLAGNETIC_SINK_REJECTION_ATTEMPTS sink_rejection_attempts 5 How many times a sink’s target must reject one batch before the sink sets it aside as a dead letter and goes on with the next. Only a rejection counts: a target that is down or busy is retried without limit, with a growing wait, and the batch keeps its place. Unit: attempts. Range: 1 to 1000. Example: 3.
FLAGNETIC_SINK_STOP_AFTER_DEAD_LETTERS sink_stop_after_dead_letters 3 How many dead letters in a row on one stream stop its sink, so that a target that keeps refusing is not fed the rest of the event store. A batch the target acknowledges ends the run. A stopped sink delivers nothing until a member resumes it. Unit: dead letters. Range: 1 to 1000. Example: 5.
FLAGNETIC_WEBHOOK_SECRET_OVERLAP webhook_secret_overlap 24h How long the secret a rotation replaced, a webhook subscription’s or a webhook sink’s, keeps signing beside the new one, so a receiver can take the new secret without refusing a single event. Unit: duration. Range: 1s to 8760h. Example: 24h.
FLAGNETIC_SCHEDULE_MIN_LEAD schedule_min_lead 60s How far ahead a change request’s apply time must be at least when it is set; a sooner time is refused invalid_change_request. Unit: duration. Range: 1s to 720h. Example: 5m.
FLAGNETIC_SCHEDULE_TICK schedule_tick 10s How often every replica looks for approved change requests whose apply time has come and applies them; a change request is applied at most this long after its time, or later when no replica was running. Unit: duration. Range: 100ms to 1h. Example: 10s.
FLAGNETIC_SCHEDULE_MAX_FAILURES schedule_max_failures 5 How many scheduled applications of a change request may fail in a row before the scheduler stops trying it and records change_request.schedule_failed. Unit: attempts. Range: 1 to 1000. Example: 5.
FLAGNETIC_AUDIT_EXPORT_MAX_ENTRIES audit_export_max_entries 100000 The most entries one download of the audit log may hold. A download whose filters match more is refused export_too_large before anything is sent; narrowing it by time brings it under. Unit: entries. Range: 1 to 100000000. Example: 100000.
FLAGNETIC_AUDIT_EXPORT_MAX_CONCURRENT audit_export_max_concurrent 4 How many downloads of the audit log one replica serves at once. A download asked while every slot is taken is refused too_many_exports (429) with Retry-After. Unit: downloads. Range: 1 to 1000. Example: 4.
FLAGNETIC_DIGEST_WEEKDAY digest_weekday monday The weekday, in UTC, on which the stale-flag digest (report.stale_flags) is sent to each project’s webhook subscribers, in English, in any case. A digest not sent within the hour of its slot because no replica was running is skipped, not sent late. Unit: weekday. Example: friday.
FLAGNETIC_DIGEST_HOUR digest_hour 8 The hour of the day, in UTC, at which the stale-flag digest is sent on its weekday; it is sent at the first minute of that hour that a replica runs. Unit: hour, 0 to 23. Example: 14.
FLAGNETIC_RATE_LIMIT_CLIENT_EVALUATE rate_limit_client_evaluate 120 Remote evaluations a client key may ask of one replica per minute, counted per key and client IP, an IPv6 client by its /64. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 120.
FLAGNETIC_RATE_LIMIT_CLIENT_EVENTS rate_limit_client_events 60 Event batches a client key may post to one replica per minute, counted per key and client IP, an IPv6 client by its /64. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 60.
FLAGNETIC_RATE_LIMIT_CLIENT_STREAM_CONNECTS rate_limit_client_stream_connects 30 Ruleset streams a client key may open on one replica per minute, counted per key and client IP, an IPv6 client by its /64. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 30.
FLAGNETIC_RATE_LIMIT_CLIENT_CONCURRENT_STREAMS rate_limit_client_concurrent_streams 10 Ruleset streams a client key may hold open on one replica at once, counted per key and client IP, an IPv6 client by its /64. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: streams. Range: 1 to 10000000. Example: 10.
FLAGNETIC_RATE_LIMIT_CLIENT_STREAMS_PER_REPLICA rate_limit_client_streams_per_replica 10000 Ruleset streams all client keys together may hold open on one replica at once, whatever their keys and client IPs, which bounds the connections a public client key can hold the replica to. One client key may hold a quarter of them (at least one), and a stream beyond its share is refused with that share as RateLimit-Limit. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: streams. Range: 1 to 10000000. Example: 10000.
FLAGNETIC_RATE_LIMIT_SERVER_RULESET rate_limit_server_ruleset 600 Ruleset downloads a server key may ask of one replica per minute, counted per key. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 600.
FLAGNETIC_RATE_LIMIT_SERVER_EVALUATE rate_limit_server_evaluate 6000 Remote evaluations a server key may ask of one replica per minute, counted per key. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 6000.
FLAGNETIC_RATE_LIMIT_SERVER_EVENTS rate_limit_server_events 600 Event batches a server key may post to one replica per minute, counted per key. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: requests per minute. Range: 1 to 10000000. Example: 600.
FLAGNETIC_RATE_LIMIT_SERVER_CONCURRENT_STREAMS rate_limit_server_concurrent_streams 1000 Ruleset streams a server key may hold open on one replica at once, counted per key. A server key’s stream connects are not limited per minute. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: streams. Range: 1 to 10000000. Example: 1000.
FLAGNETIC_RATE_LIMIT_FAILED_AUTHENTICATIONS rate_limit_failed_authentications 30 SDK API requests from one client IP (an IPv6 client by its /64) whose key is malformed or unknown that one replica takes per minute. Past it, an SDK API request from that IP or /64 is answered 429 before its key is looked up, which keeps guessing keys slow, unless the replica already holds its key from an earlier lookup, so the valid keys in use behind a shared address keep working. A revoked or expired key, and a request without a key, are not counted. Each replica counts on its own, so an instance of n replicas lets up to n times as much through. A refused request is answered 429 rate_limited with Retry-After. off switches the limit off. Unit: refusals per minute. Range: 1 to 10000000. Example: 30.

Variables of the command line

The table above is the settings of a replica. The commands read these variables too, never serve; they are environment only. The command line’s own flags are listed by each command’s -h.

Variable Description
FLAGNETIC_ADMIN_PASSWORD The password of the instance admin that flagnetic admin bootstrap and flagnetic admin create create. When unset, a password is generated and printed once.
FLAGNETIC_URL The instance that flagnetic export, import and import-firebase talk to, when --url is not given.
FLAGNETIC_TOKEN The access token those commands present, when neither --token nor --token-file is given.
FLAGNETIC_TEST_HARNESS Test only: the marker, set to playwright by the end-to-end harness, under which FLAGNETIC_TEST_CLOCK_FILE is accepted.

See The first instance admin for the admin password.