Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/x-punch/micro-prometheus
Micro plugin, prometheus metrics.
https://github.com/x-punch/micro-prometheus
Last synced: about 1 month ago
JSON representation
Micro plugin, prometheus metrics.
- Host: GitHub
- URL: https://github.com/x-punch/micro-prometheus
- Owner: x-punch
- License: apache-2.0
- Created: 2020-06-16T06:51:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T03:50:39.000Z (over 3 years ago)
- Last Synced: 2024-06-21T15:51:14.796Z (6 months ago)
- Language: Go
- Size: 52.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Micro Prometheus
Go Micro monitoring plugin, export prometheus metrics through target address.## Usage
```go
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)
}
}
```
```shell
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.
```