https://github.com/kirill-scherba/pusher
Pusher send metrics to Prometheus Push Server using HTTP post request
https://github.com/kirill-scherba/pusher
go golang http prometheus prometheus-pushgateway
Last synced: about 19 hours ago
JSON representation
Pusher send metrics to Prometheus Push Server using HTTP post request
- Host: GitHub
- URL: https://github.com/kirill-scherba/pusher
- Owner: kirill-scherba
- License: bsd-3-clause
- Created: 2022-11-09T11:34:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-10T07:51:17.000Z (over 3 years ago)
- Last Synced: 2025-04-06T03:13:48.610Z (about 1 year ago)
- Topics: go, golang, http, prometheus, prometheus-pushgateway
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pusher
Pusher send metrics to Prometheus Push Server using http post request. This
package has not any external dependencies and use only standard go librarie.
[](https://godoc.org/github.com/kirill-scherba/pusher/)
[](https://goreportcard.com/report/github.com/kirill-scherba/pusher)
## Usage example
The sample code below show all this package capabilities. Just create new pusher
and send any methrics.
```go
// Initialize random
rand.Seed(time.Now().Unix())
// Get this host name
hostName, err := os.Hostname()
if err != nil {
log.Fatalln("can't get host name error: ", err)
}
// Create publisher
pusher := pusher.NewPusher("http://example.com:9091", "my_job", hostName)
// Push metrics every 15 seconds
for {
m, err := pusher.Push(
pusher.Metric("my_job_couner_2", rand.Float64()*10),
pusher.Metric("my_job_couner_3", rand.Float64()*10),
pusher.Metric("my_job_couner_4{label=\"val1\"}", rand.Float64()*100),
pusher.Metric("my_job_couner_4{label=\"val2\"}", rand.Float64()*100),
)
if err != nil {
log.Println("push error: ", err)
} else {
log.Println("push metrics:\n" + m)
}
time.Sleep(15 * time.Second)
}
```
You can find complete packets documentation at:
-----------------------
## Licence
[BSD](LICENSE)