Scopes and Discovery Runs

How scopes organize discovery targets and how runs execute them on a schedule or on demand.

What is a Scope?

A scope defines a single discovery target: which plugin to use, what credentials to apply, and how often to run. Scopes are the primary unit of configuration for the discovery system.

Scope Fields

FieldDescriptionExample
nameHuman-readable scope nameprod-aws-east
pluginDiscovery plugin to useaws, kubernetes
configPlugin-specific configuration{"region": "us-east-1"}
scheduleCron schedule expression0 */6 * * *
statusCurrent scope statusactive, paused, error
resource_countLast known resource count342

Creating a Scope

curl -X POST http://localhost:8080/api/v1/discovery/scopes \
  -H "Content-Type: application/json" \
  -d '{
    "name": "prod-aws-east",
    "plugin": "aws",
    "config": {
      "region": "us-east-1",
      "profile": "production"
    },
    "schedule": "0 */6 * * *"
  }'

Discovery Runs

A run is a single execution of a scope. Runs can be triggered manually or on a schedule. Each run records:

  • Start and completion timestamps
  • Status: PENDING, RUNNING, COMPLETED, FAILED
  • Number of resources and relationships found
  • Any errors encountered

Trigger a Run

# Manual run
curl -X POST http://localhost:8080/api/v1/discovery/run \
  -H "Content-Type: application/json" \
  -d '{"scope_id": "prod-aws-east"}'

# Check run status
curl http://localhost:8080/api/v1/discovery/runs/{run_id}

# List all runs for a scope
curl http://localhost:8080/api/v1/discovery/runs?scope_id=prod-aws-east

Scheduling

Scopes use standard cron expressions for scheduling. The scheduler evaluates expressions and triggers runs at the configured intervals. Common patterns:

ScheduleMeaning
0 */6 * * *Every 6 hours
*/15 * * * *Every 15 minutes
0 2 * * *Daily at 2 AM
0 9 * * 1-5Weekdays at 9 AM