basecamp/upright
关于
使用 Playwright 和 Prometheus 指标的合成监控引擎。
系统与基础设施可以做什么
- Playwright Probes - Browser-based probes for user flows with video recording and logs
- HTTP Probes - Simple HTTP health checks with configurable expected status codes
- SMTP Probes - EHLO handshake verification for mail servers
- MCP Probes - Sign-in discovery checks for remote MCP servers
实测星标增长
- 24小时
- +1
- 7天
- +3
- 15天
- +5
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Upright
Upright is a self-hosted synthetic monitoring system. It provides a framework for running health check probes from multiple geographic sites and reporting metrics via Prometheus. Alerts can then be configured with AlertManager.
![]() |
![]() |
| Site overview with world map | 30-day uptime history |
![]() |
|
| Probe status across all sites |
Features
- Playwright Probes - Browser-based probes for user flows with video recording and logs
- HTTP Probes - Simple HTTP health checks with configurable expected status codes
- SMTP Probes - EHLO handshake verification for mail servers
- MCP Probes - Sign-in discovery checks for remote MCP servers
- Traceroute Probes - Network path analysis with hop-by-hop latency tracking
- Multi-Site Support - Run probes from multiple geographic locations with staggered scheduling
- Observability - OTLP compatible, Prometheus metrics, OpenTelemetry tracing, and AlertManager support
- Configurable Authentication - OmniAuth integration with support for any OIDC provider
Not Included
- Notifications - Instead, Alertmanager is included for alerting and notifications
- Hosting - Instead, you can use a VPS from DigitalOcean, Hetzner, etc.
Components
- Rails engine
- SQLite
- Solid Queue for background and recurring jobs
- Mission Control - Jobs to monitor Solid Queue and manually enqueue probes
- Kamal for deployments
- Prometheus metrics for uptime queries and alerting
- AlertManager for notifications
- Open Telemetry Collector - logs, metrics and traces can be shipped to any OTLP compatible endpoint
Installation
[!NOTE] Upright is designed to be run in its own Rails app and deployed with Kamal.
Quick Start (New Project)
Create a new Rails application and install Upright:
rails new my-upright --database=sqlite3 --skip-test
cd my-upright
bundle add upright
bin/rails generate upright:install
bin/rails db:prepare
Start the server:
bin/dev
Visit http://app.my-upright.localhost:3000 to see your Upright instance.
Note: Upright uses subdomain-based routing. The
appsubdomain is the admin interface, while site-specific subdomains (e.g.,nyc,lon) show probe results for each location. The.localhostTLD resolves to 127.0.0.1 on most systems.
What the Generator Creates
The upright:install generator creates:
config/database.yml- Development and test split intoprimary(probe results),persistent(rollups and incidents, migrated from the gem) andqueue(Solid Queue) databasesconfig/recurring.yml- Probe schedules and the engine's housekeeping, health, rollup, incident and maintenance jobsconfig/initializers/upright.rb- Engine configurationconfig/initializers/content_security_policy.rb- Ready-to-enable CSP covering the engine's CDN dependenciesconfig/sites.yml- Site definitions for each VPS you host Upright onconfig/prometheus/prometheus.yml- Prometheus configurationconfig/alertmanager/alertmanager.yml- AlertManager configurationconfig/otel_collector.yml- OpenTelemetry Collector configurationconfig/deploy.ymlandDockerfile- Kamal deployment, with Prometheus and Alertmanager pinned by image digest.kamal/secretsentries and.kamal/hooks/pre-deploy- The machine tokens and admin password as Kamal secrets, and a hook that refuses to deploy while a token is missing (see Machine tokens)probes/- Directory for all HTTP, SMTP, Traceroute YAML config as well as Playwright probe classes
It also mounts the engine at / in your routes.
Configuration
Basic Setup
See config/initializers/upright.rb
Hostname Configuration
Upright uses subdomain-based routing. Configure your production hostname:
# config/initializers/upright.rb
Upright.configure do |config|
config.hostname = "upright.com"
end
For local development, the hostname defaults to {service_name}.localhost (e.g., upright.localhost).
Site Configuration
Define your monitoring locations in config/sites.yml:
shared:
sites:
- code: nyc
city: New York City
country: US
geohash: dr5reg
provider: digitalocean
- code: ams
city: Amsterdam
country: NL
geohash: u17982
provider: digitalocean
stores_metrics: true
primary: true
- code: sfo
city: San Francisco
country: US
geohash: 9q8yy
provider: hetzner
Each site node identifies itself via the SITE_SUBDOMAIN environment variable, configured in your Kamal deploy.yml.
Two optional flags give a site a role beyond running probes: primary serves the app and status hostnames and runs the jobs writing the shared database, and stores_metrics runs a local Prometheus and Alertmanager. See Sites and their roles for what each one changes, the health metrics every site exports, and how daily rollups read across them.
Machine tokens
Two bearer tokens authenticate machine callers on the /prometheus and /alertmanager proxies. Each does one job:
| Env var | Config | Who presents it | What it allows |
|---|---|---|---|
PROMETHEUS_OTLP_TOKEN |
config.otlp_token |
The OpenTelemetry collector on every site | POST /prometheus/api/v1/otlp/v1/metrics, and nothing else |
METRICS_READ_TOKEN |
config.metrics_read_token |
Peer sites computing rollups, and tooling | GET and HEAD on /prometheus and /alertmanager, except the /-/ lifecycle endpoints |
Generate each with bin/rails secret. Set them as Kamal secrets, the same two values on every site, and nowhere in git. Outside development and test the app refuses to boot when either is missing or when both hold the same value, and .kamal/hooks/pre-deploy refuses to deploy for the same reasons before any container is replaced.
export PROMETHEUS_OTLP_TOKEN=$(bin/rails secret)
export METRICS_READ_TOKEN=$(bin/rails secret)
bin/kamal deploy
A token cannot reach any other route. The admin UI uses a session cookie instead.
Authentication
Static Credentials
Upright uses static credentials by default with username admin and the password taken from the ADMIN_PASSWORD environment variable.
[!IMPORTANT] There is no default password:
ADMIN_PASSWORDmust be set, and sign-in fails closed without it. Set it as a Kamal secret in production (the generatedconfig/deploy.ymlalready lists it) and export it locally for development.
OpenID Connect
For production environments, Upright supports OpenID Connect (Logto, Keycloak, Duo, Okta, etc.):
# config/initializers/upright.rb
Upright.configure do |config|
config.auth_provider = :openid_connect
config.auth_options = {
issuer: "https://your-tenant.logto.app/oidc",
client_id: ENV["OIDC_CLIENT_ID"],
client_secret: ENV["OIDC_CLIENT_SECRET"]
}
end
Probe Result Cleanup
Upright automatically cleans up old probe results on a recurring schedule. You can configure the retention thresholds:
Upright.configure do |config|
config.stale_success_threshold = 24.hours # Delete successful results older than this (default: 24 hours)
config.stale_failure_threshold = 30.days # Delete failed results older than this (default: 30 days)
config.failure_retention_limit = 20_000 # Keep at most this many failed results (default: 20,000)
end
Custom Probe Types
Upright ships with five built-in probe types: HTTP, MCP, Playwright, SMTP, and Traceroute. You can register your own to extend the system.
1. Register the type
Add it to your initializer so Upright knows about its name and icon:
# config/initializers/upright.rb
Upright.configure do |config|
config.probe_types.register :ping, name: "Ping", icon: "📶"
end
2. Create the probe class
Add a Ruby class in your probes/ directory that extends FrozenRecord::Base and includes Upright::Probeable and Upright::ProbeYamlSource. Implement probe_type, probe_target, check, and on_check_recorded:
# probes/ping_probe.rb
class PingProbe < FrozenRecord::Base
include Upright::Probeable
include Upright::ProbeYamlSource
stagger_by_site 3.seconds
# Hostnames, IPv4, and IPv6 addresses only. The first character may not be
# a dash, so a configured host can never be mistaken for a ping flag.
HOST_PATTERN = /\A[a-z0-9:][a-z0-9:._-]*\z/i
def check
raise ArgumentError, "invalid ping host: #{host.inspect}" unless HOST_PATTERN.match?(host.to_s)
@ping_output, status = Open3.capture2e("ping", "-c", "1", "-W", "5", "--", host)
status.success?
end
def on_check_recorded(probe_result)
if @ping_output.present?
Upright::Artifact.new(name: "ping.log", content: @ping_output).attach_to(probe_result)
end
end
def probe_type = "ping"
def probe_target = host
end
The check method should return a truthy value on success and a falsy value on failure.
3. Define probes in YAML
Create a YAML file matching the class name (e.g., PingProbe → probes/ping_probes.yml):
# probes/ping_probes.yml
- name: "Cloudflare DNS"
host: "1.1.1.1"
- name: "Google DNS"
host: "8.8.8.8"
Fields defined in the YAML are available as methods on the probe instance (e.g., host).
4. Schedule it
Add a recurring job in config/recurring.yml:
production:
ping_probes:
command: "PingProbe.check_and_record_all_later"
schedule: every 30 seconds
The custom type will automatically appear in all dashboard dropdowns and filter links.
Defining Probes
HTTP Probes
Add probes to probes/http_probes.yml:
- name: Main Website
url: https://example.com
expected_status: 200
- name: API Health
url: https://api.example.com/health
expected_status: 200
alert_severity: critical
- name: Admin Panel
url: https://admin.example.com
basic_auth_credentials: admin_auth # Key in Rails credentials
The optional alert_severity field controls the Prometheus alert severity when a probe fails. Values: medium, high (default), critical.
MCP Probes
Add probes to probes/mcp_probes.yml:
- name: Example MCP Server
url: https://mcp.example.com/mcp
authorization_server: https://auth.example.com
alert_severity: critical
The probe checks the public side of a remote MCP server, in the order an MCP client uses before the user signs in:
- An unauthenticated
initializerequest tourlreturns 401 with aresource_metadataURL in theWWW-Authenticateheader. The URL must be https on the same host asurl. - The resource metadata names
urlas theresourceand listsauthorization_server. - The authorization server metadata has
authorization_endpoint,token_endpointandregistration_endpoint, and supports the S256 code challenge method.
An HTTP probe cannot check this, because MCP endpoints accept only POST and the resource metadata is often cached by a CDN. The probe does not authenticate, so it does not call tools/list. The failing step is written to an mcp.log artifact on the result.
Schedule it in config/recurring.yml:
production:
mcp_probes:
command: "Upright::Probes::MCPProbe.check_and_record_all_later"
schedule: every 30 seconds
SMTP Probes
Add probes to probes/smtp_probes.yml:
- name: Primary Mail Server
host: mail.example.com
- name: Backup Mail Server
host: mail2.example.com
Playwright Probes
Generate a new browser-based probe:
bin/rails generate upright:playwright_probe MyServiceAuth
This creates a probe class:
# probes/my_service_auth_probe.rb
class Probes::Playwright::MyServiceAuthProbe < Upright::Probes::Playwright::Base
# Optionally authenticate before running
# authenticate_with_form :my_service
def check
page.goto("https://app.example.com")
page.fill('[name="email"]', "[email protected]")
page.click('button[type="submit"]')
page.wait_for_selector(".dashboard")
end
end
See https://playwright-ruby-client.vercel.app/docs/api/page for how to create Playwright tests.
Creating Authenticators
For probes that require authentication, create an authenticator:
# probes/authenticators/my_service.rb
class Playwright::Authenticator::MyService < Upright::Playwright::Authenticator::Base
def signin_redirect_url = "https://app.example.com/dashboard"
def signin_path = "/login"
def service_name = :my_service
def authenticate
page.goto("https://app.example.com/login")
page.get_by_label("Email").fill(credentials.my_service.email)
page.get_by_label("Password").fill(credentials.my_service.password)
page.get_by_role("button", name: "Sign in").click
end
end
Scheduling
Configure probe scheduling with Solid Queue in config/recurring.yml:
production:
http_probes:
command: "Upright::Probes::HTTPProbe.check_and_record_all_later"
schedule: every 30 seconds
smtp_probes:
command: "Upright::Probes::SMTPProbe.check_and_record_all_later"
schedule: every 30 seconds
my_service_auth:
command: "Probes::Playwright::MyServiceAuthProbe.check_and_record_later"
schedule: every 15 minutes
System Requirements
Minimum VM Specifications
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 2 vCPU | 2 vCPU |
| RAM | 2 GB | 4 GB |
| Disk | 25 GB | 50 GB |
Playwright browser automation is memory-intensive. For sites running many Playwright probes concurrently, consider 4 GB RAM.
Software Requirements
- OS: Ubuntu 24.04+ or Debian 12+ (any Linux with Docker support)
- Docker: 24.0+ (installed automatically by Kamal)
- Ruby: 3.4+ (for local development only; production runs in Docker)
- Rails: 8.0+
Firewall Rules
Open the following ports:
| Port | Protocol | Direction | Purpose |
|---|---|---|---|
| 22 | TCP | Inbound | SSH access |
| 80 | TCP | Inbound | HTTP (redirects to HTTPS) |
| 443 | TCP | Inbound | HTTPS |
| 25 | TCP | Outbound | SMTP probes (if used) |
SMTP Port 25 Note
Most cloud providers block outbound port 25 by default to prevent spam. If you plan to use SMTP probes, you must request port 25 to be unblocked.
This is not required for HTTP or Playwright probes.
DNS Setup
For multiple geographic locations, use subdomains for each site. Each subdomain points to a different server:
; Primary dashboard
app.upright.example.com A 203.0.113.10
; Monitoring nodes
ams.upright.example.com A 203.0.113.10 ; Amsterdam
nyc.upright.example.com A 198.51.100.20 ; New York
sfo.upright.example.com A 192.0.2.30 ; San Francisco
Deployment with Kamal
Example config/deploy.yml
service: upright
image: your-org/upright
servers:
web:
hosts:
- ams.upright.example.com: [amsterdam]
- nyc.upright.example.com: [new_york]
- sfo.upright.example.com: [san_francisco]
jobs:
hosts:
- ams.upright.example.com: [amsterdam]
- nyc.upright.example.com: [new_york]
- sfo.upright.example.com: [san_francisco]
cmd: bin/jobs
proxy:
app_port: 3000
ssl: true
hosts:
- "*.upright.example.com"
env:
secret:
- RAILS_MASTER_KEY
- PROMETHEUS_OTLP_TOKEN
- METRICS_READ_TOKEN
- ADMIN_PASSWORD
tags:
amsterdam:
SITE_SUBDOMAIN: ams
new_york:
SITE_SUBDOMAIN: nyc
san_francisco:
SITE_SUBDOMAIN: sfo
accessories:
prometheus:
# Pinned by digest; CVE-2026-40179 (stored XSS in the web UI) affects 3.0 to 3.5.1
# and 3.6 to 3.11.1, fixed in 3.5.2 (LTS) and 3.11.2
image: prom/prometheus:v3.5.5@sha256:332c2f43e7e389d74d3893b55bb02fbbd684208e681eeb604641d5d769c0fe2a
hosts:
- ams.upright.example.com
cmd: >-
--config.file=/etc/prometheus/prometheus.yml
--storage.tsdb.path=/prometheus
--storage.tsdb.retention.time=30d
--web.enable-otlp-receiver
files:
- config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- config/prometheus/rules/upright.rules.yml:/etc/prometheus/rules/upright.rules.yml
alertmanager:
image: prom/alertmanager:v0.28.1@sha256:27c475db5fb156cab31d5c18a4251ac7ed567746a2483ff264516437a39b15ba
hosts:
- ams.upright.example.com
cmd: --config.file=/etc/alertmanager/alertmanager.yml
files:
- config/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
Secrets
config/deploy.yml reads RAILS_MASTER_KEY, PROMETHEUS_OTLP_TOKEN, METRICS_READ_TOKEN and ADMIN_PASSWORD from .kamal/secrets, which the generator points at environment variables of the same names. Kamal passes an empty value through when a variable is unset, so .kamal/hooks/pre-deploy checks the resolved secrets Kamal hands it and stops the deploy when either token is empty or both are the same. The app applies the same checks at boot. See Machine tokens.
Observability
Prometheus
Metrics are exposed via a Puma plugin at http://0.0.0.0:9394/metrics. Configure Prometheus to scrape:
scrape_configs:
- job_name: upright
static_configs:
- targets: ['localhost:9394']
Metrics Exposed
upright_probe_duration_seconds- Probe execution durationupright_probe_up- Probe status (1 = up, 0 = down)upright_http_response_status- HTTP response status code
Labels include: type, name, site_code, site_city, site_country
AlertManager
Example alert rules (prometheus/rules/upright.rules):
groups:
- name: upright
rules:
- alert: ProbeDown
expr: upright_probe_up == 0
for: 5m
labels:
severity: "{{ $labels.alert_severity }}"
annotations:
summary: "Probe {{ $labels.name }} is down"
OpenTelemetry
Traces are automatically created for each probe execution. Configure your collector endpoint:
Upright.configure do |config|
config.otel_endpoint = "https://otel.example.com:4318"
end
Local Development
Setup
bin/setup
This installs dependencies, prepares the database, and starts the dev server.
Running Services
Start supporting Docker services (Prometheus, Alertmanager):
bin/services
Running the Server
bin/dev
Visit http://app.upright.localhost:3000 and sign in with:
- Username:
admin - Password: the value of the
ADMIN_PASSWORDenv var, e.g.ADMIN_PASSWORD=upright bin/dev(a throwaway value like this is fine for local testing only — never for a deployed site)
Testing Playwright Probes
Run probes with a visible browser window:
HEADLESS=false bin/rails console
Probes::Playwright::MyServiceAuthProbe.check
Upgrading Playwright
Upright gets Playwright from the venetian gem. Each venetian release pins playwright-ruby-client and includes the matching Playwright driver and Node.js, so Gemfile.lock sets the Playwright version and the gem and driver always match. Neither Node.js nor npm is needed to run probes. To upgrade:
- Run
bundle update venetian, or widen thevenetianconstraint inupright.gemspecfor a new minor version - Run
bundle exec playwright install chromiumto install the matching browser - Run
bin/rails testto verify compatibility
To run probes with a different Playwright driver, set config.playwright_cli_path or the PLAYWRIGHT_CLI_PATH environment variable.
Viewing Playwright Traces
Upright stores a Playwright trace as a probe result artifact and does not serve the Playwright Trace Viewer. The viewer renders a trace's tags and attributes as HTML in its own origin, so serving it from Upright's hostname would let a trace run script against an admin session.
A trace artifact links to config.trace_viewer_url, which defaults to
upstream's hosted viewer at https://trace.playwright.dev. That viewer runs
entirely in the browser, and being on its own registrable domain is what keeps a
trace's contents off Upright's origin.
Following the link hands that origin a URL it can read for 24 hours. Set
config.trace_viewer_url to a viewer you host to keep traces to yourself, or
assign nil to keep them download-only:
npx playwright show-trace trace.zip
A URL under config.hostname raises Upright::ConfigurationError, since that
would put the trace back on the admin origin.
That trace URL is served by Upright::TracesController, not Active Storage. The
viewer fetches it from its own origin, so the request arrives without the admin
session and needs Access-Control-Allow-Origin to be readable at all. The
controller sends that header for the configured viewer's origin and nothing
else, and takes a signed id in place of the session: scoped to a purpose,
expiring after 24 hours, and resolvable only to a blob attached to an
Upright::ProbeResult under a .zip filename. With no viewer configured the
route 404s, so it exists only where it's used.
Range requests are answered, which is how the viewer reads a ZIP's central directory without downloading the whole archive.
Running Tests
bin/rails test
License
The gem is available under the terms of the MIT License.
探索相关项目
加载中…


