Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.74 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "net/http"
  5.     "github.com/deathowl/go-metrics-prometheus"
  6.     "github.com/rcrowley/go-metrics"
  7.     "flag"
  8.     "time"
  9.  
  10.     "github.com/prometheus/client_golang/prometheus"
  11. )
  12.  
  13. var (
  14.     addr = flag.String("localhost", ":8181", "The address to listen on for HTTP requests.")
  15. )
  16.  
  17. func main() {
  18.  
  19.     metricsRegistry := metrics.NewRegistry()
  20.  
  21.     prometheusRegistry := prometheus.NewRegistry()
  22.  
  23.     c := metrics.NewCounter()
  24.  
  25.     metricsRegistry.Register("foo", c)
  26.  
  27.     c.Inc(1)
  28.  
  29.     pClient := prometheusmetrics.NewPrometheusProvider(metricsRegistry, "cpu.temperature.celsius", "subsysString", prometheusRegistry, 1*time.Second)
  30.     pClient.UpdatePrometheusMetrics()
  31.  
  32.     http.Handle("/metrics", prometheus.Handler())
  33.     http.ListenAndServe(*addr, nil)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement