SQL Console | CloudQuery

The SQL Console lets you run ClickHouse SQL queries directly against your synced cloud data. Use it for ad-hoc analysis, cross-table joins, aggregations, and any query that goes beyond the Asset Inventory search syntax.

The SQL Console is read-only. You can query data but cannot modify it, or create tables or views.

Table Browser

The left sidebar lists all available tables, organized into two sections:

  • Asset Inventory Tables: normalized tables that provide a consistent schema across all cloud resources, regardless of the source provider
  • Integration Tables: the raw tables synced from each integration, reflecting the exact schema from the provider’s API

Expand any table to see its columns and data types. Click a column name to insert it into the query editor.

Running a Query

Queries use ClickHouse SQL syntax. Type your query in the editor and press the Run Query button or use the keyboard shortcut:

ActionShortcut
Run queryCtrl+Enter / Cmd+Enter

The editor provides autocomplete for table names and column names as you type.

Example: Find Unassigned EC2 Images

This query joins aws_ec2_images with aws_ec2_instances to find AMIs not attached to any instance:

SELECT
    img.image_id,
    inst.image_id as ec2_image, -- should all be NULL to show unassigned
    img.name,
    img.creation_date,
    img.state,
    img.tags
FROM
    aws_ec2_images img
LEFT JOIN
    aws_ec2_instances inst ON inst.image_id = img.image_id
WHERE
    inst.image_id IS NULL -- AMIs not associated with any EC2 instance
    AND img.state = 'available'
    AND img.creation_date <= NOW() - INTERVAL 30 DAY
ORDER BY
    img.creation_date ASC;

Results appear in a table below the editor.

SQL Console displaying query results in a table below the query editor after running a query SQL Query Results

If a query returns more than 100 rows, the results are automatically paged.

Inspecting Results

Click any cell in the results table to open the Cell Inspection sidebar. This is useful for exploring complex JSON objects or copying individual values.

Cell Inspection view with a complex JSON object

Cell Inspection view with a complex JSON object

Understanding the Data

Integration tables map directly to the provider’s API endpoints. The data is not transformed. To understand a table’s schema and where its data comes from, look it up on CloudQuery Hub. For example, the AWS EC2 Instances table documentation shows the columns, types, and the underlying AWS API.

For query ideas and worked examples, see the tutorials on the CloudQuery blog.

Saved Queries

Save frequently used queries by clicking Save after writing a query. Saved queries can be:

  • Accessed from the Saved queries panel in the top right of the SQL Console
  • Tagged for organization
  • Shared with your team
  • Managed via the REST API
  • Configured with alerts to trigger notifications when they return results

You do not need to save a query before running it. The editor works for ad-hoc queries too.

Query Examples

For practical examples of security, compliance, and FinOps queries, see the query examples section.

  • Asset Inventory: browse and search resources without writing SQL
  • Historical Snapshots: query point-in-time snapshots of your tables for trend analysis
  • Reports: turn SQL queries into persistent visualizations and dashboards
  • Policies: use SQL queries as detective controls that evaluate after every sync
  • Alerts: trigger notifications when a saved query returns results
  • AI Query Writer: describe what you want in natural language and get a SQL query

Next Steps