mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 08:26:00 +02:00
[GH-ISSUE #724] Custom webhook converters for Grafana, GitHub, ... (was: pretty grafana notifications?) #531
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#531
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 @DoTheEvo on GitHub (May 13, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/724
Love ntfy.
For grafana it works, but shows just plain ugly json on its own.
I use Grafana-to-ntfy to make it look good.
But I just noticed that straight up on ntfy homepage demo pictures, theres pretty grafana notification. Did you use also grafana-to-ntfy to make it so, or is it build in and needs some enabling?
Feels kinda clunky to be running another container to get it working.
@binwiederhier commented on GitHub (May 19, 2023):
What you see there on the website is an "elaborate" fake 😄 It's not real.
I have Grafana alerts set up on my phone as well, and I get a giant JSON blob to ntfy and I hate it. However, if I start adding endpoints for one thing, everything under the sun now wants to add endpoints too: GitHub, Grafana, Prometheus, Uptime Kuma, all the things.
I suppose I could add a plugin-type thing that would allow incoming webhooks to be processed .... 🤔
@binwiederhier commented on GitHub (May 19, 2023):
Thinking out loud:
Thoughts:
e.g.
We could have built-in ones, and custom ones:
with scripts like this (e.g.
/etc/ntfy/converter.d/myconverter):FYI:
The biggest problem with this is that this would run a subshell for every incoming message that uses an external converter, which can easily blow up the server.
@binwiederhier commented on GitHub (May 19, 2023):
I guess we could use Go plugins (https://pkg.go.dev/plugin), though that would limit it to Go.
Or we could use an IPC approach using STDIN/STDOUT. PowerDNS uses that for its
remotebackend, and that scales quite well.A converter script would look like this. Reading messages on STDIN (one line per message, or whatever format we decide), and then output the converted message on STDOUT (in one line):
Here's an example usage (I manually typed the
{"alert"...}messags:The problem with that is that is not necessarily in our control how messages come in to ntfy. So if Grafana send the JSON as pretty-print the whole one line thing goes out the window. 🤔
@wunter8 commented on GitHub (May 19, 2023):
What about using a library like this? https://github.com/buger/jsonparser
It will let you specify a path to a specific value in the JSON object. And it does everything in Go. So you could set up a YAML config like this
Then you split the value of
titleandmessageat "." into a bytes array (slice?) and give it to jsonparser's getString command. It also supports a key like[0]for indexing into a list in the JSON object@binwiederhier commented on GitHub (May 30, 2023):
Just mentioning that I implemented a "templating approach" a while back here: #171 + #104
@skurfuerst commented on GitHub (Jun 2, 2023):
If you wanted to go further here, you could also check out https://github.com/hashicorp/go-plugin - this also might be useful.
All the best,
Sebastian
@skurfuerst commented on GitHub (Jun 2, 2023):
Btw I am unsure whether these kinds of conversions should happen in ntfy; or if this should be done e.g. in Caddy outside ntfy.