### Install and Initialize Upright Rails Application Source: https://github.com/basecamp/upright/blob/main/README.md Commands to create a new Rails application, add the Upright gem, run the installation generator, and perform database migrations. ```bash rails new my-upright --database=sqlite3 --skip-test cd my-upright bundle add upright bin/rails generate upright:install bin/rails db:migrate bin/dev ``` -------------------------------- ### Example PromQL Query for Probe Status Source: https://context7.com/basecamp/upright/llms.txt Shows an example PromQL query to retrieve the current status of HTTP probes named 'Main Website'. This query uses the `upright_probe_up` metric and filters by probe type and name. ```promql # Example PromQL queries # Get current probe status upright_probe_up{type="http", name="Main Website"} ``` -------------------------------- ### Define Playwright Probe Logic Source: https://context7.com/basecamp/upright/llms.txt Provides an example of a Playwright probe class that extends Upright::Probes::Playwright::Base. It demonstrates how to perform browser actions like navigating, filling forms, clicking, and waiting for elements, as well as asserting expected outcomes. ```ruby # probes/my_service_auth_probe.rb class Probes::Playwright::MyServiceAuthProbe < Upright::Probes::Playwright::Base # Optional: use form-based authentication authenticate_with_form :my_service def check page.goto("https://app.example.com") page.fill('[name="email"]', "test@example.com") page.fill('[name="password"]', "secret") page.click('button[type="submit"]') page.wait_for_selector(".dashboard") # Verify expected content expect_text = page.text_content(".welcome-message") raise "Login failed" unless expect_text.include?("Welcome") end end ``` -------------------------------- ### Configure Recurring Probe Scheduling Source: https://context7.com/basecamp/upright/llms.txt Details how to configure recurring probe executions using Solid Queue by defining schedules and commands in `config/recurring.yml`. Examples are provided for HTTP, SMTP, traceroute, Playwright probes, and cleanup tasks across different environments. ```yaml # config/recurring.yml development: http_probes: schedule: every minute command: "Upright::Probes::HTTPProbe.check_and_record_all_later" smtp_probes: schedule: every minute command: "Upright::Probes::SMTPProbe.check_and_record_all_later" production: http_probes: schedule: "*/30 * * * * *" # Every 30 seconds command: "Upright::Probes::HTTPProbe.check_and_record_all_later" smtp_probes: schedule: "*/30 * * * * *" command: "Upright::Probes::SMTPProbe.check_and_record_all_later" traceroute_probes: schedule: every 5 minutes command: "Upright::Probes::TracerouteProbe.check_and_record_all_later" my_service_auth: schedule: every 15 minutes command: "Probes::Playwright::MyServiceAuthProbe.check_and_record_later" cleanup_stale_probe_results: command: "Upright::ProbeResult.stale.in_batches.destroy_all" schedule: every hour at minute 30 ``` -------------------------------- ### AlertManager Configuration for Notifications Source: https://context7.com/basecamp/upright/llms.txt This YAML configuration outlines the AlertManager setup for routing and managing alerts generated by Upright. It includes global settings like `resolve_timeout`, routing rules based on labels, grouping intervals, and definitions for receivers such as webhooks, Slack, and PagerDuty. ```yaml global: resolve_timeout: 5m route: receiver: default group_by: ['alertname', 'probe_name'] group_wait: 30s group_interval: 5m repeat_interval: 4h receivers: - name: default webhook_configs: - url: 'https://your-webhook-url.com/alerts' slack_configs: - api_url: 'https://hooks.slack.com/services/xxx' channel: '#alerts' pagerduty_configs: - service_key: 'your-service-key' ``` -------------------------------- ### Local Development CLI Commands Source: https://github.com/basecamp/upright/blob/main/README.md Common shell commands for setting up the environment, running services, and executing the server. ```bash bin/setup bin/services bin/dev ``` -------------------------------- ### Configure Deployment with deploy.yml Source: https://github.com/basecamp/upright/blob/main/README.md Defines the service infrastructure, including server hosts, proxy settings, environment variables, and accessory services like Playwright and Prometheus. ```yaml 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 tags: amsterdam: SITE_SUBDOMAIN: ams new_york: SITE_SUBDOMAIN: nyc san_francisco: SITE_SUBDOMAIN: sfo accessories: playwright: image: jacoblincool/playwright:chromium-server-1.55.0 port: "127.0.0.1:53333:53333" roles: - jobs prometheus: image: prom/prometheus:v3.2.1 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 hosts: - ams.upright.example.com cmd: --config.file=/etc/alertmanager/alertmanager.yml files: - config/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml ``` -------------------------------- ### Configure Upright Hostname and Authentication Source: https://github.com/basecamp/upright/blob/main/README.md Configuration snippets for setting the application hostname and enabling OpenID Connect authentication within the Upright initializer. ```ruby # config/initializers/upright.rb Upright.configure do |config| config.hostname = "upright.com" end ``` ```ruby # 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 ``` -------------------------------- ### Run and Schedule Playwright Probes Source: https://context7.com/basecamp/upright/llms.txt Shows how to manually run a Playwright probe for debugging purposes, including enabling a visible browser. It also demonstrates how to schedule a Playwright probe for later execution. ```ruby # Run Playwright probe manually (with visible browser for debugging) # Start with: LOCAL_PLAYWRIGHT=1 bin/rails console Probes::Playwright::MyServiceAuthProbe.check # Schedule Playwright probe Probes::Playwright::MyServiceAuthProbe.check_and_record_later ``` -------------------------------- ### Configure Upright Initializer Source: https://context7.com/basecamp/upright/llms.txt Settings for the Upright engine including service identification, timeout thresholds, Playwright server URLs, and OIDC authentication providers. ```ruby Upright.configure do |config| config.service_name = "my_monitoring" config.user_agent = "my_monitoring/1.0" config.hostname = Rails.env.local? ? "my-monitoring.localhost" : "my-monitoring.com" config.default_timeout = 10.seconds config.playwright_server_url = ENV["PLAYWRIGHT_SERVER_URL"] config.otel_endpoint = ENV["OTEL_EXPORTER_OTLP_ENDPOINT"] config.auth_provider = :openid_connect config.auth_options = { issuer: ENV["OIDC_ISSUER"], client_id: ENV["OIDC_CLIENT_ID"], client_secret: ENV["OIDC_CLIENT_SECRET"] } end ``` -------------------------------- ### Manage Probe Artifacts Source: https://context7.com/basecamp/upright/llms.txt Demonstrates how to create, attach, and retrieve debugging artifacts like logs or response data from probe results. ```ruby # Create and attach an artifact artifact = Upright::Artifact.new( name: "debug.log", content: "Detailed debugging information..." ) artifact.attach_to(probe_result) # Access artifacts from probe result probe_result.artifacts.each do |attachment| content = attachment.download puts "#{attachment.filename}: #{content.bytesize} bytes" end ``` -------------------------------- ### Ruby API for Site Management Source: https://context7.com/basecamp/upright/llms.txt This Ruby code illustrates how to programmatically access and manage monitoring sites using the Upright API. It covers listing all configured sites, finding a specific site by its code and accessing its properties, retrieving the current site based on an environment variable, and generating Leaflet map data. ```ruby # List all configured sites Upright.sites # => [#, ...] # Find a specific site site = Upright.find_site("nyc") site.code # => :nyc site.city # => "New York City" site.country # => "US" site.geohash # => "dr5reg" site.provider # => "digitalocean" site.latitude # => 40.7128 site.longitude # => -74.0060 site.url # => "https://nyc.my-monitoring.com/" # Get current site (based on SITE_SUBDOMAIN env var) Upright.current_site # Generate Leaflet map data Upright.sites.map(&:to_leaflet) # => [{hostname: "nyc.example.com", city: "New York City", lat: 40.7128, lon: -74.0060, url: "..."}, ...] ``` -------------------------------- ### Ruby API for Probe Status and Uptime Queries Source: https://context7.com/basecamp/upright/llms.txt This Ruby code demonstrates how to interact with the Upright API to retrieve probe status and uptime summaries. It shows how to fetch all probes of a specific type, iterate through site statuses, retrieve 30-day uptime summaries, and filter uptimes by probe type. ```ruby # Get current status for all probes of a type probes = Upright::Probes::Status.for_type("http") probes.each do |probe| puts "#{probe.name}: #{probe.type}" probe.site_statuses.each do |site_status| puts " #{site_status.site_city}: #{site_status.current_status}" end end # Get 30-day uptime summaries uptimes = Upright::Probes::Uptime.all uptimes.each do |summary| puts "#{summary.name}: #{summary.uptime_percentage}%" end # Filter uptime by probe type http_uptimes = Upright::Probes::Uptime.for_type("http") playwright_uptimes = Upright::Probes::Uptime.for_type("playwright") ``` -------------------------------- ### Query Probe Results from Database Source: https://context7.com/basecamp/upright/llms.txt Demonstrates various ways to query probe results stored in the database using ActiveRecord. It covers fetching recent results, filtering by type and status, filtering by probe name, and preparing data for charting. ```ruby # Query recent probe results Upright::ProbeResult.order(created_at: :desc).limit(10) # Filter by type and status Upright::ProbeResult.by_type("http").by_status("fail") # Filter by probe name Upright::ProbeResult.by_name("Main Website") # Get results for charting results = Upright::ProbeResult.by_name("API Health").limit(100) chart_data = results.map(&:to_chart) # => [{probe_name: "API Health", status: "ok", created_at: "2024-01-15T10:30:00Z", duration: 0.234}, ...] ``` -------------------------------- ### Test Playwright Probes Source: https://github.com/basecamp/upright/blob/main/README.md Commands to run Playwright probes locally, either via console or test suite. ```bash LOCAL_PLAYWRIGHT=1 bin/rails console # Inside console: Probes::Playwright::MyServiceAuthProbe.check # Running tests: bin/rails test ``` -------------------------------- ### Manage Traceroute Probes Source: https://context7.com/basecamp/upright/llms.txt Configuration and execution of network path analysis probes. Includes YAML definitions and Ruby methods for triggering traceroute. ```yaml - name: CDN Edge host: cdn.example.com alert_severity: high - name: Database Server host: db.example.com ``` ```ruby probe = Upright::Probes::TracerouteProbe.find_by(name: "CDN Edge") result = probe.check_and_record ``` -------------------------------- ### Configure Prometheus Scrape and Alert Rules Source: https://github.com/basecamp/upright/blob/main/README.md Provides the configuration for scraping Upright metrics and defining alert rules for monitoring probe status. ```yaml scrape_configs: - job_name: upright static_configs: - targets: ['localhost:9394'] 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" ``` -------------------------------- ### Configure HTTP and SMTP Probes Source: https://github.com/basecamp/upright/blob/main/README.md Define monitoring targets for HTTP and SMTP services using YAML configuration files. HTTP probes support status code validation and authentication, while SMTP probes monitor host availability. ```yaml - 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 ``` ```yaml - name: Primary Mail Server host: mail.example.com - name: Backup Mail Server host: mail2.example.com ``` -------------------------------- ### Implement Custom Monitoring Probes Source: https://context7.com/basecamp/upright/llms.txt Extends the base probe classes to create custom monitoring logic, such as HTTP API checks, with built-in support for site staggering and artifact attachment. ```ruby class Upright::Probes::CustomAPIProbe < FrozenRecord::Base include Upright::Probeable include Upright::ProbeYamlSource stagger_by_site 3.seconds def check response = fetch_api_data validate_response(response) end def on_check_recorded(probe_result) attach_response_data(probe_result) end def probe_type = "custom_api" def probe_target = url private def fetch_api_data Upright::HTTP::Request.new(url).get end def validate_response(response) return false if response.network_error? data = JSON.parse(response.body) data["status"] == "healthy" && data["version"].present? rescue JSON::ParserError false end def attach_response_data(probe_result) Upright::Artifact.new( name: "api_response.json", content: @last_response&.body ).attach_to(probe_result) end end ``` -------------------------------- ### Manage SMTP Probes Source: https://context7.com/basecamp/upright/llms.txt Configuration and execution of SMTP probes to verify mail server availability. Includes YAML definitions and Ruby methods for manual execution and log retrieval. ```yaml - name: Primary Mail Server host: mail.example.com alert_severity: high - name: Backup Mail Server host: mail2.example.com alert_severity: medium ``` ```ruby Upright::Probes::SMTPProbe.all.each(&:check_and_record) probe = Upright::Probes::SMTPProbe.find_by(name: "Primary Mail Server") result = probe.check_and_record result.artifacts.first.download ``` -------------------------------- ### Prometheus Queries for Probe Status and Uptime Source: https://context7.com/basecamp/upright/llms.txt These Prometheus Query Language (PromQL) snippets are used to extract uptime percentages, identify probes with high failure rates across regions, and retrieve probe duration by site. They leverage metrics like `upright_probe_up` and `upright_probe_duration_seconds`. ```promql avg_over_time(upright_probe_up{name="API Health"}[24h]) * 100 ``` ```promql upright:probe_down_fraction > 0.5 ``` ```promql upright_probe_duration_seconds{type="http"} by (name, site_city) ``` -------------------------------- ### Access Probe Artifacts Source: https://context7.com/basecamp/upright/llms.txt Explains how to access artifacts associated with probe results, such as logs, videos, and response bodies. It iterates through the artifacts of the last probe result and prints their filenames and content types. ```ruby # Access probe artifacts (logs, videos, response bodies) result = Upright::ProbeResult.last result.artifacts.each do |artifact| puts "#{artifact.filename}: #{artifact.content_type}" # curl.log: text/plain # response.html: text/html # recording.webm: video/webm end ``` -------------------------------- ### Schedule Probes with Solid Queue Source: https://github.com/basecamp/upright/blob/main/README.md Configure recurring probe execution in the Rails application using the Solid Queue configuration file. Each probe type is mapped to a command and a specific execution frequency. ```yaml 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 ``` -------------------------------- ### Configure Kamal Deployment Source: https://context7.com/basecamp/upright/llms.txt Defines the service architecture, server hosts, environment variables, and accessory services like Prometheus and Playwright for Kamal orchestration. ```yaml service: my-upright image: my-org/my-upright servers: web: hosts: - ams.my-upright.com: [amsterdam] - nyc.my-upright.com: [new_york] - sfo.my-upright.com: [san_francisco] jobs: hosts: - ams.my-upright.com: [amsterdam] - nyc.my-upright.com: [new_york] - sfo.my-upright.com: [san_francisco] cmd: bin/jobs proxy: app_port: 3000 ssl: true hosts: - "*.my-upright.com" env: secret: - RAILS_MASTER_KEY tags: amsterdam: SITE_SUBDOMAIN: ams new_york: SITE_SUBDOMAIN: nyc san_francisco: SITE_SUBDOMAIN: sfo accessories: playwright: image: jacoblincool/playwright:chromium-server-1.55.0 port: "127.0.0.1:53333:53333" roles: - jobs prometheus: image: prom/prometheus:v3.2.1 hosts: - ams.my-upright.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 ``` -------------------------------- ### 422 Unprocessable Entity Response Source: https://github.com/basecamp/upright/blob/main/test/dummy/public/422.html Standard error response returned when a request is rejected due to validation errors or insufficient permissions. ```APIDOC ## 422 Unprocessable Entity ### Description This response is returned when the server understands the content type of the request entity, and the syntax of the request entity is correct, but was unable to process the contained instructions. This often occurs due to validation failures or lack of access rights. ### Method N/A ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response (422) - **error** (string) - The change you wanted was rejected. - **message** (string) - Indicates that the user may have attempted to modify a resource without sufficient access. #### Response Example { "error": "The change you wanted was rejected", "code": 422, "hint": "Check application logs for specific validation details." } ``` -------------------------------- ### Create Playwright Authenticators Source: https://github.com/basecamp/upright/blob/main/README.md Define custom authentication logic for probes requiring login. Authenticators extend the base class and handle navigation, credential injection, and form submission. ```ruby 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 ``` -------------------------------- ### Define Playwright Authenticator Source: https://context7.com/basecamp/upright/llms.txt Illustrates how to create a custom authenticator for Playwright probes. This class defines the sign-in URL, path, and service name, and implements the `authenticate` method to handle the sign-in process using provided credentials. ```ruby # 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 ``` -------------------------------- ### Define Monitoring Sites Source: https://github.com/basecamp/upright/blob/main/README.md YAML configuration for defining geographic monitoring locations, including city, country, geohash, and hosting provider details. ```yaml shared: sites: - code: nyc city: New York City country: US geohash: dr5reg provider: digitalocean - code: ams city: Amsterdam country: NL geohash: u17982 provider: digitalocean - code: sfo city: San Francisco country: US geohash: 9q8yy provider: hetzner ``` -------------------------------- ### Generate Playwright Probe Source: https://context7.com/basecamp/upright/llms.txt Shows how to generate a new Playwright probe using the Rails generator. It includes an option to generate with an authenticator, which is useful for probes that require login. ```bash # Generate a new Playwright probe bin/rails generate upright:playwright_probe MyServiceAuth # Generate with authenticator bin/rails generate upright:playwright_probe MyServiceAuth --with-authenticator ``` -------------------------------- ### Manage Kamal Deployment Operations Source: https://context7.com/basecamp/upright/llms.txt Common CLI commands for deploying the Upright service, viewing logs, and accessing the Rails console. ```bash # Deploy to all servers bin/kamal deploy # Deploy to specific destination bin/kamal deploy -d production # View logs bin/kamal logs -f # Access Rails console bin/kamal console ``` -------------------------------- ### Generate and Implement Playwright Probes Source: https://github.com/basecamp/upright/blob/main/README.md Use the Rails generator to create Playwright probe classes for browser-based testing. These classes extend the base probe and implement custom check logic using the Playwright API. ```bash bin/rails generate upright:playwright_probe MyServiceAuth ``` ```ruby class Probes::Playwright::MyServiceAuthProbe < Upright::Probes::Playwright::Base def check page.goto("https://app.example.com") page.fill('[name="email"]', "test@example.com") page.click('button[type="submit"]') page.wait_for_selector(".dashboard") end end ``` -------------------------------- ### Access Traceroute Result Details Source: https://context7.com/basecamp/upright/llms.txt Demonstrates how to retrieve and iterate over traceroute results. It shows how to check if the destination was reached and access details for each hop, such as hop number, IP address, ASN, and average latency. ```ruby traceroute = Upright::Traceroute::Result.for("cdn.example.com") traceroute.reached_destination? # => true traceroute.hops.each do |hop| puts "#{hop.hop_number}: #{hop.ip} (#{hop.asn}) - #{hop.avg_latency}ms" end ``` -------------------------------- ### Manage HTTP Probes Source: https://context7.com/basecamp/upright/llms.txt Configuration and execution of HTTP health checks. Includes YAML definitions for probes and Ruby methods for manual triggering. ```yaml - 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 - name: External Service url: https://external-service.com proxy: us_proxy ``` ```ruby Upright::Probes::HTTPProbe.all.each(&:check_and_record) probe = Upright::Probes::HTTPProbe.find_by(name: "Main Website") probe.check_and_record Upright::Probes::HTTPProbe.check_and_record_all_later ``` -------------------------------- ### CSS Reset and Base Styling Source: https://github.com/basecamp/upright/blob/main/test/dummy/public/404.html This CSS code snippet provides a universal box-sizing reset, removes default margins, sets the base font size for the HTML, and defines general styling for the body, including background, color, font family, font size, and layout properties. It also includes styles for links, bold text, and italic text. ```css *, *::before, *::after { box-sizing: border-box; } * { margin: 0; } html { font-size: 16px; } body { background: #FFF; color: #261B23; display: grid; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: clamp(1rem, 2.5vw, 2rem); -webkit-font-smoothing: antialiased; font-style: normal; font-weight: 400; letter-spacing: -0.0025em; line-height: 1.4; min-height: 100dvh; place-items: center; text-rendering: optimizeLegibility; -webkit-text-size-adjust: 100%; } a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 0.0925em; } b, strong { font-weight: 700; } i, em { font-style: italic; } ``` -------------------------------- ### Configure OpenTelemetry Endpoint Source: https://github.com/basecamp/upright/blob/main/README.md Configures the OpenTelemetry collector endpoint within the Ruby application environment. ```ruby Upright.configure do |config| config.otel_endpoint = "https://otel.example.com:4318" end ``` -------------------------------- ### Define Monitoring Sites Source: https://context7.com/basecamp/upright/llms.txt Configuration for geographic monitoring locations using YAML. Each site entry includes metadata like city, country, and provider. ```yaml shared: sites: - code: nyc city: New York City country: US geohash: dr5reg provider: digitalocean - code: ams city: Amsterdam country: NL geohash: u17982 provider: digitalocean - code: sfo city: San Francisco country: US geohash: 9q8yy provider: hetzner ``` -------------------------------- ### Prometheus Alert Rules for Upright Monitoring Source: https://context7.com/basecamp/upright/llms.txt This YAML configuration defines Prometheus recording rules and alerting rules for the Upright monitoring system. It includes rules for calculating the fraction of regions reporting a probe as DOWN, daily uptime percentage, and alerts for HTTP probe failures and degradations. ```yaml groups: - name: upright_recording interval: 30s rules: # Fraction of regions reporting DOWN (0.0 to 1.0) - record: upright:probe_down_fraction expr: | count by (name, type, probe_target, alert_severity) (upright_probe_up == 0) / count by (name, type, probe_target, alert_severity) (upright_probe_up) # Daily uptime percentage - record: upright:probe_uptime_daily expr: | avg_over_time(( sum by (name, type, probe_target) (upright_probe_up) / count by (name, type, probe_target) (upright_probe_up) > bool 0.5 )[1d:]) - name: upright_http_alerts rules: - alert: UprightHTTPProbeDown annotations: summary: "HTTP: {{ $labels.name }} is DOWN" description: "{{ $value | humanizePercentage }} of regions report failure" expr: upright:probe_down_fraction{type="http"} > 0.5 labels: severity: "{{ $labels.alert_severity }}" - alert: UprightHTTPProbeDegraded annotations: summary: "HTTP: {{ $labels.name }} degraded" expr: upright:probe_down_fraction{type="http"} > 0.25 and upright:probe_down_fraction{type="http"} <= 0.5 for: 5m labels: severity: warning ``` -------------------------------- ### Upright Prometheus Metrics Source: https://context7.com/basecamp/upright/llms.txt Lists the available metrics exposed by Upright for Prometheus monitoring. It details the metric names, their purpose, and the labels associated with them, which can be used for filtering and aggregation in PromQL queries. ```ruby # Available metrics (set automatically on probe completion): # upright_probe_duration_seconds - Probe execution duration # Labels: type, name, probe_target, probe_service, alert_severity, status, # site_code, site_city, site_country, site_geohash, site_provider # upright_probe_up - Probe status (1 = up, 0 = down) # Labels: type, name, probe_target, probe_service, alert_severity, # site_code, site_city, site_country, site_geohash, site_provider # upright_http_response_status - HTTP response status code # Labels: name, probe_target, probe_service ``` -------------------------------- ### Clean Up Stale Probe Results Source: https://context7.com/basecamp/upright/llms.txt Shows how to clean up old probe results from the database. The `stale` scope filters results older than 24 hours, and `in_batches.destroy_all` efficiently deletes them. ```ruby # Clean up stale results (older than 24 hours) Upright::ProbeResult.stale.in_batches.destroy_all ``` -------------------------------- ### 404 Error Page Styling and Responsiveness Source: https://github.com/basecamp/upright/blob/main/test/dummy/public/404.html This CSS code styles specific elements of a 404 error page, including SVG elements for the error description and ID. It also defines styles for the main content area, header, and article, ensuring responsiveness with media queries for line breaks. The styles adapt for dark mode preference. ```css #error-description { fill: #d30001; } #error-id { fill: #f0eff0; } @media (prefers-color-scheme: dark) { body { background: #101010; color: #e0e0e0; } #error-description { fill: #FF6161; } #error-id { fill: #2c2c2c; } } main { display: grid; gap: 1em; padding: 2em; place-items: center; text-align: center; } main header { width: min(100%, 12em); } main header svg { height: auto; max-width: 100%; width: 100%; } main article { width: min(100%, 30em); } main article p { font-size: 75%; } main article br { display: none; } @media (min-width: 48em) { main article br { display: inline; } } ``` -------------------------------- ### Error Page CSS Styling Source: https://github.com/basecamp/upright/blob/main/test/dummy/public/422.html This CSS code styles the error page, including layout, typography, and color schemes for both light and dark modes. It ensures responsiveness and accessibility. ```css *, *::before, *::after { box-sizing: border-box; } * { margin: 0; } html { font-size: 16px; } body { background: #FFF; color: #261B23; display: grid; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: clamp(1rem, 2.5vw, 2rem); -webkit-font-smoothing: antialiased; font-style: normal; font-weight: 400; letter-spacing: -0.0025em; line-height: 1.4; min-height: 100dvh; place-items: center; text-rendering: optimizeLegibility; -webkit-text-size-adjust: 100%; } #error-description { fill: #d30001; } #error-id { fill: #f0eff0; } @media (prefers-color-scheme: dark) { body { background: #101010; color: #e0e0e0; } #error-description { fill: #FF6161; } #error-id { fill: #2c2c2c; } } a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 0.0925em; } b, strong { font-weight: 700; } i, em { font-style: italic; } main { display: grid; gap: 1em; padding: 2em; place-items: center; text-align: center; } main header { width: min(100%, 12em); } main header svg { height: auto; max-width: 100%; width: 100%; } main article { width: min(100%, 30em); } main article p { font-size: 75%; } main article br { display: none; } @media (min-width: 48em) { main article br { display: inline; } } ``` -------------------------------- ### Style 400 Bad Request Error Page with CSS Source: https://github.com/basecamp/upright/blob/main/test/dummy/public/400.html This CSS snippet defines the global layout, typography, and responsive behavior for the error page. It utilizes CSS Grid for centering, clamp functions for fluid typography, and media queries to adjust colors for dark mode. ```css *, *::before, *::after { box-sizing: border-box; } * { margin: 0; } html { font-size: 16px; } body { background: #FFF; color: #261B23; display: grid; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: clamp(1rem, 2.5vw, 2rem); min-height: 100dvh; place-items: center; } @media (prefers-color-scheme: dark) { body { background: #101010; color: #e0e0e0; } #error-description { fill: #FF6161; } #error-id { fill: #2c2c2c; } } main { display: grid; gap: 1em; padding: 2em; place-items: center; text-align: center; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.