The query language (BQL)
How to ask Discover a question: the shape of a query, filters, dates, grouping, measures, and every thing you can ask about, with examples.
Discover answers questions about what you can see. You write a short query, or build it in the Builder, which writes the same text. Nobody writes SQL. A query only ever sees what you may see, so a query shared with you gives you the answer for your own access.
For the screen itself see Discover and Reports.
A first query
packages where categorization = MODERATE and authorization in (ATO, "ATO with conditions") countHow many Moderate packages hold an ATO, with or without conditions.
The shape of a query
A query says what to look at, then, in this order and each part optional:
what where <filter> group by <field> <measure> sort by <key> limit <n>- What is one of the things in the table below, for example
packagesorobligations. - where filters. Join tests with
andandor(andbinds first; use parentheses to change that), and usenotto turn a test around. - group by splits the answer into groups. Use at most two fields.
- A measure counts or adds:
count,sum(field),avg(field),min(field),max(field). - sort by orders the answer. limit caps the rows (1,000 unless you say otherwise, at most 5,000).
What you get depends on what you wrote:
| You wrote | You get |
|---|---|
Just the thing, maybe with where | A list of rows with the default columns. |
A measure, no group by | One row: a number. |
group by and a measure | One row per group. |
Tests in where
| Test | Example |
|---|---|
Compare: = != < <= > >= | days_left < 90 |
In a list: in (a, b) or not in | authorization in (ATO, IATT) |
Is empty: is empty, is not empty | poam_number is empty |
| Contains text | title contains "credentials" |
- Words and enum values are case-insensitive. A value with spaces goes in quotes.
- An enum accepts its key or its label:
ato_conditionsand"ATO with conditions"are the same. - A field with no value is never equal to anything, and is always
!=.
Dates
Compare a date field with a date (2026-12-31), today, or a time from today: 30d (days),
12w (weeks), 6m (months), 1y (years). A minus means the past: -30d.
expires < 90dmeans before the day that is 90 days from now.decision_date > -1ymeans within the last year.
Grouping and measures
packages group by program_office countis packages per program office.packages group by area, standing countis standing per area, for a stacked bar.- Name a measure to sort by it:
count,sum_cat1_open,avg_days_left,min_expires(the function, an underscore, and the field with dots turned into underscores). - A grouped answer with no
sort byis ordered by its first measure, largest first. A date group is ordered by date.
What the answer looks like
Discover picks a chart for the shape of the answer: a number for a measure, a bar for one group, a stacked bar for two, a timeline for a date group, and a table for a list. You can switch among those that make sense.
What you can ask about
Every field has a short description in the Fields panel in Discover.
| Ask about | What it holds |
|---|---|
packages | ATO packages with their standing, posture and authorization. Fields include categorization, authorization, expires, days_left, standing, failing_checks, cat1_open, obligations_overdue, sca_team, source, recommendation. |
obligations | Open ConMon, condition, guidance, CTO and finding obligations: kind, state, due_on, days_until_due. |
findings | Assessment findings: severity, status, control, cci, poam_number, days_open. |
exceptions | Exception requests: status, check_title, expires_on, recommendation. |
decisions | Authorization decisions: decision, status, decision_date, termination_date, residual_risk. |
transfers | Packages moving between program offices. |
guidance | Guidance and CTOs: kind, status, effective_on, requires_acknowledgment. |
assessment_plans | SCA plans: status, start_on, end_on. |
assessment_reports | Reports and the SCA's recommendation: recommendation, residual_risk. |
controls | Each control of each native package: implementation_status, responsibility, family. |
poams and milestones | Native POA&Ms and their milestones: severity, status, scheduled_completion. |
artifacts | Files kept with packages: kind, versions, latest_uploaded. |
scans | Imported scan files: kind, scanned_at, hosts, cat1. |
iavm | The IAVMs each package's scans reference: iav_id, status, comply_by, hosts. |
iavm_notices | The notices of the bulletin in force: iav_id, type, title, comply_by. |
stig_coverage | The STIGs that apply to each asset: asset, benchmark, coverage, last_scan_at. |
hardware | The hardware inventory: name, asset_type, os_name, ip_addresses. |
software | The software inventory: name, version, end_of_support, days_to_end_of_support, installs. |
ports | Ports, protocols and services: port_start, protocol, boundary, ppsm_status. |
interconnections | Connections to other systems: connection_type, agreement, agreement_expires. |
Anything about a package is available from the other things with a package. prefix, for
example package.program_office or package.standing.
A dot reaches a related thing or a section: package.program_office, standing.compliance.
Examples
packages where standing = fail count
packages group by program_office count sort by count desc
packages group by area, standing count
packages where expires < 90d and expires >= today sort by expires
packages where cat1_open > 0 sum(cat1_open)
packages where authorization = ato avg(days_left), min(expires)
packages where transferred = true count
obligations where state = overdue group by package.program_office count
exceptions where status = approved and days_left < 30
decisions where status = draft
assessment_plans where status = submitted
guidance where kind = cto
iavm where status = overdue group by package count
software where days_to_end_of_support < 90 sort by days_to_end_of_support
ports where ppsm_status = unknown and boundary = external
stig_coverage where coverage = missing group by package countLimits and errors
- A query is at most 4,000 characters, 16 levels deep, and runs for at most 2 seconds. If it takes longer you are told to narrow it. You can run 30 in 10 seconds.
- A result holds up to 500 groups. A note says when more existed.
- A query that does not parse is refused with the line and column, a message in plain words
and the choices that would have been valid. For example:
Unknown field 'categorisation' on packages. Did you mean 'categorization'?
Saved queries and exports
A saved query is the text plus how to show it. It is private to you, or shared with a unit
so everyone at or below that unit can run it, always as themselves. Only the owner changes or
deletes it. Export CSV downloads a result. Text cells that start with =, +, - or @ are
prefixed with a quote so a spreadsheet does not run them as a formula.