diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-11-04 23:09:42 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-11-04 23:09:42 +0100 |
commit | 53ad91c63c2788a83d0e80985ffa89ce7cdf203f (patch) | |
tree | 33b7244bc0e7e036ecb411c2d6dfd2d2bc4f6c8c /metric.go | |
parent | 7fb24c41ec04d31d3170c9f26ebdbd6eb2ee5aa5 (diff) |
added prometheus metrics
Diffstat (limited to 'metric.go')
-rw-r--r-- | metric.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/metric.go b/metric.go new file mode 100644 index 0000000..7179458 --- /dev/null +++ b/metric.go @@ -0,0 +1,28 @@ +package stfe + +import ( + "sync" + + "github.com/google/trillian/monitoring" + "github.com/google/trillian/monitoring/prometheus" +) + +var ( + once sync.Once + reqcnt monitoring.Counter // number of incoming http requests + rspcnt monitoring.Counter // number of valid http responses + latency monitoring.Histogram // request-response latency + lastSdiTimestamp monitoring.Gauge // unix timestamp from the most recent sdi + lastSthTimestamp monitoring.Gauge // unix timestamp from the most recent sth + lastSthSize monitoring.Gauge // tree size of most recent sth +) + +func metricSetup() { + mf := prometheus.MetricFactory{} + reqcnt = mf.NewCounter("http_req", "number of http requests", "logid", "endpoint") + rspcnt = mf.NewCounter("http_rsp", "number of http requests", "logid", "endpoint", "status") + latency = mf.NewHistogram("http_latency", "http request-response latency", "logid", "endpoint", "status") + lastSthTimestamp = mf.NewGauge("last_sth_timestamp", "unix timestamp while handling the most recent sth", "logid") + lastSdiTimestamp = mf.NewGauge("last_sdi_timestamp", "unix timestamp while handling the most recent sdi", "logid") + lastSthSize = mf.NewGauge("last_sth_size", "most recent sth tree size", "logid") +} |