https://github.com/jtaczanowski/go-graphite-client
Simple Golang graphite client
https://github.com/jtaczanowski/go-graphite-client
go golang graphite graphite-client
Last synced: 4 months ago
JSON representation
Simple Golang graphite client
- Host: GitHub
- URL: https://github.com/jtaczanowski/go-graphite-client
- Owner: jtaczanowski
- License: apache-2.0
- Created: 2019-02-05T16:26:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-04T10:44:28.000Z (about 4 years ago)
- Last Synced: 2025-08-14T07:40:23.792Z (10 months ago)
- Topics: go, golang, graphite, graphite-client
- Language: Go
- Size: 22.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-graphite-client [](https://travis-ci.org/jtaczanowski/go-graphite-client) [](https://coveralls.io/github/jtaczanowski/go-graphite-client?branch=master) [](https://goreportcard.com/report/github.com/jtaczanowski/go-graphite-client)
go-graphite-client - Simple Golang Graphite client which allows sending batches of metrics in single connection.
The optimal use of the library is to collect set of metrics for current minute in single ```map[string]float64```
and after that pass it to `Client.SendData()` method.
`Client.SendData()` method creates a new connection to Graphite server **every time it's called**
and pushes all metric trough it.
Example usage (taken from `example_text.go`)
```go
package main
import (
"log"
graphite "github.com/jtaczanowski/go-graphite-client"
)
func Example() {
graphiteClient := graphite.NewClient("localhost", 2003, "metrics.prefix", "tcp")
// metrics map
metricsMap := map[string]float64{
"test_metric": 1234.1234,
"test_metric2": 12345.12345,
}
// append metrics from function which returns map[string]float64 as well
for k, v := range metricsGenerator() {
metricsMap[k] = v
}
// graphiteClient.SendData(data map[string]float64) error - this method expects a map of metrics as an argument
if err := graphiteClient.SendData(metricsMap); err != nil {
log.Printf("Error sending metrics: %v", err)
}
}
func metricsGenerator() map[string]float64 {
return map[string]float64{
"test_metric4": 3.14159265359,
}
}
```