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

MeteoGroup/go-metrics-prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

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))
}()

Releases

No releases published

Packages

No packages published

Languages