tree: 58325d4dc447079a2f880a1d9e3023316bc52011 [path history] [tgz]
  1. collector.go
  2. counter.go
  3. desc.go
  4. doc.go
  5. expvar.go
  6. fnv.go
  7. gauge.go
  8. go_collector.go
  9. histogram.go
  10. http.go
  11. metric.go
  12. process_collector.go
  13. push.go
  14. README.md
  15. registry.go
  16. summary.go
  17. untyped.go
  18. value.go
  19. vec.go
vendor/github.com/prometheus/client_golang/prometheus/README.md

Overview

This is the Prometheus telemetric instrumentation client Go client library. It enable authors to define process-space metrics for their servers and expose them through a web service interface for extraction, aggregation, and a whole slew of other post processing techniques.

Installing

$ go get github.com/prometheus/client_golang/prometheus

Example

package main

import (
	"net/http"

	"github.com/prometheus/client_golang/prometheus"
)

var (
	indexed = prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "my_company",
		Subsystem: "indexer",
		Name:      "documents_indexed",
		Help:      "The number of documents indexed.",
	})
	size = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "my_company",
		Subsystem: "storage",
		Name:      "documents_total_size_bytes",
		Help:      "The total size of all documents in the storage.",
	})
)

func main() {
	http.Handle("/metrics", prometheus.Handler())

	indexed.Inc()
	size.Set(5)

	http.ListenAndServe(":8080", nil)
}

func init() {
	prometheus.MustRegister(indexed)
	prometheus.MustRegister(size)
}

Documentation

GoDoc