Understanding the exposed metrics

Hello there!

I’ve just began to explore the Peertube metrics and I’d like to understand a little bit more how they work.

There’s the /api/v1/server/stats endpoint, the only metrics endpoint (isn’t it?). There you can find a lot of interesting metrics.
The question begs, how are those metrics generated and when?

  • The metrics are stored on the database and this endpoint just launches a query to the database?
  • The query updates the metrics somehow and gets them in real time?
  • Is a way to modify in some way the output of the metrics? (range, periodic execution, whatever)

As far as I’ve seen, it seems to update them every three hours, isn’t it? At least is what I’m able to see.

The changes I’ve seen every three hours are these. Since I’m new I only can post one image and two link, so I’ll just link a couple of them.

Thanks for your time.

Hello

Yes, for now. I was thinking adding another server in peertube, listening on localhost that could expose more « private » metrics.

Yes

No, they are generated on the fly by the database queries. But we have a cache in front of this endpoint of 4 hours.

There is the filter:api.server.stats.get.result plugin hook to update the result. But you can’t update the cache lifetime. Our cache just use the URL as key, so you can add fake parameters to bypass it. This is a little bit hacky, it’s the reason why I woudl prefer to develop an internal stat endpoint that would not have a cache.

It would be pretty cool to have more metrics, it would let the people understand, debug and report better the errors they see.
Also I agree about making the metrics somehow private. It would be nice to be able to use them from outside though, maybe under authentication and the admin role (or best one only for that).
Thanks for explaining it and for the hack to obtain real time metrics!