prombolt

package module
v0.0.0-...-9b7adba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 3 Imported by: 22

README

prombbolt Build Status GoDoc Report Card

Package prombbolt provides a Prometheus metrics collector for bbolt databases. MIT Licensed.

Forked from https://github.com/mdlayher/prombolt to use the maintained bbolt library.

Usage

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

const name = "prombbolt.db"

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

// Register prombbolt handler with Prometheus
prometheus.MustRegister(prombbolt.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="prombboltd.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="prombboltd.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="prombboltd.db"} 1

FAQ

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

At this time, prombbolt 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.

Documentation

Overview

Package prombolt provides a Prometheus metrics collector for Bolt databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(name string, db *bolt.DB, blockedBuckets ...[]byte) prometheus.Collector

New creates a new prometheus.Collector that can be registered with Prometheus to scrape metrics from a Bolt database handle.

Name should specify a unique name for the collector, and will be added as a label to all produced Prometheus metrics.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL