Skip to content

x-punch/micro-prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Micro Prometheus

Go Micro monitoring plugin, export prometheus metrics through target address.

Usage

import (
	"github.com/asim/go-micro/v3"
	prometheus "github.com/x-punch/micro-prometheus/v3"
)

func main() {
	service := micro.NewService(micro.Name("go.micro.prometheus.testing"), micro.Version("1.0.0"))
	promOpts := []prometheus.Option{
		prometheus.ServiceID(service.Server().Options().Id),
		prometheus.ServiceName(service.Name()),
		prometheus.ServiceVersion(service.Server().Options().Version),
		prometheus.ListenAddress(":8080"),
	}
	prom := prometheus.NewPrometheus(promOpts...)
	microOpts := []micro.Option{
		micro.WrapHandler(prom.NewHandlerWrapper()),
		micro.WrapSubscriber(prom.NewSubscriberWrapper()),
	}
	service.Init(microOpts...)
	if err := service.Run(); err != nil {
		panic(err)
	}
}
curl http://:8080/metrics

Tips

When plugin created, it'll listen on http address(default :8080), if the port is not avaiable or other issues, you'll have an error, but the program'll still be running.

About

Micro plugin, prometheus metrics.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages