Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Latest commit

 

History

History
33 lines (25 loc) · 1.01 KB

README.md

File metadata and controls

33 lines (25 loc) · 1.01 KB

go-metrics-prometheus

This is a reporter for the go-metrics library which will post the metrics to the prometheus client registry. It just updates the registry, taking care of exporting the metrics is still your responsibility. It is based on https://github.com/deathowl/go-metrics-prometheus

Usage:

import (
  "github.com/prometheus/client_golang/prometheus/promhttp"
  "github.com/prometheus/client_golang/prometheus"
  metrics "github.com/rcrowley/go-metrics"
  promReg "github.com/MeteoGroup/go-metrics-prometheus"
  )

// create metrics registry
metricsRegistry := metrics.NewRegistry()
appGauge := metrics.GetOrRegisterGauge("m1", metricsRegistry)
appGauge.Update(1)

// register in prometheus
pClient := promReg.NewPrometheusProvider(metricsRegistry, "test", "subsys", 1*time.Second)
go pClient.UpdatePrometheusMetrics()

// export http for prometheus

go func() {
  http.Handle("/metrics", promhttp.HandlerFor(promClient.PromRegistry, promhttp.HandlerOpts{}))
  log.Fatal(http.ListenAndServe(":8080", nil))
}()