Client for graphite web api. Full documentation with other examples could be found on godoc.
package main
import (
"github.com/lorehov/graphite-api-client""log""fmt"
)
funcmain() {
client, err:=NewFromString("https://my-graphite.tld")
iferr!=nil {
log.Fatalf("Couldn't parse url")
}
res, err:=client.QueryRender(
RenderRequest{
From: time.Unix(1468339853, 0),
Until: time.Unix(1568339853, 0),
MaxDataPoints: 1000,
Targets: []string{"main"},
},
)
iferr!=nil {
log.Fatalf("Error %s while performing query %s", err.Error(), err.Query)
}
for_, series:=rangeres {
fmt.Printf("Processing target %s", series.Target)
for_, dp:=rangeseries.Datapoints {
fmt.Printf("Datapoint %+v", dp)
}
}
}