Back to Docs
Documentation

Custom Metrics

Define your own SQL-based metrics inside a private namespace, query them via REST or MCP, and export them as schema-v1 YAML.

Step 1

Workspace setup

Before creating metrics, name your workspace at /dashboard. Your workspace name becomes your metric namespace: custom.<name>.*

For example, a workspace named acmebank means all your custom metrics live under custom.acmebank.*. Workspace names must be lowercase, alphanumeric, and unique across the registry.

Step 2

Create a metric

Navigate to Dashboard → Custom Metrics → New metric and fill in the form:

  • Display name — human-readable title shown in search results
  • Description — what the metric measures and why it matters
  • Industry — free text (e.g. banking, insurance)
  • Category — optional grouping within the industry
  • SQL formula — use ${dataset} and ${column} template variables
  • Input table + columns — declare all datasets and columns consumed
  • Output column / type / unit — the result column the formula produces
  • Frequency — how often the metric is expected to be recalculated

Click Save to create the metric as a draft in your namespace.

Step 3

Query via REST API

Use your API key to retrieve your own metrics. Draft metrics are only visible to your organisation.

terminal
# Your own metrics (draft or published) — use your API key
curl https://api.metricregistry.co.uk/metrics/custom.acmebank.capital.my_metric \
  -H "Authorization: Bearer mrk_..."
Step 4

Query via MCP

Custom metrics are accessible through the MCP get_metric tool the same way as any registry metric. Your API key is your identity — draft metrics are visible only to your org.

mcp call
{
  "tool": "get_metric",
  "input": { "id": "custom.acmebank.capital.my_metric" }
}
Step 5

Export as YAML

Go to Dashboard → Custom Metrics and click the YAML ↓ button on any metric. This downloads a schema-v1 compatible YAML file ready to commit to Git. The file structure matches the MetricRegistry schema for consistency with the main registry.

Step 6

Publishing

Metrics start as draft— private to your organisation. Set status to published to make a metric visible to anyone with a valid API key.

Update the status via the dashboard toggle or the PUT /custom-metrics/{id} endpoint with "status": "published".

Reference

API reference

All custom metrics endpoints are authenticated with your API key.

MethodRouteDescription
POST/custom-metricsCreate a new custom metric
GET/custom-metricsList your custom metrics
GET/custom-metrics/{id}Get a single custom metric
PUT/custom-metrics/{id}Update display name, description, SQL, or status
DELETE/custom-metrics/{id}Delete a custom metric
PUT/orgSet workspace name

Next Steps

  • dbt Integration — Run metrics directly in your warehouse with the dbt package
  • API Reference — Full endpoint documentation with request/response schemas
  • Dashboard — Create and manage your custom metrics