mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 16:35:53 +02:00
[GH-ISSUE #210] Implement Prometheus /metrics endpoint to ntfy server #166
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#166
Loading…
Add table
Add a link
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?
Originally created by @rogeliodh on GitHub (Apr 11, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/210
I think it would be very useful to implement a /metrics endpoint to ntfy server so that we could monitor ntfy itself and get some statistics on the service
See https://prometheus.io/docs/guides/go-application/ for details, there is an official library for Go, so it should be relatively easy to integrate
one thing to notice is that "/metrics" is not reserved right now, so if there is a topic named "metrics" it would be a backwards incompatible change. If that is a problem, the endpoint could be moved to another path (ex: "system/metrics", "server/metrics", etc... )
@binwiederhier commented on GitHub (Apr 12, 2022):
I looked at your link and even briefly implemented it as a test (
github.com/binwiederhier/ntfy@3b1852541e). Unfortunately, I don't like it, because it brings in 7 new dependencies and outputs a very Prometheus specific format. I also can't really expose this on the public server because it gives away too much about the system and may be a security risk (maybe?).If it was easy to implement without a library, maybe. But even then I thought it was gonna be some custom JSON that I output, not the weird Prometheus format.
If people really really really want this I can be convinced otherwise, but I'm trying to protect the (already large) dependency tree.
Sample format:
@rogeliodh commented on GitHub (Apr 12, 2022):
fair enough!
about dependencies, there is an alternative library which, supposedly as I haven't used it, has less dependencies: https://github.com/VictoriaMetrics/metrics
about the endpoint being public, yes, I think it shoud be protected by some auth, or even published in another port
but let's wait to see if there are more users that want this feature :)
@mhameed commented on GitHub (Apr 29, 2022):
Hi,
I would also be interested in seeing ntfy prometheus metrics implemented.
I would also second the idea that the prometheus/victoria/openmetrics information would be served via a diffrent interface/port to the actual ntfy service.
Thanks.
@benisai commented on GitHub (Aug 4, 2022):
Interested in this
@genofire commented on GitHub (Aug 12, 2022):
Maybe we should implement /ready and /healthy eigther to run in a k8s.
@nicois commented on GitHub (Dec 21, 2022):
Victoria metrics looks like a good candidate. Adding a configuration option for the path, defaulting to undefined/off, should be sufficient here I believe. Nginx/Apache can use ACLs to prevent external hosts from reaching whatever endpoint is configured.
@genofire commented on GitHub (Dec 23, 2022):
https://github.com/binwiederhier/ntfy/issues/210#issuecomment-1095742026
I am missing metric here, like:
subscription_total{topic="x"}messages_total {topic="x"}For getting big topics based on subscription and message rate.
Maybe also a Histogramm of the time get and send to all reciever like:
delivery{le="+Inf", topic="x"}@binwiederhier commented on GitHub (Mar 7, 2023):
@rogeliodh @nicois @genofire @benisai @mhameed, and anyone else who is interested, what metrics would you like to see?
Here's my current WIP:
Here's my dabbling dashboard:
@genofire commented on GitHub (Mar 7, 2023):
Maybe for find big topics:
(Also on other metrics, based on
topic).@rogeliodh commented on GitHub (Mar 7, 2023):
I think adding
topiclabel is not a good idea because there could be thousands of topics and adding a high cardinality dimension to prometheus metrics is a bad practice.So I think original proposal is ok but I was wondering if they are enough to replicate the statistics you generate daily on the
statstopic:and I think we would be missing:
errortontfy_messages_published_failure(and firebase and emails metrics, too)for IPs I'm not really sure if ntfy could generate that stat...
for Clients... maybe change it to the "published" metric: add a
client_typelabel to allntfy_*_published_*metrics so we can get number of published messages per client type.I'm not sure about the last one. @binwiederhier should know better ;)
@xenrox commented on GitHub (Mar 9, 2023):
What about number of user registrations?
That could be useful for abuse prevention/detection.
@binwiederhier commented on GitHub (Mar 14, 2023):
I think I am content the way I have implemented this. I may add a few more metrics and then call it a day for now. We can always add more or change it later. The majority of work for me will be to Anisble-ize the Grafana+Prometheus installation.
@binwiederhier commented on GitHub (Mar 14, 2023):
The funniest thing: Apparently some other dependency had pulled in the prometheus client already, so this won't add any dependencies, whooo.
@binwiederhier commented on GitHub (Mar 15, 2023):
📢 Question around the
/metricsendpoint for Prometheus: Right now I have it so that if you configurelisten-metrics-http, it'll listen on a different IP/port for the metrics. But I feel like some people may want to just use the same interface potentially.Are there any best practices around this?
What I have:
I want to keep it simple, but flexible enough to be useful for everyone. Thoughts?
Plus, I don't want 100 different metrics config options...
@xenrox commented on GitHub (Mar 15, 2023):
Most of the services I scrape with Prometheus, expose their metrics on their default listening port under some variant of "/metrics".
As an example the following services handle it like that: keycloak, sourcehut, gitea, hedgedoc.
synapse is an example that supports both.
I personally prefer a simple "/metrics" on the normal port, but if that somehow does not work with ntfy because of conflicts with topics, a different port seems fine as well and does not really cause any annoyances for setups.
@binwiederhier commented on GitHub (Mar 15, 2023):
Thanks. I'll check them out tonight. It feels weird to me that these tools allow them to be publicly available. Metrics are sensitive information and can give attackers insight.
@xenrox commented on GitHub (Mar 15, 2023):
For sourcehut at least is it a design decision that everything around metrics/alerts is public, so that users can get a better grasp of what is going on.
Besides that, it is easy enough for sysadmins to protect the metrics with e.g. their reverse proxy.
Setting up basic auth, or only internal access (1 2) is pretty straightforward in nginx.
@binwiederhier commented on GitHub (Mar 16, 2023):
@xenrox Thanks again for the examples. They were great. I did this, and I think I like it:
The names are a bit weird, but they match the other variables. There is
enable-(reservations|login|..). It could belisten-metrics-httpto match the otherlisten-ones, but there's alsosmtp-listen-addr, so it's already inconsistent...@binwiederhier commented on GitHub (Mar 17, 2023):
This is done and will be in the next release.
@genofire commented on GitHub (Mar 18, 2023):
do you have an grafana dashboard for it? i like to make it part of my helm-chart
@binwiederhier commented on GitHub (Mar 19, 2023):
Here's one: https://cdn.discordapp.com/attachments/874398661709295629/1086744190312001556/ntfy-1679170350783.json
It's a WIP, and I'll add one to the docs once I think it's good enough.