---
title: Metrics
description: Metrics protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Metrics Protocol - Performance and Operational Metrics

Comprehensive metrics collection and monitoring:

- Counter, Gauge, Histogram, Summary metric types

- Time-series data collection

- SLI/SLO definitions

- Metric aggregation and export

- Integration with monitoring systems (Prometheus, etc.)

<Callout type="info">
**Source:** `packages/spec/src/system/metrics.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { HistogramBucketConfig, MetricAggregationConfig, MetricAggregationType, MetricDataPoint, MetricDefinition, MetricExportConfig, MetricLabels, MetricType, MetricUnit, ServiceLevelObjective, TimeSeries, TimeSeriesDataPoint } from '@objectstack/spec/system';
import type { HistogramBucketConfig, MetricAggregationConfig, MetricAggregationType, MetricDataPoint, MetricDefinition, MetricExportConfig, MetricLabels, MetricType, MetricUnit, ServiceLevelObjective, TimeSeries, TimeSeriesDataPoint } from '@objectstack/spec/system';

// Validate data
const result = HistogramBucketConfig.parse(data);
```

---

## HistogramBucketConfig

Histogram bucket configuration

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **type** | `Enum<'linear' \| 'exponential' \| 'explicit'>` | ✅ | Bucket type |
| **linear** | `Object` | optional |  |
| **exponential** | `Object` | optional |  |
| **explicit** | `Object` | optional |  |


---

## MetricAggregationConfig

Metric aggregation configuration

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **type** | `Enum<'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| 'p50' \| 'p75' \| 'p90' \| 'p95' \| 'p99' \| 'p999' \| 'rate' \| 'stddev'>` | ✅ | Aggregation type |
| **window** | `Object` | optional |  |
| **groupBy** | `string[]` | optional | Group by label names |
| **filters** | `Record<string, any>` | optional | Filter criteria |


---

## MetricAggregationType

Metric aggregation type

### Allowed Values

* `sum`
* `avg`
* `min`
* `max`
* `count`
* `p50`
* `p75`
* `p90`
* `p95`
* `p99`
* `p999`
* `rate`
* `stddev`


---

## MetricDataPoint

Metric data point

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Metric name |
| **type** | `Enum<'counter' \| 'gauge' \| 'histogram' \| 'summary'>` | ✅ | Metric type |
| **timestamp** | `string` | ✅ | Observation timestamp |
| **value** | `number` | optional | Metric value |
| **labels** | `Record<string, string>` | optional | Metric labels |
| **histogram** | `Object` | optional |  |
| **summary** | `Object` | optional |  |


---

## MetricDefinition

Metric definition

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Metric name (snake_case) |
| **label** | `string` | optional | Display label |
| **type** | `Enum<'counter' \| 'gauge' \| 'histogram' \| 'summary'>` | ✅ | Metric type |
| **unit** | `Enum<'nanoseconds' \| 'microseconds' \| 'milliseconds' \| 'seconds' \| 'minutes' \| 'hours' \| 'days' \| 'bytes' \| 'kilobytes' \| 'megabytes' \| 'gigabytes' \| 'terabytes' \| 'requests_per_second' \| 'events_per_second' \| 'bytes_per_second' \| 'percent' \| 'ratio' \| 'count' \| 'operations' \| 'custom'>` | optional | Metric unit |
| **description** | `string` | optional | Metric description |
| **labelNames** | `string[]` | ✅ | Label names |
| **histogram** | `Object` | optional | Histogram bucket configuration |
| **summary** | `Object` | optional |  |
| **enabled** | `boolean` | ✅ |  |


---

## MetricExportConfig

Metric export configuration

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **type** | `Enum<'prometheus' \| 'openmetrics' \| 'graphite' \| 'statsd' \| 'influxdb' \| 'datadog' \| 'cloudwatch' \| 'stackdriver' \| 'azure_monitor' \| 'http' \| 'custom'>` | ✅ | Export type |
| **endpoint** | `string` | optional | Export endpoint |
| **interval** | `integer` | ✅ |  |
| **batch** | `Object` | optional |  |
| **auth** | `Object` | optional |  |
| **config** | `Record<string, any>` | optional | Additional configuration |


---


---

## MetricType

Metric type

### Allowed Values

* `counter`
* `gauge`
* `histogram`
* `summary`


---

## MetricUnit

Metric unit

### Allowed Values

* `nanoseconds`
* `microseconds`
* `milliseconds`
* `seconds`
* `minutes`
* `hours`
* `days`
* `bytes`
* `kilobytes`
* `megabytes`
* `gigabytes`
* `terabytes`
* `requests_per_second`
* `events_per_second`
* `bytes_per_second`
* `percent`
* `ratio`
* `count`
* `operations`
* `custom`


---

## ServiceLevelObjective

Service Level Objective

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | SLO name (snake_case) |
| **label** | `string` | ✅ | Display label |
| **description** | `string` | optional | SLO description |
| **sli** | `string` | ✅ | SLI name |
| **target** | `number` | ✅ | Target percentage |
| **period** | `Object` | ✅ | Time period |
| **errorBudget** | `Object` | optional |  |
| **alerts** | `Object[]` | ✅ |  |
| **enabled** | `boolean` | ✅ |  |


---

## TimeSeries

Time series

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **name** | `string` | ✅ | Series name |
| **labels** | `Record<string, string>` | optional | Series labels |
| **dataPoints** | `Object[]` | ✅ | Data points |
| **startTime** | `string` | optional | Start time |
| **endTime** | `string` | optional | End time |


---

## TimeSeriesDataPoint

Time series data point

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **timestamp** | `string` | ✅ | Timestamp |
| **value** | `number` | ✅ | Value |
| **labels** | `Record<string, string>` | optional | Labels |


---

