AIOps Database (Soybean)

AIOps Database (Soybean) #

The AIOps stack (tofu-aiops-hub) uses its own PostgreSQL database called soybean, separate from the main BonsAI database. It stores extraction flags, issues, labels, and other AIOps bookkeeping.

Because it runs as a standalone container, it is not the connection CloudBeaver is pre-configured with, and it is not reachable through tofu-mcp (which targets the main bonsai database only). To inspect or query it in a Coder workspace / preview environment, go through Portainer.

Connection Details #

Setting Value
Container / hostname aiops-database
Database soybean
Username postgres
Password postgres
Port (in-network) 5432
Port (host) 15432
Docker network bonsai-network

Other containers on bonsai-network (CloudBeaver, BonsAPI, etc.) reach it at host aiops-database on port 5432. From the Docker host itself it is published on localhost:15432.

Portainer is the Docker management UI available in your Coder workspace (port 9443). Use it to open a shell directly inside the database container.

  1. Open Portainer from the workspace apps section.

  2. Go to Containers and click the aiops-database container.

  3. Click >_ Console (Exec / Attach).

  4. Set the command to /bin/bash (or /bin/sh) and the user to root, then Connect.

  5. From the container shell, open a psql session:

    psql -U postgres -d soybean
    
  6. Run queries as needed:

    -- Confirm the connection
    SELECT 1;
    
    -- Inspect the extraction-flag tables
    \dt
    SELECT id, name FROM label ORDER BY name;
    SELECT extraction_id, reason FROM extraction_issue ORDER BY created_at DESC LIMIT 20;
    
  7. Exit with \q, then close the console.

Inspecting logs #

The same container page in Portainer has a Logs tab — useful for watching the aiops-migration container apply schema changes or debugging connection issues.

Connect via CloudBeaver (optional) #

If you prefer a visual UI, add a second connection in CloudBeaver alongside the main bonsai one (see CloudBeaver):

  1. DatabaseNew Connection (+ icon) → PostgreSQL.
  2. Enter:
    • Host: aiops-database
    • Port: 5432
    • Database: soybean
    • Username: postgres
    • Password: postgres
  3. Save credentialsTest ConnectionCreate.

Applying Migrations #

The soybean schema is managed by Atlas, with migrations in tools/aiops-database/migrations/. The aiops-migration container applies pending migrations automatically on mise run dev. To apply them manually:

mise run aiops-db-migrate-apply

Note: atlas.hcl’s local env targets port 5433, but the container publishes on the host at 15432. If the mise task fails with connection refused, apply against the published port directly:

cd tools/aiops-database
atlas migrate apply --dir "file://migrations" \
  --url "postgres://postgres:postgres@localhost:15432/soybean?sslmode=disable"

Troubleshooting #

Cannot Connect #

  1. Confirm the container is running and healthy in Portainer (Containersaiops-database should show healthy).
  2. From other containers use host aiops-database (not localhost); from the host use localhost:15432.
  3. Check the Logs tab for the aiops-database and aiops-migration containers.

Migrations Not Applied #

  • Verify the aiops-migration container ran successfully (it exits after applying).
  • Re-run mise run aiops-db-migrate-apply (see note above on the port).

Resources #

  • CloudBeaver - Web-based database management
  • Database Migration - Atlas migration workflow
  • Compose definition: tools/aiops-database/docker-compose.yml
  • Migrations: tools/aiops-database/migrations/