Find your first policy result
Find a policy result in the compliance dataset and identify the resource, policy, and evaluation context needed for investigation.
Before You Begin
- Obtain your organization's BigQuery export project ID and compliance dataset name. This documentation calls the dataset
ce; your actual name may differ. - Arrange query access as described in Configure BigQuery permissions for Compliance Engine.
- Confirm with your Technical Account Manager (TAM) that evaluation data is available for the policy you want to inspect.
Use Google Cloud Console's BigQuery SQL editor or your configured BigQuery query tool. This task reads existing evaluation data; it does not trigger a policy run or require a local repository clone.
Choose a Policy and Date Range
Choose a policy from the policy catalog or your organization's repository. Copy its full policy ID, including the leading slash. The example uses the AWS Support Role policy:
/ce/ca/aws/account/aws-support-role
Confirm that this policy has run in your environment, or replace the ID with one that has. The query starts with the previous seven days and returns up to 20 resources from the latest completed run within that window. This is not necessarily the latest run outside the selected period.
Query a First Result
-
Replace
YOUR_PROJECT.YOUR_CE_DATASETin both table paths with your export project and compliance dataset. -
Adjust
selected_policy_id,start_time, andend_timeif needed. The time window includes its start and excludes its end. -
Run the following GoogleSQL script:
DECLARE selected_policy_id STRING DEFAULT '/ce/ca/aws/account/aws-support-role';DECLARE end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP();DECLARE start_time TIMESTAMP DEFAULT TIMESTAMP_SUB(end_time, INTERVAL 7 DAY);WITH selected_run AS (SELECT policyId, policyName, runTime, snapshotTimeFROM `YOUR_PROJECT.YOUR_CE_DATASET.PolicyRun`WHERE policyId = selected_policy_idAND runTime >= start_timeAND runTime < end_timeAND completed = TRUEORDER BY runTime DESCLIMIT 1)SELECTpolicy_output.policyId,policy_run.policyName,policy_output.runTime,policy_run.snapshotTime,policy_output.object.id AS resource_id,policy_output.object.name AS resource_name,policy_output.object.typeApiName AS resource_type,policy_output.status,policy_output.statusDate,policy_output.currentStateMessage,policy_output.currentStateReferences,policy_output.remediationMessageFROM `YOUR_PROJECT.YOUR_CE_DATASET.PolicyOutput` AS policy_outputJOIN selected_run AS policy_runON policy_output.policyId = policy_run.policyIdAND policy_output.runTime = policy_run.runTimeWHERE policy_output.runTime >= start_timeAND policy_output.runTime < end_timeORDER BY policy_output.object.idLIMIT 20;
PolicyOutput records individual resource outcomes. Matching both policyId and runTime attaches the corresponding run context. The result limit bounds the displayed sample, not the bytes scanned.
Interpret the Result
Choose one returned row and inspect:
| Fields | What to Check |
|---|---|
policyId, policyName | Which requirement was evaluated. |
resource_id, resource_name, resource_type | Which resource was evaluated. Preserve the ID for further investigation. |
runTime, snapshotTime | When evaluation ran and when its input snapshot was taken. |
status, statusDate | The resource outcome and when that status last changed. |
currentStateMessage, currentStateReferences | The explanation and referenced configuration properties. |
remediationMessage | Guidance provided for resolving a violation. |
A completed run describes execution success; it does not mean every resource is compliant. Run statistics summarize outcomes, while each returned row describes one resource. See Policy statuses for status meanings.
If No Rows Are Returned
An empty result does not establish compliance. Check the project, dataset, exact policy ID, and time window. To see whether the policy has any runs in that period, use the same declarations and replace the main query with:
SELECT policyId, runTime, snapshotTime, completed, stats
FROM `YOUR_PROJECT.YOUR_CE_DATASET.PolicyRun`
WHERE policyId = selected_policy_id
AND runTime >= start_time
AND runTime < end_time
ORDER BY runTime DESC
LIMIT 10;
If runs exist but none completed, review execution details with your TAM. If a completed run has no resource results, inspect its counts and confirm the available inventory. If no runs appear, confirm policy availability and evaluation timing before expanding the date range.
Continue the Investigation
Keep the policy ID, resource ID, run time, and snapshot time with your investigation notes. Follow Review resource results for evidence and Remediate policy violations for the next steps when a resource is incompliant.
For reporting beyond this first query, see Query compliance data. The dataset also lists CeFindings and CeFindingsTrend views. Check their definitions in your export before using them; this walkthrough uses the documented base tables explicitly.