The SWF Monitor provides web interface and API services for the testbed.
The monitor runs on two ports for different purposes:
# Start monitor with both HTTP and HTTPS
../swf-monitor/start_django_dual.shThis creates:
- HTTP Server (port 8002): REST logging from agents (no authentication required)
- HTTPS Server (port 8443): Authenticated API calls (STF files, workflows, runs)
Required environment variables in ~/.env:
# Monitor URLs for different purposes (development, local Django)
export SWF_MONITOR_URL=https://localhost:8443 # Authenticated API calls
export SWF_MONITOR_HTTP_URL=http://localhost:8002 # REST logging (no auth)
# Authentication token for API calls
export SWF_API_TOKEN=your_token_hereGet Next Run Number (used by DAQ simulator):
POST /api/state/next-run-number/
# Returns: {"run_number": 100015, "status": "success"}Get Next Agent ID (used by all agents at startup):
POST /api/state/next-agent-id/
# Returns: {"agent_id": 42, "status": "success"}Both endpoints are atomic and thread-safe for concurrent access.
The Remote SSE example agent is intended to connect to the production Apache-hosted monitor only. Set this in your ~/.env (or rely on the built-in default):
# Canonical production monitor base (Apache path-aware)
export SWF_MONITOR_PROD_URL=https://pandaserver02.sdcc.bnl.gov/swf-monitorNotes:
- The example receiver will use
SWF_MONITOR_PROD_URLif set; otherwise it falls back to the canonical URL above. - It does not support the local Django dev server.
Python requests must trust the production monitor certificate chain. Add this to your ~/.env:
# Use the same full chain as production Apache
export REQUESTS_CA_BUNDLE=/eic/u/wenauseic/github/swf-monitor/full-chain.pem
# Alternative copy:
# export REQUESTS_CA_BUNDLE=/eic/u/wenauseic/github/swf-common-lib/config/full-chain.pemThis ensures the receiver can validate the server certificate when calling:
${SWF_MONITOR_PROD_URL}/api/messages/stream/status/${SWF_MONITOR_PROD_URL}/api/messages/stream/
- Dashboard: http://localhost:8002/ (main monitoring interface)
- STF Files: http://localhost:8002/stf-files/ (file tracking)
- Workflows: http://localhost:8002/workflows/ (processing status)
- Admin Interface: http://localhost:8002/admin/ (Django admin)
Require Authorization: Token <token> header:
POST /api/runs/- Create run recordsPOST /api/stf-files/- Register STF filesPOST /api/workflows/- Create workflow recordsPOST /api/workflow-stages/- Track processing stages
No authentication required:
POST /api/logs/- Agent logging endpoint
From the monitor server:
cd ../swf-monitor/src
python manage.py get_token <username>The startup script automatically creates self-signed certificates for development:
ssl_cert.pem- SSL certificatessl_key.pem- Private key
For production, replace with proper certificates.
-
"Connection refused" - Monitor not started
../swf-monitor/start_django_dual.sh
-
"HTTPS timeout" - Wrong port or SSL issues
- Check HTTPS server is running on port 8443
- Verify SSL certificates exist
-
"401 Unauthorized" - Missing or invalid API token
- Set
SWF_API_TOKENenvironment variable - Get new token with
manage.py get_token
- Set
-
"Empty STF files page" - Agents not calling API
- Verify monitor is serving HTTPS on 8443
- Check agent logs for API call failures
- Ensure
SWF_MONITOR_URLpoints to HTTPS endpoint
This example is intended to run only against the production monitor under Apache.
- Required environment variables (can be placed in
~/.env):SWF_API_TOKEN— DRF token for the APISWF_MONITOR_PROD_URL— Base URL of the production monitor (defaults tohttps://pandaserver02.sdcc.bnl.gov/swf-monitorif not set)
tcsh example:
setenv SWF_API_TOKEN your_token
setenv SWF_MONITOR_PROD_URL https://pandaserver02.sdcc.bnl.gov/swf-monitorThe receiver connects to:
- Stream:
${SWF_MONITOR_PROD_URL}/api/messages/stream/ - Status:
${SWF_MONITOR_PROD_URL}/api/messages/stream/status/
Problem: STF files not appearing despite agents running Cause: Port/protocol mismatch between agent configuration and monitor Solution: Ensure environment variables match actual server configuration:
SWF_MONITOR_URL→ HTTPS port (8443) for API callsSWF_MONITOR_HTTP_URL→ HTTP port (8002) for logging
Agents automatically use the correct endpoints:
- REST logging: Uses
SWF_MONITOR_HTTP_URL(HTTP, no auth) - API calls: Uses
SWF_MONITOR_URL(HTTPS, token auth) - Proxy bypass: Automatic for localhost connections
See Agent System for more details on agent configuration.