Observability Architecture
The observability stack uses industry-standard cloud-native tools to capture and aggregate metrics:- Go API Server Metrics: Emitted using the OpenTelemetry SDK via OTLP (gRPC) to the OpenTelemetry Collector, which exposes a Prometheus scraper endpoint.
- PostgreSQL Database Metrics: Captured by the
postgres-exportercontainer, which queries database statistics and exposes standard metrics. - Redis Caching Metrics: Captured by the
redis-exportercontainer, which collects keyspace, memory, and connection statistics. - Prometheus Server: Scrapes the OpenTelemetry Collector, postgres-exporter, and redis-exporter at high frequency (5-second intervals) to assemble a unified telemetry database.
- Grafana Platform: Pulls metrics from Prometheus to display preconfigured, interactive dashboards.
Port Mapping and Web UIs
The telemetry endpoints exposed locally when booting the stack include:| Service | Port | Endpoint URL | Description |
|---|---|---|---|
| Go API Server | 8000 | http://localhost:8000 | The primary Go backend application built with Fiber |
| Prometheus | 9090 | http://localhost:9090 | The metrics database scraping all collector endpoints |
| Grafana | 3000 | http://localhost:3000 | The visualization platform preloaded with provisioned dashboards |
| OpenTelemetry Collector | 4317 / 4318 | localhost:4317 | The OTLP gRPC and HTTP receiver pipelines |
| OTEL Prometheus Exporter | 8889 | http://localhost:8889 | Scraper endpoint for Go API server metrics |
| PostgreSQL Exporter | 9187 | http://localhost:9187 | Scraper endpoint for PostgreSQL database metrics |
| Redis Exporter | 9121 | http://localhost:9121 | Scraper endpoint for Redis cache metrics |
1. Spin Up the Telemetry Stack
All observability services and database exporters are orchestrated inside thedocker-compose.yml file of the main application. If you have already started the containers as described in the Run px0 Locally guide, the telemetry stack is already running.
Otherwise, boot all background containers in detached mode from the project root:
2. Verify Prometheus Scraping Targets
Ensure that the Prometheus server is successfully scraping all system components:- Open the Prometheus targets dashboard at http://localhost:9090/targets.
- Verify that all three endpoints show a status of UP:
otel-collector(Go application metrics)postgres-exporter(PostgreSQL database metrics)redis-exporter(Redis cache metrics)
Quick Sanity Queries
Navigate to http://localhost:9090 and execute these queries in the expression browser to confirm metric capture:- Application Metrics: Enter
px0_http_server_requests_totalorpx0_go_goroutine_countand click Execute. - PostgreSQL Metrics: Enter
pg_uporpg_stat_database_numbackendsand click Execute. - Redis Metrics: Enter
redis_uporredis_connected_clientsand click Execute.
3. Generate Load and Run Benchmarks
To observe real-time metrics on your dashboards, you must simulate system load. The project contains a high-performance, self-contained load-testing utility located atcmd/loadtest/main.go.
Run the Benchmark
Execute the load test script from the root directory of the main project:Benchmarking Lifecycle
The script executes the following actions autonomously during execution:- Connects directly to the PostgreSQL database.
- Registers a temporary test organization, team, programmatic API key, prompt, and a live prompt template version.
- Conducts a pre-flight health check on the rendering API endpoint.
- Launches concurrent worker goroutines that send high-throughput parallel POST requests to render the live prompt template.
- Cleans up and truncates all temporary test records upon completion.
- Measures response latency and success throughput, outputting an aligned table in your console.
Sample Benchmark Results
The console output from a successful benchmark run looks similar to this:4. Explore Grafana Dashboards
Grafana is preconfigured to run locally with zero manual login overhead. Anonymous access is enabled with Admin permissions by default.Grafana Access
- Access URL: Open http://localhost:3000 in your browser.
- Authentication: Anonymous login is active. If prompted for login credentials, use Username:
adminand Password:admin. - Dashboards: Navigate to Dashboards, open the
px0folder, and open the preconfiguredpx0 Service Dashboard.
Key Metrics to Monitor
When running a benchmark, observe the following visualizations on the dashboard:- HTTP Request Rate (RPS): Tracks the real-time throughput of the application.
- HTTP Latency (p95 and p99): Visualizes tail latencies to detect performance degradation under load.
- Active and In-flight Requests: Measures the active concurrent requests being processed by the Go web server.
- System Resources: Tracks host and container CPU/memory usage to help you identify hardware bottlenecks.

