Setting Up the GHOSTS API¶
Updated on October 30, 2024
The GHOSTS API enables centralized control and orchestration of non-player characters (NPCs) within a deployment. It provides logging, reporting, and management capabilities for individual machines, machine groups, or entire deployments.
Architecture Overview¶
The GHOSTS API consists of four components, each running in its own Docker container:
- GHOSTS API - RESTful API for configuring and managing NPCs, machines, and timelines
- GHOSTS UI - Web interface for visualizing and managing your GHOSTS deployment
- Postgres - Database for storing all GHOSTS data (machines, NPCs, timelines, activities)
- Grafana - Dashboard for monitoring and analyzing NPC activities in real-time
Installation Steps¶
Step 1 — Choose Where to Host the API¶
Select an appropriate host for your GHOSTS API deployment:
- Testing/Development: Your local machine is sufficient
- Training/Exercises: Use a dedicated server, VM, or cloud instance
- Production: Consider container orchestration platforms like AWS ECS, Kubernetes, or Docker Swarm
System Requirements:
- Docker and Docker Compose installed
- Minimum 4GB RAM (8GB+ recommended for larger deployments)
- 20GB disk space
- Network access from client machines to API server
Step 2 — Install Docker and Docker Compose¶
Install the required software on your API host:
- Install Docker: Follow the Docker installation guide
- Install Docker Compose: Follow the Docker Compose installation guide
Verify Installation:
docker --version
docker-compose --version
Both commands should return version information if properly installed.
Step 3 — Deploy the GHOSTS API¶
Create a directory for the GHOSTS deployment and download the Docker Compose configuration:
mkdir ghosts-api
cd ghosts-api
curl -O https://raw.githubusercontent.com/cmu-sei/GHOSTS/master/src/Ghosts.Api/docker-compose.yml
Start all containers:
docker-compose up -d
The -d flag runs containers in detached mode (in the background).
Verify All Containers Are Running:
docker ps -a
You should see four containers: ghosts-api, ghosts-ui, ghosts-postgres, and ghosts-grafana.

Step 4 — Verify the Installation¶
Test each component to ensure proper deployment:
1. GHOSTS API (Port 5000)
Open http://localhost:5000 in your browser. You should see the API home page displaying:
- API version information
- Several test machine entries
- Links to various API endpoints

2. GHOSTS UI (Port 8080)
Open http://localhost:8080 to access the web management interface. See the UI documentation for usage details.
3. Grafana Dashboard (Port 3000)
Open http://localhost:3000 to access the monitoring dashboard. Default credentials are typically admin/admin (you'll be prompted to change the password on first login). See the Grafana documentation for configuration details.
Managing the API¶
Starting and Stopping¶
# Stop all containers
docker-compose down
# Start all containers
docker-compose up -d
# Restart a specific container
docker-compose restart ghosts-api
# View container logs
docker-compose logs -f ghosts-api
Updating GHOSTS¶
To update to the latest version:
docker-compose down
docker-compose pull
docker-compose up -d
Data Persistence¶
All data is stored in Docker volumes:
- postgres_data - Database containing machines, NPCs, timelines, and activities
- grafana_data - Grafana configuration and dashboards
These volumes persist across container restarts and updates.
Troubleshooting¶
API Home Page Shows Error¶

Cause: The Postgres database container is not running or not accessible.
Solution:
-
Check if the Postgres container is running:
docker ps -a | grep postgres -
Check Postgres logs for errors:
docker logs ghosts-postgres -
Restart the Postgres container:
docker-compose restart ghosts-postgres -
If the container repeatedly restarts, check for permission issues with the data volume.
Social Graph Link Shows Error¶

Cause: No social network has been created yet.
Solution: This is normal for new installations. Social networks are created when you generate NPCs using the Animator functionality. See the Animator documentation for details.
Grafana Container Keeps Restarting¶
Cause: Insufficient permissions on the Grafana data directory.
Solution:
-
Check the ownership of the Grafana data directory:
ls -la | grep grafana -
Set the correct ownership (the exact user ID may vary based on your
docker-compose.yml):sudo chown -R 472:472 grafana_data -
Restart the Grafana container:
docker-compose restart ghosts-grafana
Cannot Connect from Client to API¶
Cause: Network connectivity or firewall issues.
Solution:
-
Verify the API is accessible from the client machine:
curl http://YOUR-API-SERVER:5000/api -
Check firewall rules on the API server to ensure ports 5000, 8080, and 3000 are accessible.
-
Ensure the client's
application.jsonorapplication.yamlhas the correct API URL:{ "ApiRootUrl": "http://YOUR-API-SERVER:5000/api" }
Container Logs Show "Connection Refused" Errors¶
Cause: Containers are trying to communicate before all services are ready.
Solution: This is typically a timing issue during startup. Wait 30-60 seconds and check if the errors persist. If they do:
docker-compose restart
Need to Reset the Database¶
Warning: This will delete all machines, NPCs, timelines, and activity data.
docker-compose down
docker volume rm ghosts-api_postgres_data
docker-compose up -d
Next Steps¶
- Configure client machines to connect to your API
- Explore the UI to manage machines and timelines
- Set up Grafana dashboards for monitoring
- Learn about timeline configuration
- Generate NPCs using Animator