FR: Metrics exporting #811
Labels
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Compliance
Continuwuity/Web Interface
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Merge
Merge/Manual
Merge/Squash
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
bob the builder
No milestone
No assignees
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
continuwuation/continuwuity#811
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
note we can't leave /metrics on by default as many people expose all routes on their continuwuity deployment
I guess there's potentially an option to open a second listener for metrics, so it can run in a separate thread on a different port? That would add complexity, but would replicate one of the (unintentionally?) useful features of the multiple listeners in Synapse.
Yeah, this and HTML web interface ones are the ones I'd like people to be able to put on separate interfaces, although at that point, it makes sense to separate federation endpoints, too. The challenge is giving that flexibility without introducing a bunch of complexity in configuration.
I think separating client and federation mainly risks complicating reverse proxy setup, which at the moment is one of our strengths - people coming from Synapse are often amazed at the simplicity of just forwarding everything to one port.
That said, it wouldn't be terribly difficult to provide example config for all the major reverse proxies to show how to handle the metrics endpoint securely, so maybe it would be easier overall to just keep everything on one port? 🤔
Yeah the simplest default situation is to have everything on one port under matrix.sub and have sub/.well_know/matrix forwarded to matrix.sub, and then have the reverse proxy block /metrics. The challenge is when people want to start putting the HTML auth pages under a different domain. I guess that probably counts as an extra feature that's not needed for the initial implementation though.
what about making the metrics endpoint restrict requests to local connections only?
I guess that would be possible, but it opens the doors to issues with misconfiguration or spoofing if we allow reading the IP from a header for reverse proxies.
We could also allow configuring basic authentication, as most Prometheus implementations support that
I’d like to suggest another pathway for exporting metrics: OpenTelemetry. Basically, since c10y already has some investment in it by way of allowing homeserver admins to send traces to an arbitrary OTLP-compliant receiver (as of v0.5.1, this includes both HTTP and gRPC), I think that simply sending metrics over the same “pipe” would both:
However, as Jade notes here, this might not work out as well for setups where services write logs/metrics/traces directly to specific (different) backends.
I'm thinking of working on this, what kinda metrics can people imagine they'd like to have? Off the top of my head i can imagine:
From asking in offtopic:
Other examples and ideas:
If jemalloc metrics are enabled, those should probably be exported too.
Thinking a bit loud about possible implementation: Creating a new
metricsservice (if one doesnt exist already) used for responding to metric requests. Other services can add hooks for their own metrics when called, and otherwise increment counters in the metric service itself? Unsure about exact implementation there.For when a request comes in to get metrics (on the
/metricsendpoint) I imagine the service uses the hooks to gather metrics from the other services instead of doing all that collection itself? And then returns whatever data was collected.If whatever frameworks we use implement some sort of metrics i might hook into that, otherwise I'll use something like the
prometheuscrate.Thoughts?
Afterthought: An advantage of the above method could be that any missing or problematic services wouldn't take down the rest of the services, as they simply wouldn't add the hooks (or they would error immediately) instead of a potential service trying to get data itself and failing and crashing the rest of the metric collector
Summing up some conversation from the dev room today (starting around here) for posterity:
Tools
Two main pathways here:
metrics-*directories; OTel is a CNCF graduated project and enjoys considerable adoption & contribution throughout the o11y ecosystem/industry as an agnostic standard under the auspices of the CNCF & thus the Linux Foundation - as such, OTel should be expected to stick around for quite a while. Users have plenty of options, open source and proprietary alike, for where to send & store OTel traces/metrics./metricsendpoint somewhere: This might be doable with the opentelemetry_prometheus crate.I currently maintain that of these, OpenTelemetry by OTLP would be the better choice, as it has stabler maintenance and o11y-community-wide uptake. However, as alluded to in the cons I wrote for Prometheus, I could ultimately make something work either way.
What to expose
References
Linked by s1lv3r earlier in this issue:
https://matrix.to/#/!c10y-fNiMx5ijtgGFibzPUfNs9hpQvnJYPTV-fD2KPk/%24Kxf_loQH8SBpUqnxm9zZvBJAlovDqDaWXMkIk2mVqHU?via=wolfgirl.pet&via=explodie.org&via=matrix.org
https://element-hq.github.io/synapse/latest/usage/administration/understanding_synapse_through_grafana_graphs.html
Others from today (h/t Nex):
https://grafana.i-am.nexus/public-dashboards/30de2946878045a796e8777691f3dd01
...which is in turn derived from: https://demo.thefifthfleet.net/metrics
Prometheus metrics exportingto FR: Prometheus metrics exportingCould someone please update the title to remove "Prometheus"? As evinced by the discussion history here, it's an open question whether Prometheus is the exposition method of choice.
FR: Prometheus metrics exportingto FR: Metrics exportingThis was implemented in #2282