#Backend

Metrics Board: Building an Agent-ready Metrics Layer

Metrics Board: Building an Agent-ready Metrics Layer
01

Summary

"From Weeks to Minutes!" How Pinterest Rebuilt its Unified Metrics Layer to Empower LLM-Driven Analytics Agents

Explore how Metrics Board leverages code-based declarations (YAML), automated Airflow orchestration, and ML-based anomaly detection to deliver bulletproof data insights.

This article outlines Pinterest's engineering journey in building 'Metrics Board', a modern semantic layer handling thousands of business metrics across petabyte-scale data lakes. By moving metric declarations directly to code, automating DAG setups, and running embedded monitoring checks, Pinterest solved chronic data-drift and quality challenges. Critically, Pinterest details how it exposed this semantic layer to conversational AI agents, giving a masterclass on enterprise-grade data governance in the LLM era.

  • 01Introduces Metrics-as-Code, where every metric exists as a declarative YAML spec under strict peer reviews, version controls, and schema checks.
  • 02Parses user SQL queries via sqlglot to dynamically render isolated Airflow DAGs with automatic upstream-ready monitoring.
  • 03Deploys a hybrid quality suite of rule-based thresholds and machine learning algorithms (Warden) to continuously inspect data anomalies.
  • 04Ensures zero-manual-wiring deployment to DataHub metadata registers, Helium experimentation platform, Superset dashboards, and StarRocks databases.
  • 05Implements a metric grading hierarchy (A+ down to Unknown) and dashboard tiering system to optimize resource retention and cluster scheduling.

RECOMMENDATION

An exceptional technical guide for data architects, analytical engineers, and AI developers who need to design reliable semantic layer architectures or ground LLM agents in verified enterprise definitions.

The Problem

Previously at Pinterest, data producers defined business metrics inside bespoke pipelines and manually connected them into reporting and experiment setups. This manual overhead degraded engineering velocity, led to inconsistent monitoring with downstream system failures, and triggered critical metadata drift with zero single source of truth.

The Solution

Pinterest built 'Metrics Board', a lightweight semantic layer that automates the entire downstream engineering lifecycle from a single declarative code block. It integrates five core pillars: code-based inventory (Git YAML specifications), dynamic compute engine (automatic Airflow DAG compilation), comprehensive automated quality checks, effortless publishing pipelines, and AI agent enablement via semantic model delivery.

The Result

The end-to-end cycle for creating and delivering metrics fell from several weeks to just 1-2 hours, saving two engineering-months on a high-profile engagement project. Today, over 98% of experimentation metrics leverage Metrics Board, and the platform implements an MCP server that empowers LLM-powered Analytics Agents to query enterprise databases securely using certified golden definitions.

Trade-off

Pinterest chose to prioritize developer velocity and team adoption by avoiding the forced adoption of a highly restrictive relational semantic model over existing raw datasets. While this design trade-off accommodated Pinterest's massive and messy raw database structures easily, it sacrificed the rigorous architectural alignment and safety constraints typically guaranteed by an enterprise semantic model.

03

Key Concepts

Concept · 01

Semantic Layer

A centralized middleware layer that decouples physical database structures from user-facing concepts to maintain single-truth business logic and metrics definitions across an entire enterprise.

  • Acts as a thin semantic wrapper on top of Pinterest's legacy analytics systems, consolidating fragmented metric tables without forced model migrations.
Concept · 02

Model Context Protocol (MCP)

An open-standard communication protocol designed to safely expose external context, schemas, and processing tools directly to modern LLM-driven software systems.

  • Exposes metadata from Metrics Board as machine-readable schemas, enabling Pinterest's Analytics Agent to perform accurate, automated SQL generations.
Concept · 03

Metrics-as-Code

A paradigm in data engineering where metrics are managed similarly to software applications: declared in declarative config files (such as YAML) and updated through standard CI/CD pipelines.

  • Ensures all metric files are versioned in Git, where user-friendly UI wizards automatically create the underlying configuration Pull Requests on their behalf.