# Trifle::Stats ## Content # Trifle::Stats [![Gem Version](https://badge.fury.io/rb/trifle-stats.svg)](https://rubygems.org/gems/trifle-stats) [![Ruby](https://github.com/trifle-io/trifle-stats/actions/workflows/ruby.yml/badge.svg?branch=main)](https://github.com/trifle-io/trifle-stats) `Trifle::Stats` is a Ruby library for tracking time-series metrics with pluggable drivers. ## What it does - Tracks counters and numeric payloads per key. - Reads back series by timeframe and granularity. - Supports drivers like Redis, Postgres, Mongo, and Process. ## Quick example ```ruby require 'redis' Trifle::Stats.configure do |config| config.driver = Trifle::Stats::Driver::Redis.new(Redis.new) config.granularities = ['1h', '1d'] config.time_zone = 'UTC' config.beginning_of_week = 'monday' end Trifle::Stats.track(key: 'event::uploads', at: Time.now.utc, values: { count: 1, duration: 3.2 }) from = Time.now.utc - 24 * 3600 stats = Trifle::Stats.values(key: 'event::uploads', from: from, to: Time.now.utc, granularity: '1h') ``` ## What to expect - `values` returns `{ at: [...], values: [...] }` for the bucketed series. - All leaf values must be numeric. - Driver choice controls persistence and performance. ## Next steps - [Installation](/trifle-stats-rb/installation) - [Configuration](/trifle-stats-rb/configuration) - [Getting Started](/trifle-stats-rb/getting_started) - [Usage](/trifle-stats-rb/usage) - [Drivers](/trifle-stats-rb/drivers)