Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokens for Notifications? #4344

Closed
2 tasks done
YouveGotMeowxy opened this issue Jan 8, 2024 · 4 comments
Closed
2 tasks done

Tokens for Notifications? #4344

YouveGotMeowxy opened this issue Jan 8, 2024 · 4 comments
Labels
area:notifications Everything related to notifications help

Comments

@YouveGotMeowxy
Copy link

⚠️ Please verify that this question has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

Is there a way to use a token when creating a notification?

Case Example:

I am adding a ton of docker containers to monitor and I want them all to use the same Gotify notification via Apprise.

I can either 1-by-1 manually add the same gotify://gotify/<token> to each one, and hand edit the "Friendly Name" to match each docker container, and set the below toggles to off so they don't affect all current, or new monitors, or do like this:

image

and it'll use whatever was entered into the Friendly Name field; and keep the toggles enabled so all new monitors automatically get the same notifications settings, with the name dynamically used via the token.

Apologies if this already exists, but I did a quick look through the docs and didn't see it.

📝 Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.11

💻 Operating System and Arch

Docker container

🌐 Browser

Brave

🐋 Docker Version

latest

🟩 NodeJS Version

No response

@larswmh
Copy link

larswmh commented Jan 9, 2024

Hey @YouveGotMeowxy,

I hope I've understood your issue correctly. You're not that far from the correct solution here.

The "Friendly Name" input field is just for how you want that notification to be called when it's listed on monitors, see here:
image

"Title" can be left empty, but feel free to put whatever you want in there. When a notification is sent to Gotify, the monitor name will be sent anyway. I've set this up in a test enviroment to check:
image

This way, you should easily be able to just create the monitors for your docker containers with that notification being set as default, without having to configure each monitors notification individually

@CommanderStorm CommanderStorm added the area:notifications Everything related to notifications label Jan 9, 2024
@CommanderStorm
Copy link
Collaborator

Sort of related #1323

I don't think that templating in the notification providers settings (!= send messages, this is tracked in #646) is a good idea, as the added complexity would just confuse users.

@larswmh a helptext should be added (discovering something via testing how it works is not ideal UX)

@YouveGotMeowxy
Instead of creating such monitors by hand, you might want to consider using third party tooling like https://pypi.org/project/uptime-kuma-api/ to automate this until we support either config tempaltes or templating for notifications

=> I am closing this as a duplicate. If I understood something wrong, please reopen ^^

@CommanderStorm CommanderStorm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
@YouveGotMeowxy
Copy link
Author

YouveGotMeowxy commented Jan 9, 2024

Hi guys,

All I really mean is not so much "templating", but simply having a few 'tokens' that get replaced with the text from the already entered fields in the Edit -> General section for a service. Technically yes, it's 'templating', but I don't really mean a complicated templating system; just a couple essentially search & replaces in the form of tokens.

for example:

if the above-mentioned fields contain:

friendly name: Bazaar
Server URL: https://bazarr.my.domain

then using the tokens:

%FRIENDLYNAME% and %URL% in the Notifications fields would replace the tokens with their respective text.

%FRIENDLYNAME% -> "Bazaar"

%URL% -> "https://bazarr.my.domain"

Then we would simply create 1 notification containing those tokens in their respective fields, and toggle the Default Enabled to On, and any new services created will automatically use the above in those fields.

image

(as also shown in the screenshot, the already created notifications have been manually created for each monitor. Every single one of those are exact clones, with the exception of me having to manually enter the same text as I entered in the Friendly Name and Server URL fields into the notification fields.
This seems like a lot of waste since they're all exact clones in terms of the Gotify token used, and also more minutiae/micro-managing than seems necessary, having to create tons of clones, manually copying and pasting into the Notification fields. Those clones would ALL be replaced with a single notification, since it would be using replacement tokens.)

In my case, I am using an auto-adder:

https://github.com/linuxserver/docker-mods/tree/swag-auto-uptime-kuma

So I when I add these labels to my docker compose:

    labels:
      swag.uptime-kuma.monitor.name: "Crowdsec"
      swag.uptime-kuma.monitor.url: "https://crowdsec.my.domain"

the notification would automatically use those in place of the tokens. Completely automating creating properly labeled notifications as well (the way we like them personalized), when the new monitor is added. :)

Other replacement tokens could be created as well as you all feel like adding, but in my case, those 2 would be plenty.

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Jan 10, 2024

just a couple essentially search & replaces

I don't see this as a maintainable solution going forward.
Such a solution would require additional work like #3414 (which also means breaking changes for our users) in the future.
I can't speak for the other maintainers, but I think we need not add bodges, which require more effort to fix in the future.

Have you asked the integration if this would be a configuration option that they could support for now?

Warning

Please be aware of these issues (both seem related as they both are triggered by removing a container) with the product you showed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:notifications Everything related to notifications help
Projects
None yet
Development

No branches or pull requests

3 participants