Deploying Vigil
Vigil ships as one OCI image (Dockerfile): a Debian runner with the
release under /app, running as nobody under tini, started by
bin/server. CI builds and pushes it on every push to master
(.forgejo/workflows/image.yml). It needs Postgres (17; pg_trgm, which the migrations create) and
nothing else. The three Rust NIFs are built from source into the release,
and the runner image carries no extra system libraries for them.
Docker or Podman both work. With Podman, build with --format docker, or
the image’s HEALTHCHECK is dropped (OCI images have none):
podman build --format docker -t vigil . # or: docker build -t vigil .
docker run --rm -e DATABASE_URL=... -e SECRET_KEY_BASE=... vigil /app/bin/migrate
docker run -p 4000:4000 -v vigil-storage:/data/storage \
-e DATABASE_URL=... -e SECRET_KEY_BASE=... -e PHX_HOST=vigil.example.com vigil
Release commands
All under /app/bin/ in the image (rel/overlays/bin/):
| Command | What |
|---|---|
server |
Starts the app (sets PHX_SERVER=true). The image’s default command |
migrate |
Runs the migrations. Run it before a new version’s server starts |
invite [--email E] [--note T] [--days N] [--by E] |
Prints a registration invite link. The first account is made this way while registration is closed |
invite-link EMAIL |
Prints a fresh link for the newest active invite to EMAIL |
token EMAIL LABEL SCOPE[,SCOPE...] |
Makes an API token for an existing user (for sentry-cli and similar) and prints it once. mix vigil.token in development |
Scopes are org:read org:write org:admin org:integrations member:read member:write member:admin team:read team:write team:admin project:read project:write project:admin project:releases event:read event:write event:admin. In each organization a token is narrowed to the user’s role
there.
Health
The image’s HEALTHCHECK fetches GET /_health/ on 127.0.0.1:$PORT, with
Host: localhost so the HTTPS redirect leaves it alone. Point liveness
probes there: it answers ok without touching the database.
GET /api/0/internal/health/ is the readiness check, in Sentry’s shape
({"problems": [...], "healthy": {...}}): the database answers, Oban is
running, and the ingest buffer is under 50,000 waiting items. It answers
503, listing the problems, otherwise.
Metrics
Prometheus metrics come from PromEx (Vigil.PromEx) and are served on a
second listener, port 9568, at /metrics, with no token. That port is
separate from the site so a proxy or Ingress that forwards everything on
PORT doesn’t publish it; keep 9568 off the internet and point the scraper
at it (on Kubernetes, the prometheus.io/scrape, /path and /port: "9568"
pod annotations).
The names are PromEx’s with a shared phx_ prefix: phx_phoenix_http_*
(requests by route pattern), phx_beam_*, phx_ecto_*, phx_oban_*
(queue depth by state, job durations and failures) and
phx_application_*. Vigil’s own are phx_vigil_*:
| Metric | Labels | |
|---|---|---|
phx_vigil_ingest_requests_total |
endpoint, outcome |
Requests to the ingest edge: accepted, rate_limited, not_accepting, denied, too_large, invalid, method_not_allowed |
phx_vigil_ingest_items_accepted_total |
type |
Envelope items buffered |
phx_vigil_ingest_items_dropped_total |
source, category, reason |
Dropped at the edge, in processing, or by SDKs (client reports) |
phx_vigil_ingest_processing_duration_milliseconds |
type, result |
Histogram: one buffered item’s processing |
phx_vigil_ingest_buffer_items |
state |
Buffered items by state (polled) |
phx_vigil_ingest_buffer_oldest_pending_age_seconds |
Wait of the oldest pending item (polled) | |
phx_vigil_uptime_checks_total |
type, result, reason |
Uptime checks recorded |
phx_vigil_uptime_check_response_time_milliseconds |
type |
Histogram: measured response times |
phx_vigil_uptime_monitors |
state |
Uptime monitors up, down, pending, disabled (polled) |
phx_vigil_monitor_check_ins_total |
status |
Cron check-ins, missed and timed-out included |
phx_vigil_monitors |
health |
Cron monitors by health (polled) |
phx_vigil_monitor_incidents_open |
Unresolved cron incidents (polled) | |
phx_vigil_alert_deliveries_total |
type, result |
Alert delivery attempts: sent, retrying, failed |
phx_vigil_organizations_count, _projects_count, _users_count |
(polled) | |
phx_vigil_issues_count |
status |
(polled every 5 minutes) |
phx_vigil_rows_estimate |
table |
pg_class.reltuples over the partitions of issue_events, spans, log_events, uptime_checks, monitor_checkins (polled) |
Counters and histograms are per replica: sum them. The polled gauges ask
the database, so every replica reports the same number: aggregate them with
max, never sum.
The same text is also available at GET /metrics on the site’s own port,
for a scraper that can only reach that, but it is off unless one of the
variables below turns it on.
| Variable | Default | |
|---|---|---|
METRICS_PORT |
9568 |
The metrics listener’s port; off doesn’t start it |
METRICS_TOKEN |
unset | Serves /metrics on PORT to Authorization: Bearer <token> |
METRICS_PUBLIC |
false |
true serves /metrics on PORT to anyone (scrape over a private network only) |
Before PromEx, /metrics on PORT served vigil_* names from
telemetry_metrics_prometheus_core; those names are gone, replaced by the
ones above.
Environment
Required (prod)
| Variable | |
|---|---|
DATABASE_URL |
ecto://USER:PASS@HOST/DATABASE |
SECRET_KEY_BASE |
64+ random bytes: mix phx.gen.secret |
PHX_HOST |
The public hostname. URLs and DSNs are built as https://PHX_HOST. Default example.com, which is never right |
Web and database
| Variable | Default | |
|---|---|---|
PORT |
4000 |
HTTP listen port. TLS is terminated in front of Vigil |
POOL_SIZE |
10 |
Postgres connections per node |
ECTO_IPV6 |
off | true to reach Postgres over IPv6 |
REGISTRATION_OPEN |
false |
true lets anyone sign up; otherwise sign-up needs an invite |
VIGIL_ORG_GROUP_RULES |
unset | Org membership from identity-provider groups: org:group:role[:provider],... |
Storage
Uploaded files (source maps, artifact bundles) go to local disk unless
S3_BUCKET is set.
| Variable | Default | |
|---|---|---|
VIGIL_STORAGE_ROOT |
/data/storage in the image (storage/ otherwise) |
Local storage root. The image declares a volume there; with several replicas it must be shared (or use S3) |
S3_BUCKET |
unset | Switches storage to an S3-compatible bucket. The rest are then required, except S3_REGION |
S3_ENDPOINT |
e.g. https://s3.us-west-004.backblazeb2.com |
|
S3_REGION |
us-east-1 |
|
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY |
Login links, account emails and alert emails go one of three ways:
- mail-prism (prism.neiam.org), as the sibling apps send. Vigil pushes
its account templates (
priv/mail_prism/) there at boot. Alerts go as raw sends. - SMTP through a relay.
- The log: nothing is sent; the rendered mail is logged at
info.
MAIL_PROVIDER chooses. Unset, the choice is mail-prism if both
MAIL_PRISM_* are set, else SMTP if SMTP_RELAY is set, else the log.
| Variable | Default | |
|---|---|---|
MAIL_PROVIDER |
unset | mail_prism, smtp or log; a named provider missing its settings stops the boot |
MAIL_PRISM_URL |
unset | mail-prism’s base URL, e.g. http://mail-prism-svc.mail-prism in-cluster |
MAIL_PRISM_API_KEY |
unset | The application’s key. mail-prism only sends as that application’s address, so MAIL_FROM_ADDRESS must be it |
SMTP_RELAY |
unset | The relay’s hostname |
SMTP_PORT |
587 |
|
SMTP_USERNAME, SMTP_PASSWORD |
unset | |
SMTP_TLS |
if_available |
STARTTLS: always, if_available or never |
SMTP_SSL |
false |
true for implicit TLS (port 465) |
SMTP_AUTH |
if_available |
always, if_available or never |
SMTP_TLS_VERIFY |
verify_peer |
verify_none for a self-signed private relay |
SMTP_CACERTFILE |
/etc/ssl/certs/ca-certificates.crt |
Fallback CA bundle when the OS store can’t be loaded |
MAIL_FROM_ADDRESS |
noreply@PHX_HOST |
Sender of every email |
MAIL_FROM_NAME |
Vigil |
TLS is pinned to 1.2 and 1.3 and the peer is verified against the OS CA
store; see the comments in config/runtime.exs.
Clustering
Replicas work unclustered: ingest is stateless apart from a per-node key cache, which then lags a key, project or organization change by up to 30 seconds on the other nodes. Clustered, Phoenix PubSub spans the nodes, so such changes flush every node’s cache at once and live updates reach users wherever they are connected. Ingest rate limits are counted per node either way, so with N replicas a key can take up to N times its limit.
| Variable | Default | |
|---|---|---|
POD_IP |
unset | Turns on libcluster’s Kubernetes strategy, and names the node vigil@POD_IP (rel/env.sh.eex). Set it from the downward API (status.podIP) |
POD_NAMESPACE |
vigil |
Where to look for peers |
CLUSTER_SELECTOR |
name=vigil |
Label selector for the peer pods. The service account needs list on pods |
CLUSTER_SERVICE |
vigil-headless |
Headless Service name |
RELEASE_COOKIE |
generated at image build | Must be the same on every replica; set it from a Secret rather than rely on the baked-in one |
DNS_CLUSTER_QUERY |
unset | Alternative to libcluster: cluster by DNS (dns_cluster) |
With POD_IP set, the Erlang distribution listens on port 9100 only.
Self-reporting
Vigil can report its own errors and Oban cron jobs (as cron monitors) through sentry-elixir, to a project on itself or on another Vigil. Errors about the ingest path itself are dropped, so a broken ingest can’t report into a loop.
| Variable | Default | |
|---|---|---|
VIGIL_SELF_DSN |
unset | The project’s DSN. Unset: nothing is sent |
VIGIL_SELF_ENVIRONMENT |
production |
The environment those events carry |
Retention
Partitioned data is kept for set periods (config :vigil, Vigil.Partitions):
events 90 days, logs 30, spans 14, uptime checks 30, session counts 400.
Releases are kept 365 days after their last issue (config :vigil, Vigil.Retention, release_days:). An organization can keep less, under
Settings → General. A daily job (03:53 UTC) applies those limits. It also
removes stale issues, releases and orphaned artifact bundles, and, a day
after deletion, deleted projects and organizations with their files.
Sign in with NEIAM (OIDC)
Off unless OIDC_ENABLED=true. OIDC_LOGIN_MODE, PUBLIC_URL,
OIDC_PROVIDERS and the per-provider OIDC_* variables are neiam_auth’s;
see its README (deps/neiam_auth/README.md).
The Android app’s sign-in
| Variable | Default | |
|---|---|---|
ANDROID_CERT_FINGERPRINTS |
unset | SHA-256 fingerprints of the APK signing certificates, comma-separated, for /.well-known/assetlinks.json. Unset: emailed sign-in links open in the browser |
APP_LOGIN_REDIRECT_URI |
vigil://auth |
Where “Sign in with NEIAM” in the app hands its one-time code. Empty turns SSO in the app off |
APP_LOGIN_OIDC_PROVIDER |
the first provider | The provider the app’s SSO button uses |
See app-login.md.