Deployment Guide
The project can run locally using Docker Compose or it can be launched manually with dependencies installed separately.
Docker Compose
The repository includes a docker-compose.yml file that starts the server along with Redis, Postgres, ClickHouse, Prometheus, Loki, Promtail, Grafana, Tempo, and optionally the CTR predictor service.
docker compose up
- Grafana is available at
http://localhost:3000(usernameadmin, passwordadmin). - The server listens on
http://localhost:8787by default. - A
prebid-servercontainer is exposed athttp://localhost:8060when using theprebidprofile. See Programmatic Demand for configuration guidance. - Logs are collected by Promtail and stored in Loki. You can explore them in Grafana's Explore section.
- Distributed tracing is enabled by default with traces sent to Tempo. Use Grafana's Explore section to query traces and correlate them with logs.
The data/GeoLite2-Country.mmdb file provides GeoIP lookup out of the box. The server creates the tables on startup. Run the fake_data tool from inside the openadserve container to load demo data:
docker compose exec openadserve go run ./tools/fake_data
When the database is empty this command inserts a demo publisher (ID 1, API key demo123) before generating additional publishers.
Using Distributed Tracing
The ad server includes comprehensive distributed tracing with OpenTelemetry and Grafana Tempo integration:
Finding and Using Trace IDs
Trace IDs are automatically included in all application logs:
{
"level": "error",
"trace_id": "172ed24edd575ad8999472a68e6cfb72",
"span_id": "a83dd8775de972b9",
"msg": "invalid api key"
}
To trace a request:
- Find any log entry related to your request (error logs, info logs, etc.)
- Copy the
trace_idvalue - In Grafana, go to Explore → Select Tempo data source
- Paste the trace ID and click Run Query
TraceQL Queries
Use TraceQL to find traces by attributes:
// Find all traces for the ad server
{service.name="openadserve"}
// Find traces with errors
{service.name="openadserve" && status=error}
// Find ad request traces by publisher
{service.name="openadserve" && publisher_id="1"}
Trace-to-Logs Correlation
The Grafana setup includes automatic correlation between traces and logs:
- Click on any span in a trace view
- Select "Logs for this span" to see all related log entries
- All logs within a request automatically include the same trace ID
This enables seamless debugging: start with a trace to see the request flow, then drill down to specific log entries for detailed error information.
Manual Setup
-
Start Redis (set
REDIS_ADDRif using an existing instance):docker run -p 6379:6379 redis -
Start ClickHouse (set
CLICKHOUSE_DSNfor your instance):docker run -p 9000:9000 clickhouse/clickhouse-server:latest -
Start Postgres (set
POSTGRES_DSNfor your instance):docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:15
# default DSN assumes 127.0.0.1
export POSTGRES_DSN=postgres://postgres@127.0.0.1:5432/postgres?sslmode=disable -
(Optional) GeoIP – set
GEOIP_DBto a MaxMind GeoLite2 database. The repo ships with a country database indata/GeoLite2-Country.mmdb, but you can supply a City database for region targeting. -
Generate demo data:
go run ./tools/fake_dataThe first run on an empty database creates a demo publisher with ID
1and API keydemo123before adding more publishers. -
Run the server:
go run cmd/server/main.go
Set the PORT environment variable to change the listen port. Enable DEBUG_TRACE=1 to always include selection traces in ad responses for troubleshooting.
For logging configuration, set ENV=development for full debug logging, or ENV=production for reduced log volume via sampling. Use LOG_LEVEL to override the default log level.
Use RELOAD_INTERVAL to automatically reload campaigns, line items and creatives from Postgres. The default interval is 30s; set it to 0 to disable automatic reloading.