restic / rest-server

Rest Server is a high performance HTTP server that implements restic's REST backend API.
BSD 2-Clause "Simplified" License
978 stars 143 forks source link

`/metrics` should also provide repository stats #176

Open NobbZ opened 2 years ago

NobbZ commented 2 years ago

Output of rest-server --version

$ /nix/store/ikr0wfhq239s7s8l65b1bl0q53y213nr-restic-rest-server-0.10.0/bin/rest-server --version
rest-server 0.10.0 compiled with go1.16.9 on linux/amd64

What should rest-server do differently?

Currently the metrics reported in the /metrics endpoint are the default metrics for go programs and actually more about the runtime and process behavior, which is totally fine and important data, still it is missing the interesting things like number of users, number of repositories, size of them, user quotas, snapshots (per user/repo), etc

What are you trying to do? What is your use case?

I want to collect meaningful metrics about the repository.

wojas commented 2 years ago

It would be nice to have this extra data, but currently rest-server does not have all of this information and it could be expensive to collect from the spinnings disks that typically serve as the storage. It would be useful to have, but the implementation does require some careful consideration and we may want to make this opt-in.

When quota are enabled, we do keep track of the total size, but not per user or repo (see also #65).

There is also the issue of potentially leaking too much information. We probably want to move the /metrics to a different port for this reason (see also #116) and then this would not be an issue.

Gaibhne commented 2 years ago

Could also allow for a different .htaccess / password for the /metrics endpoint. 'Cheap' statistics should should be trivial to cache and would be extremely useful would be disk free space and repo disk size, so people could make simple alerts like 'disk about to run full'.

wojas commented 2 years ago

Adding simple disk usage and disk free space would be a good idea, indeed. It's cheap and does not leak sensitive information.