ObjectStackObjectStack

Metrics

Metrics protocol schemas

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.)

Source: packages/spec/src/system/metrics.zod.ts

TypeScript Usage

import { HistogramBucketConfigSchema, MetricAggregationConfigSchema, MetricAggregationType, MetricDataPointSchema, MetricDefinitionSchema, MetricExportConfigSchema, MetricLabelsSchema, MetricType, MetricUnit, MetricsConfigSchema, ServiceLevelIndicatorSchema, ServiceLevelObjectiveSchema, TimeSeriesSchema, TimeSeriesDataPointSchema } from '@objectstack/spec/system';
import type { HistogramBucketConfig, MetricAggregationConfig, MetricAggregationType, MetricDataPoint, MetricDefinition, MetricExportConfig, MetricLabels, MetricType, MetricUnit, MetricsConfig, ServiceLevelIndicator, ServiceLevelObjective, TimeSeries, TimeSeriesDataPoint } from '@objectstack/spec/system';

// Validate data
const result = HistogramBucketConfigSchema.parse(data);

HistogramBucketConfig

Histogram bucket configuration

Properties

PropertyTypeRequiredDescription
typeEnum<'linear' | 'exponential' | 'explicit'>Bucket type
linear{ start: number; width: number; count: integer }optional
exponential{ start: number; factor: number; count: integer }optional
explicit{ boundaries: number[] }optional

MetricAggregationConfig

Metric aggregation configuration

Properties

PropertyTypeRequiredDescription
typeEnum<'sum' | 'avg' | 'min' | 'max' | 'count' | 'p50' | 'p75' | 'p90' | 'p95' | 'p99' | 'p999' | 'rate' | 'stddev'>Aggregation type
window{ size: integer; sliding: boolean; slideInterval?: integer }optional
groupBystring[]optionalGroup by label names
filtersRecord<string, any>optionalFilter 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

PropertyTypeRequiredDescription
namestringMetric name
typeEnum<'counter' | 'gauge' | 'histogram' | 'summary'>Metric type
timestampstringObservation timestamp
valuenumberoptionalMetric value
labelsRecord<string, string>optionalMetric labels
histogram{ count: integer; sum: number; buckets: object[] }optional
summary{ count: integer; sum: number; quantiles: object[] }optional

MetricDefinition

Metric definition

Properties

PropertyTypeRequiredDescription
namestringMetric name (snake_case)
labelstringoptionalDisplay label
typeEnum<'counter' | 'gauge' | 'histogram' | 'summary'>Metric type
unitEnum<'nanoseconds' | 'microseconds' | 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'bytes' | 'kilobytes' | 'megabytes' | 'gigabytes' | 'terabytes' | … +8 more>optionalMetric unit
descriptionstringoptionalMetric description
labelNamesstring[]Label names
histogram{ type: Enum<'linear' | 'exponential' | 'explicit'>; linear?: object; exponential?: object; explicit?: object }optionalHistogram bucket configuration
summary{ quantiles: number[]; maxAge: integer; ageBuckets: integer }optional
enabledboolean

Allowed Values: MetricDefinition.unit

  • 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

MetricExportConfig

Metric export configuration

Properties

PropertyTypeRequiredDescription
typeEnum<'prometheus' | 'openmetrics' | 'graphite' | 'statsd' | 'influxdb' | 'datadog' | 'cloudwatch' | 'stackdriver' | 'azure_monitor' | 'http' | 'custom'>Export type
endpointstringoptionalExport endpoint
intervalinteger
batch{ enabled: boolean; size: integer }optional
auth{ type: Enum<'none' | 'basic' | 'bearer' | 'api_key'>; username?: string; password?: string; token?: string; … }optional
configRecord<string, any>optionalAdditional configuration

MetricLabels

Metric labels

Type: Record<string, string>


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

MetricsConfig

Metrics configuration

Properties

PropertyTypeRequiredDescription
namestringConfiguration name (snake_case, max 64 chars)
labelstringDisplay label
enabledbooleanoptional
metrics{ name: string; label?: string; type: Enum<'counter' | 'gauge' | 'histogram' | 'summary'>; unit?: Enum<'nanoseconds' | 'microseconds' | 'milliseconds' | 'seconds' | 'minutes' | … +15 more>; … }[]optional
defaultLabelsRecord<string, string>optionalMetric labels
aggregations{ type: Enum<'sum' | 'avg' | 'min' | 'max' | 'count' | 'p50' | 'p75' | 'p90' | 'p95' | 'p99' | … +3 more>; window?: object; groupBy?: string[]; filters?: Record<string, any> }[]optional
slis{ name: string; label: string; description?: string; metric: string; … }[]optional
slos{ name: string; label: string; description?: string; sli: string; … }[]optional
exports{ type: Enum<'prometheus' | 'openmetrics' | 'graphite' | 'statsd' | 'influxdb' | 'datadog' | … +5 more>; endpoint?: string; interval?: integer; batch?: object; … }[]optional
collectionIntervalintegeroptional
retention{ period?: integer; downsampling?: object[] }optional
cardinalityLimits{ maxLabelCombinations?: integer; onLimitExceeded?: Enum<'drop' | 'sample' | 'alert'> }optional

ServiceLevelIndicator

Service Level Indicator

Properties

PropertyTypeRequiredDescription
namestringSLI name (snake_case)
labelstringDisplay label
descriptionstringoptionalSLI description
metricstringBase metric name
typeEnum<'availability' | 'latency' | 'throughput' | 'error_rate' | 'saturation' | 'custom'>SLI type
successCriteria{ threshold: number; operator: Enum<'lt' | 'lte' | 'gt' | 'gte' | 'eq'>; percentile?: number } | string | { dialect: Enum<'cel' | 'cron' | 'template'>; source?: string; ast?: any; meta?: object }Success criteria — structured or CEL predicate
window{ size: integer; rolling?: boolean }Measurement window
enabledbooleanoptional

ServiceLevelObjective

Service Level Objective

Properties

PropertyTypeRequiredDescription
namestringSLO name (snake_case)
labelstringDisplay label
descriptionstringoptionalSLO description
slistringSLI name
targetnumberTarget percentage
period{ type: Enum<'rolling' | 'calendar'>; duration?: integer; calendar?: Enum<'daily' | 'weekly' | 'monthly' | 'quarterly' | 'yearly'> }Time period
errorBudget{ enabled: boolean; alertThreshold: number; burnRateWindows?: object[] }optional
alerts{ name: string; severity: Enum<'info' | 'warning' | 'critical'>; condition: object }[]
enabledboolean

TimeSeries

Time series

Properties

PropertyTypeRequiredDescription
namestringSeries name
labelsRecord<string, string>optionalSeries labels
dataPoints{ timestamp: string; value: number; labels?: Record<string, string> }[]Data points
startTimestringoptionalStart time
endTimestringoptionalEnd time

TimeSeriesDataPoint

Time series data point

Properties

PropertyTypeRequiredDescription
timestampstringTimestamp
valuenumberValue
labelsRecord<string, string>optionalLabels

On this page