Skip to content

Basic Reporting

drpcli provides rich listing and filtering capabilities that make it straightforward to produce inventory reports and job status summaries without writing custom API code. The key pattern is drpcli <object> list [filter...] combined with jq for field selection and formatting.

Listing Objects

Every DRP object type supports the list sub-command. Without filters, it returns all objects of that type as a JSON array:

Bash
# List all machines
drpcli machines list

# List all jobs
drpcli jobs list

# List all workflows
drpcli workflows list

Filtering Lists

Pass key=value filter expressions to narrow results server-side. Multiple filters are ANDed together:

Bash
# Machines currently running a specific workflow
drpcli machines list Workflow=ubuntu-install

# Machines in a specific stage
drpcli machines list Stage=configure-base

# Jobs for a specific machine
drpcli jobs list Machine=<machine-uuid>

# Jobs in a specific state (incomplete, failed, finished)
drpcli jobs list State=failed

See Filter Syntax for filtering information.

Selecting Fields with --format and jq

Use --format yaml to get YAML output, or pipe JSON output to jq for field projection:

Bash
# Machine inventory: name, address, workflow
drpcli machines list | jq -r '.[] | [.Name, .Address, .Workflow] | @tsv'

# Count machines per workflow
drpcli machines list | jq 'group_by(.Workflow) | map({workflow: .[0].Workflow, count: length})'

# List machines that are NOT in the "complete" stage
drpcli machines list | jq '[.[] | select(.Stage != "complete")]'

Common Reporting Tasks

Machine Inventory Report

Bash
# Tab-separated: Name, Address, Workflow, Stage, BootEnv
drpcli machines list | jq -r \
  '.[] | [.Name, (.Address // "unset"), .Workflow, .Stage, .BootEnv] | @tsv' \
  | column -t

Job Status Summary

Bash
# Count jobs by state across all machines
drpcli jobs list | jq 'group_by(.State) | map({state: .[0].State, count: length})'

# Find all failed jobs with machine uuid
drpcli jobs list State=failed | jq -r \
  '.[] | [.UUID[0:8], .Machine, .Task, .State] | @tsv'

Recent Job Log for a Machine

Bash
# Get the UUID of the most recent job for a machine
JOB=$(drpcli jobs list Machine=<machine-uuid> sort=StartTime reverse=true | jq -r '.[0].UUID')

# Print the job log
drpcli jobs log $JOB

Parameter Report Across Machines

Bash
# Show a specific parameter value for every machine
drpcli machines list | jq -r \
  '.[] | [.Name, (.Params["my-param"] // "not-set")] | @tsv'

Scripting Tips

  • Set RS_ENDPOINT and RS_TOKEN (or RS_KEY) as environment variables so you do not need to pass flags on every call.
  • Use drpcli --format json (the default) and pipe to jq for the most flexibility.
  • For large environments, use server-side filters (drpcli machines list Stage=X) rather than client-side jq selects to reduce data transfer.
  • Combine drpcli with standard shell tools like sort, uniq -c, and column -t for quick summaries without writing full scripts.

See Basic Scripting for environment variable setup and scripting patterns.