Minimal metrics for Go (counter/gauge/histogram). No dependencies. Compatible with expvar. Web UI included.
Switch branches/tags
Nothing to show
Clone or download
zserge implement totals for time series (#1)
better implementation of the rolling timelines

add histogram timeline test

remove test skip

remove temporary example comments
Latest commit 69b8d18 Oct 10, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
example use compressed screenshot May 23, 2018
.gitignore Initial commit May 23, 2018
.travis.yml add .travis.yml May 23, 2018
LICENSE Initial commit May 23, 2018 add readme and a screenshot May 23, 2018
go.mod add go.mod Oct 3, 2018
handler.go implement totals for time series (#1) Oct 10, 2018
metric.go implement totals for time series (#1) Oct 10, 2018
metric_test.go implement totals for time series (#1) Oct 10, 2018


Build Status GoDoc Go Report Card

Package provides simple uniform interface for metrics such as counters, gauges and histograms. It keeps track of metrics in runtime and can be used for some basic web service instrumentation in Go, where complex tools such as Prometheus or InfluxDB are not required.

It is compatible with expvar package, that is also commonly used for monitoring.


// Create new metric. All metrics may take time frames if you want them to keep
// history. If no time frames are given the metric only keeps track of a single
// current value.
c := metric.NewCounter("15m10s") // 15 minutes of history with 10 second precision
// Increment counter
// Return JSON with all recorded counter values
c.String() // Or json.Marshal(c)

// With expvar

// Register a metric
expvar.Publish("latency", metric.NewHistogram("5m1s", "15m30s", "1h1m"))
// Register HTTP handler to visualize metrics
http.Handle("/debug/metrics", metric.Handler(metric.Exposed))

// Measure time and update the metric
start := time.Now()

Metrics are thread-safe and can be updated from background goroutines.

Web UI

Nothing fancy, really, but still better than reading plain JSON. No javascript, only good old HTML, CSS and SVG.

web ui

Of course you may customize a list of metrics to show in the web UI.

If you need precise values - you may use /debug/vars HTTP endpoint provided by expvar.


Code is distributed under MIT license, feel free to use it in your proprietary projects as well.