Query the dbt Cloud Semantic Layer GraphQL API to retrieve metric values with dimension breakdowns

domain: docs.getdbt.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Enable the dbt Semantic Layer in your dbt Cloud environment and obtain the Environment ID and a service token (or personal access token) from Account Settings in dbt Cloud
  2. Connect to the GraphQL API endpoint at https://semantic-layer.cloud.getdbt.com/api/graphql using the header Authorization: Bearer YOUR_SERVICE_TOKEN and the query parameter environmentId=YOUR_ENV_ID
  3. Introspect available metrics by sending the query { metrics(environmentId: YOUR_ENV_ID) { name description type } } to discover what metrics are defined in your semantic layer
  4. Query metric values with dimensions using the createQuery mutation to create a query, then poll queryResults with the returned queryId; the createQuery payload accepts metrics, groupBy, where, and orderBy fields
  5. Parse the paginated results from queryResults; as of 2025, paginated GraphQL endpoints for metadata queries are available to handle large manifests and avoid timeouts on environments with many models

Known gotchas

Related routes

Query dbt Semantic Layer metric history using the GraphQL queryRecords endpoint
docs.getdbt.com · 5 steps · unrated
Define a saved query in dbt MetricFlow YAML to standardize a commonly used metric + dimension combination for BI tool consumption
docs.getdbt.com · 5 steps · unrated
Write Loki LogQL queries using log pipeline stages and metric queries to extract and aggregate structured fields from logs
grafana.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans