mirror of
https://github.com/restic/rest-server.git
synced 2026-04-04 17:21:32 -07:00
Add Prometheus metrics
Exposes a few metrics for Prometheus under /metrics if started with --prometheus.
Example:
# HELP rest_server_blob_read_bytes_total Total number of bytes read from blobs
# TYPE rest_server_blob_read_bytes_total counter
rest_server_blob_read_bytes_total{repo="test",type="data"} 2.13557024e+09
rest_server_blob_read_bytes_total{repo="test",type="index"} 1.198653e+06
rest_server_blob_read_bytes_total{repo="test",type="keys"} 5388
rest_server_blob_read_bytes_total{repo="test",type="locks"} 1975
rest_server_blob_read_bytes_total{repo="test",type="snapshots"} 10018
# HELP rest_server_blob_read_total Total number of blobs read
# TYPE rest_server_blob_read_total counter
rest_server_blob_read_total{repo="test",type="data"} 3985
rest_server_blob_read_total{repo="test",type="index"} 21
rest_server_blob_read_total{repo="test",type="keys"} 12
rest_server_blob_read_total{repo="test",type="locks"} 12
rest_server_blob_read_total{repo="test",type="snapshots"} 32
# HELP rest_server_blob_write_bytes_total Total number of bytes written to blobs
# TYPE rest_server_blob_write_bytes_total counter
rest_server_blob_write_bytes_total{repo="test",type="data"} 1.063726179e+09
rest_server_blob_write_bytes_total{repo="test",type="index"} 395586
rest_server_blob_write_bytes_total{repo="test",type="locks"} 1975
rest_server_blob_write_bytes_total{repo="test",type="snapshots"} 1933
# HELP rest_server_blob_write_total Total number of blobs written
# TYPE rest_server_blob_write_total counter
rest_server_blob_write_total{repo="test",type="data"} 226
rest_server_blob_write_total{repo="test",type="index"} 6
rest_server_blob_write_total{repo="test",type="locks"} 12
rest_server_blob_write_total{repo="test",type="snapshots"} 6
This commit is contained in:
committed by
Zlatko Čalušić
parent
526a2b3837
commit
ca0e09261f
6
mux.go
6
mux.go
@@ -8,6 +8,7 @@ import (
|
||||
goji "goji.io"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"goji.io/pat"
|
||||
)
|
||||
|
||||
@@ -19,6 +20,7 @@ var Config = struct {
|
||||
CPUProfile string
|
||||
Debug bool
|
||||
AppendOnly bool
|
||||
Prometheus bool
|
||||
}{
|
||||
Path: "/tmp/restic",
|
||||
Listen: ":8000",
|
||||
@@ -53,6 +55,10 @@ func NewMux() *goji.Mux {
|
||||
mux.Use(logHandler)
|
||||
}
|
||||
|
||||
if Config.Prometheus {
|
||||
mux.Handle(pat.Get("/metrics"), promhttp.Handler())
|
||||
}
|
||||
|
||||
mux.HandleFunc(pat.Head("/config"), CheckConfig)
|
||||
mux.HandleFunc(pat.Head("/:repo/config"), CheckConfig)
|
||||
mux.HandleFunc(pat.Get("/config"), GetConfig)
|
||||
|
||||
Reference in New Issue
Block a user