Skip to content
tezvyn:
Menu

Design a Centralized Metrics Layer

Source: thenewstack.ioMediumHow cards are made

Design a Centralized Metrics Layer

This tests your grasp of data governance and creating a single source of truth. A good answer defines a semantic layer between the data warehouse and BI tools, centralizing metric definitions in code.

What's really being asked

Your understanding of data architecture beyond simple ETL. It assesses your ability to design a system that enforces consistency, promotes data governance, and scales organizationally. The interviewer wants to see if you can separate business logic from raw data storage and visualization, creating a 'single source of truth' for key business metrics.

The full answer

Four key components of a metrics layer, which sits between the data warehouse (like Snowflake or BigQuery) and consumption tools (like Tableau or Looker). First, a definition layer, where metrics are defined as code (e.g., in YAML or Python) and managed in Git. This makes changes reviewable and auditable. Second, a centralized metric catalog or registry that serves as a discoverable inventory of all metrics. Third, a query generation engine that translates a request for a metric (e.g., 'MAU') into the correct, optimized SQL for the underlying warehouse. Fourth, consumption interfaces, like REST/GraphQL APIs or JDBC/ODBC connectors, allowing any tool to query metrics by name, not by writing raw SQL.

The mistakes people make

Proposing to build a single 'golden dashboard.' This just moves the problem; it doesn't solve the underlying inconsistency in the logic used to populate that dashboard. Another red flag is suggesting only to create a new, pre-aggregated table (a data mart). This is inflexible to new dimensions (e.g., 'show me MAU by country') and doesn't create a reusable definition. Finally, just naming a tool like dbt or Looker without explaining the architectural principles is a weak answer. The key is the decoupling of the metric definition from its consumption.

What usually comes next

How would you handle slowly changing dimensions, like a user changing their country? How would you manage backfills if a metric definition changes? How would you drive adoption of this new layer across different teams? What's the performance trade-off of generating queries on the fly versus pre-calculating everything?

A concrete example

To define a 'Monthly Active User' (MAU), a team would commit a YAML file to a Git repository. It might look like: metric: mau; type: count_distinct; sql: user_id; filters: [event_timestamp > now() - 30d]; dimensions: [country, device_type]. When a dashboard requests 'MAU by country,' it calls the metrics layer API. The layer finds the mau definition, generates the SQL SELECT country, COUNT(DISTINCT user_id) FROM events WHERE event_timestamp > NOW() - INTERVAL '30 day' GROUP BY 1;, runs it against the warehouse, and returns the result. The dashboard never contains any SQL.

Interview question

A data team decides to implement a centralized metrics layer. What is the primary architectural problem this solution aims to address?

  • a.To centralize all business intelligence dashboards into one "golden dashboard" for executive reporting.
  • b.To replace existing BI tools with a new, more powerful visualization platform.
  • c.To decouple the definition of business metrics from their consumption, ensuring consistent logic across all tools.Correct
  • d.To provide a single, pre-aggregated data mart for all key business metrics, improving dashboard load times.
Why?

The core purpose of a centralized metrics layer is to establish a single source of truth for metric definitions, ensuring consistency by decoupling how metrics are defined from how they are consumed. This prevents inconsistencies that arise when different teams or tools implement the same metric with varying logic, which is not solved by simply creating a golden dashboard or a pre-aggregated data mart.

Just read this? Test yourself on what you have been reading.

Read the original → thenewstack.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on data architecture — each one lists the topics its interview covers.

See open roles