Inventory

SQL over everything you run

Stategraph stores state as normalized tables in PostgreSQL. Every resource in every state answers to one query, and gap analysis finds what no state manages.

7,190 instances indexed Query across all states Live, not exported

Infrastructure as a Database

The inventory is the state

Schema

Your state is already a database

A state file is JSON you grep. Stategraph keeps resources, instances, states, providers, and cost snapshots in tables you can list with one command.

SQL inventory →
stategraph · sql schema
❯ stategraph sql schema resources(type,name,provider,module,…) instances(address,attributes,dependencies,…) states(name,workspace,created_at,…) providers cost_snapshots

Real output captured from a live Stategraph instance.

Query

Every state in one query

One question means stitching a dozen tfstate files. One SELECT spans every state and workspace, live, with nothing exported.

Query docs →
stategraph · query
❯ stategraph query "SELECT type, COUNT(*) FROM resources GROUP BY type ORDER BY COUNT(*) DESC LIMIT 8" type count kubernetes_role_binding 586 kubernetes_manifest 382 null_resource 317 kubernetes_service 175 google_kms_key_ring 166 google_kms_crypto_key 166 google_kms_secret 163 kubernetes_namespace 159 ❯ stategraph query "SELECT COUNT(*) FROM instances" count 7190

Real output captured from a live Stategraph instance.

Attributes

A compliance check is a WHERE clause

Every attribute of every instance is queryable JSONB. A public bucket, an instance type, or any other attribute is one filter across all states.

SQL syntax reference →
stategraph · query
-- Publicly readable S3 buckets across all states SELECT i.address, s.name AS state, i.attributes->>'region' AS region FROM instances AS i JOIN resources AS r ON i.resource_address = r.address AND i.state_id = r.state_id JOIN states AS s ON i.state_id = s.id WHERE r.type = 'aws_s3_bucket' AND i.attributes->>'acl' = 'public-read' address state region aws_s3_bucket.legacy_uploads production us-east-1 aws_s3_bucket.temp_storage staging us-west-2 aws_s3_bucket.public_assets production eu-west-1

Illustrative query and result.

Gap analysis

Find what no state manages

Part of the cloud was made in the console and never imported. Gap analysis compares your AWS or GCP account with your states and writes the import blocks and HCL for the rest.

Gap analysis docs →
stategraph · tenant gaps
# 1. List the AWS resources no state manages ❯ stategraph tenant gaps analyze --provider aws --format json \ | jq '.unmanaged_resources' > unmanaged.json # 2. Generate import blocks and HCL for them ❯ stategraph tenant gaps import unmanaged.json import { provider = aws.us_east_1 to = aws_s3_bucket.imported_orphaned_bucket id = "orphaned-bucket" } resource "aws_s3_bucket" "imported_orphaned_bucket" { bucket = "orphaned-bucket" # ... generated attributes }

Commands and output from the CLI reference. AWS and GCP today.

Dashboards

Save a query as a live view

A dashboard is a query you run often. Any query becomes a panel in the console, so inventory, cost, and ownership views need no glue code.

Dashboards docs →
Resources
1,345
↑ 12% this month
Compliance
94%
847 resources tagged
Unmanaged
23
Gap analysis
States
8
Across 3 workspaces
Resource growth (30 days)
+158 resources added
Resources by provider
AWS (847)GCP (342)Azure (156)

Illustrative. Each panel is a saved query.

Access

Console, API, or SQL

Instance explorer

Browse states and filter instances by type and state in the console, without writing SQL.

HTTP API

GET /api/v1/mql returns the same rows as JSON for your BI tool or scripts.

No export pipeline

Nothing to sync or schedule. The inventory is the state itself, read live.

Start Querying Your Infrastructure

Import your Terraform state files. Query resources with SQL. Understand your infrastructure in minutes.

Get started Read the docs