diff --git a/pkg/observe/aleph.go b/pkg/observe/aleph.go index 215f0a6..83b7c5f 100644 --- a/pkg/observe/aleph.go +++ b/pkg/observe/aleph.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "github.com/parnurzeal/gorequest" + "github.com/prometheus/client_golang/prometheus" ) type AlephStage struct { @@ -41,6 +42,8 @@ type AlephStatus struct { } func GetAlephStatus(host string, token string, skipTLS bool) ([]error, string) { + timer:= prometheus.NewTimer(requestDurationMetric) + defer timer.ObserveDuration() request := gorequest.New() _, body, err := request.Get(host). Set("Authorization", "ApiKey "+token). diff --git a/pkg/observe/metrics.go b/pkg/observe/metrics.go index 6c7d1f3..04f79ca 100644 --- a/pkg/observe/metrics.go +++ b/pkg/observe/metrics.go @@ -28,6 +28,11 @@ var ( "hostname", }, ) + requestDurationMetric = prometheus.NewHistogram(prometheus.HistogramOpts{ + Name: "aleph_http_request_duration_seconds", + Help: "Histogram for the runtime of the request to the aleph api", + Buckets: prometheus.LinearBuckets(0.01,0.01,10), + }) ) // RegisterPrometheus adds the prometheus handler to the mux router