/prombolt

Package prombolt provides a Prometheus metrics collector for Bolt databases. MIT Licensed.

Primary LanguageGoMIT LicenseMIT

prombolt Build Status GoDoc Report Card

Package prombolt provides a Prometheus metrics collector for Bolt databases. MIT Licensed.

Usage

Instrumenting your application's Bolt database using prombolt is trivial. Simply wrap the database handle using prombolt.New and register it with Prometheus.

const name = "prombolt.db"

db, err := bolt.Open(name, 0666, nil)
if err != nil {
	log.Fatal(err)
}

// Register prombolt handler with Prometheus
prometheus.MustRegister(prombolt.New(name, db))

mux := http.NewServeMux()
mux.Handle("/", newHandler(db))
// Attach Prometheus metrics handler
mux.Handle("/metrics", prometheus.Handler())

http.ListenAndServe(":8080", mux)

At this point, Bolt metrics should be available for Prometheus to scrape from the /metrics endpoint of your service.

$ curl -s http://localhost:8080/metrics | grep "bolt" | head -n 9
# HELP bolt_bucket_buckets Number of buckets within a bucket, including the top bucket.
# TYPE bolt_bucket_buckets gauge
bolt_bucket_buckets{bucket="foo",database="promboltd.db"} 1
# HELP bolt_bucket_depth Number of levels in B+ tree for a bucket.
# TYPE bolt_bucket_depth gauge
bolt_bucket_depth{bucket="foo",database="promboltd.db"} 1
# HELP bolt_bucket_inlined_buckets Number of inlined buckets for a bucket.
# TYPE bolt_bucket_inlined_buckets gauge
bolt_bucket_inlined_buckets{bucket="foo",database="promboltd.db"} 1

FAQ

Q: can prombolt provide metrics for nested/child buckets?

At this time, prombolt is unable to retrieve metrics for nested/child buckets, because Bolt does not currently provide functionality to iterate nested/child buckets within a parent bucket. See boltdb/bolt#603.