Skip to content

LasseJacobs/go-metrics-prometheus

Repository files navigation

Prometheus

This is a reporter for the go-metrics that will posts metrics to Prometheus.

Note: this codebase is very young and might contain bugs.

Why use this module?

It is a very minimal module with no external dependencies other that the go-metrics module. This module does not require the standard Prometheus go client which itself is quite a large module containing lots of other code not related to exposing metrics to Prometheus.

This module is quite small so feel free to internalize it into your codebase and adjust it to your needs.

Usage

import "github.com/rcrowley/go-metrics"
import "github.com/LasseJacobs/go-metrics-prometheus"

http.Handle("/metrics", prometheus.MakePrometheusHandler(nil, nil))

fmt.Printf("Starting server at port 8080\n")
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}

See example/simple-server for a full working example. Alternatively you can run docker-compose up --build, this will start a test web-app that exposes some metrics, and a prometheus server that will monitor these metrics.

By supplying nil to the MakePrometheusHandler the default metrics registry will be used.

You can verify that it is working by going to: localhost:8080/metrics. Note that if you do not expose any metrics, as is the case in this example, this page will be empty.

Install

go get -u github.com/LasseJacobs/go-metrics-prometheus

running go tidy might be required:

go mode tidy

About

Prometheus client reporter for go-metrics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published