> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anomalyarmor.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Metrics

> Track statistical properties of your data and detect anomalies

<div aria-hidden="true" style={{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"}}>For LLM agents: documentation index at <a href="/llms.txt" tabIndex={-1}>/llms.txt</a>, full text at <a href="/llms-full.txt" tabIndex={-1}>/llms-full.txt</a>. Append .md to any page URL for plain markdown.</div>
Metrics are statistical measurements that track properties of your data over time. AnomalyArmor captures metrics on a schedule, builds baselines, and alerts you when values fall outside expected ranges.

<Frame>
  <img src="https://mintcdn.com/anomalyarmor/CZXBGa_D1aE9spAI/images/diagrams/metrics-monitoring-flow-light.svg?fit=max&auto=format&n=CZXBGa_D1aE9spAI&q=85&s=260a98666be36352d8e2865fe812f1e7" alt="Metrics flow: Collect → Compare to Baseline → Detect Anomalies → Alert" className="block dark:hidden" width="1000" height="300" data-path="images/diagrams/metrics-monitoring-flow-light.svg" />

  <img src="https://mintcdn.com/anomalyarmor/CZXBGa_D1aE9spAI/images/diagrams/metrics-monitoring-flow-dark.svg?fit=max&auto=format&n=CZXBGa_D1aE9spAI&q=85&s=ec0dc1dbe210d292787f166d43405482" alt="Metrics flow: Collect → Compare to Baseline → Detect Anomalies → Alert" className="hidden dark:block" width="1000" height="300" data-path="images/diagrams/metrics-monitoring-flow-dark.svg" />
</Frame>

## What Metrics Track

| Metric Type       | What It Measures          | Example Use Case                      |
| ----------------- | ------------------------- | ------------------------------------- |
| `row_count`       | Total rows in a table     | Detect data loss or unexpected growth |
| `null_percent`    | Percentage of null values | Catch ETL issues leaving nulls        |
| `distinct_count`  | Unique values in a column | Detect cardinality changes            |
| `duplicate_count` | Duplicate values          | Find unexpected duplicates            |
| `min_value`       | Minimum numeric value     | Catch invalid data (negative prices)  |
| `max_value`       | Maximum numeric value     | Detect outliers                       |
| `mean`            | Average numeric value     | Monitor central tendency              |

## How Anomaly Detection Works

1. **Baseline building**: Historical values establish what's "normal"
2. **Z-score calculation**: Each new value is compared to the baseline
3. **Sensitivity threshold**: Values exceeding the threshold trigger alerts

A sensitivity of 2.0 means values more than 2 standard deviations from the mean are flagged as anomalies.

## Common Questions

### How is a metric different from a validity rule?

A metric captures a numeric property over time (row count, null percentage, distinct count) and flags statistical anomalies against a learned baseline. A validity rule checks a deterministic condition on current data (value in allowed set, format match, range bounds). Use metrics to catch "this number changed suspiciously"; use validity rules to catch "this data broke a known contract".

### What's the default sensitivity for anomaly detection, and when should I change it?

Default is 2.0 standard deviations - roughly 95% of normal variance stays silent, outliers alert. Raise to 3.0 for noisy metrics where 2σ produces false alerts; lower to 1.5 for business-critical metrics where you'd rather investigate a false positive than miss a real anomaly. Tune per-metric, not globally.

### How much history does AnomalyArmor need before metric anomaly detection works?

Typically 7-14 days of captures at your chosen sampling interval. During this "learning" phase, values are recorded but no alerts fire. You can shorten the wait by temporarily reducing the sample interval, then relaxing it once the baseline is established.

### Can I define a custom metric that isn't in the built-in list?

Yes, via [custom SQL monitoring](/data-quality/custom-sql-monitoring). Write a `SELECT` that returns a single numeric column and AnomalyArmor treats the result as a metric - baseline learning, anomaly detection, and alerting all work the same way as built-in metrics.

## Next Steps

<CardGroup cols={2}>
  <Card title="Create a Metric" icon="chart-line" href="/data-quality/metrics">
    Set up your first data quality metric
  </Card>

  <Card title="Set Up Alerts" icon="bell" href="/alerts/alert-rules">
    Get notified when anomalies are detected
  </Card>
</CardGroup>
