Add time-series metrics
to your app in 5 minutes
Minimal libraries for Ruby, Elixir, and Go. Drop into your existing app, configure your database driver, start tracking.
Get started in your language
Install, configure a driver, and start tracking. That's it.
# Gemfile
gem 'trifle-stats'
# config/initializers/trifle.rb
Trifle::Stats.configure do |c|
c.driver = Trifle::Stats::Driver::Postgres.new
c.granularities = ['10m', '1h', '1d']
end
# Track metrics
Trifle::Stats.track(
key: 'orders',
at: Time.now,
values: { count: 1, revenue: 99.0 }
)
# Query metrics
Trifle::Stats.values(
key: 'orders',
from: Time.now - 3600,
to: Time.now,
granularity: '1h'
)
# mix.exs
{:trifle_stats, "~> 0.1"}
# config/config.exs
config :trifle_stats,
driver: Trifle.Stats.Driver.Postgres,
granularities: ["10m", "1h", "1d"]
# Track metrics
Trifle.Stats.track("orders", DateTime.utc_now(), %{
count: 1,
revenue: 99.0
})
import "github.com/trifle-io/trifle-stats-go"
// Create driver and config
driver := trifle.NewSQLiteDriver("metrics.db")
config := trifle.NewConfig(driver, []string{"10m", "1h", "1d"})
// Track metrics
config.Track("orders", time.Now(), map[string]interface{}{
"count": 1,
"revenue": 99.0,
})
Database drivers
Use the database you already have. No new infrastructure required.
| Driver | Ruby | Elixir | Go |
|---|---|---|---|
| PostgreSQL | — | ||
| MongoDB | — | ||
| Redis | — | — | |
| SQLite | — | — |
Core concepts
Four building blocks. That's all you need to learn.
Keys
Namespace your metrics with string keys. Track 'orders', 'signups', or 'api::response_time'.
Values
Pass any hash of values. Numbers get summed automatically across time buckets.
Granularities
Configure time resolution: 1m, 10m, 1h, 6h, 1d, 1w. Data is stored at each level.
Hierarchical Data
Nest values for deep breakdowns: { country: { us: 1, uk: 1 }, channel: { web: 1 } }
Advanced features
Extend the default behavior when you need more control.
Designators
Custom time bucketing logic
Aggregators
Custom aggregation beyond sum
Transponders
Transform data on read
Formatters
Custom output formatting
Open source
Production-ready, battle-tested. MIT licensed.
Works standalone or as part of the platform
Use just the library, or pair with Trifle App and CLI for dashboards and terminal access.
Start tracking in 5 minutes
Pick your language and install the library.
$ gem install trifle-stats
$ mix deps.get
$ go get github.com/trifle-io/trifle-stats-go