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

Add notifications for changes to monitor messages #4865

Closed
wants to merge 5 commits into from

Conversation

Rudedog9d
Copy link

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Related to #432 (#432 is a full content check, but this atleast alerts on changes)

Type of change

Please delete any options that are not relevant.

  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

UI option for watching monitor messages:

image

Discord notifications including message field, and consecutive up messages representing the changed message.

image

@Rudedog9d
Copy link
Author

Rudedog9d commented Jun 18, 2024

@louislam I'm not sure if this will be something your interested in or not. The description / naming may need to change (both variables and UI). No hurt feelings if you don't think it's useful, but I think it could be a useful feature.

My main use case is watching DNS records, but I think it would work with a number of monitors. I didn't limit the UI option to any specific monitor, as I'm not sure which monitors change their "message" field without a status change.

I'm not sure if the isImportant methods were static for a specific reason, but the easiest way I found to check the watchChanges var was to change them to not static - it doesn't seem like they're used in many places, so I don't think it's a breaking change.

@Rudedog9d
Copy link
Author

Rudedog9d commented Jun 18, 2024

Oh, also worth noting - this change includes the msg field in Discord notifications aswell. I was testing with Discord so I added it, but it felt like a good addition?

I saw a comment in sendNotification that mentioned Discord, but then it wasn't used in Discord, so I wasn't sure what the history was there.

@CommanderStorm CommanderStorm added area:notifications Everything related to notifications type:enhance-existing feature wants to enhance existing monitor pr:needs review this PR needs a review by maintainers or other community members labels Jun 18, 2024
<div class="my-3 form-check">
<input id="monitor-change" v-model="monitor.watchChanges" class="form-check-input" type="checkbox">
<label class="form-check-label" for="monitor-change">
<!-- todo use the $t thing here -->
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ maintainers I'm not sure what the $t thing was or where it came from, so I left a TODO.

If the PR is something you'd consider accepting, what do I need to change to utilize that instead of hard-coding the descriptions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$t is a shorthand for a localised string.
It grabs the translation key provided in the $t("KEY") and looks it up here: https://github.com/louislam/uptime-kuma/blob/master/src/lang/en.json

Docs: https://vue-i18n.intlify.dev/

what do I need to change to utilize that instead of hard-coding the descriptions

Suggested change
<!-- todo use the $t thing here -->
{{ $t("Monitor Changes") }}

And then add the translation key Monitor Changes here https://github.com/louislam/uptime-kuma/blob/master/src/lang/en.json

the second point is nessesary as otherwise our awsome translators can't translate this.

Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a few comments below.

What I am torn about is if this is the best place to put this setting (if we add such a setting).
I think we could simplify the app by either adding it to the settings.

What I am also unsure if this is nessesary.
=> What is your inital motivation? Could you go further into this? #432 seems like a pretty faar strech and is something different.

To get #432, proposals like #3919 seem more promising and less of a testing nightmare to me. (remember that maintainers should test every combination of relevant settings)

* @returns {boolean} True if is an important beat else false
*/
static isImportantBeat(isFirstBeat, previousBeatStatus, currentBeatStatus) {
isImportantBeat(isFirstBeat, previousBeat, currentBeat) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refactor the function to remain static.
If it is static, this is better testable in the future than currently as static methods don't provide interiour mutability of the class.

Adding a parameter for this is fine.

<div class="my-3 form-check">
<input id="monitor-change" v-model="monitor.watchChanges" class="form-check-input" type="checkbox">
<label class="form-check-label" for="monitor-change">
<!-- todo use the $t thing here -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$t is a shorthand for a localised string.
It grabs the translation key provided in the $t("KEY") and looks it up here: https://github.com/louislam/uptime-kuma/blob/master/src/lang/en.json

Docs: https://vue-i18n.intlify.dev/

what do I need to change to utilize that instead of hard-coding the descriptions

Suggested change
<!-- todo use the $t thing here -->
{{ $t("Monitor Changes") }}

And then add the translation key Monitor Changes here https://github.com/louislam/uptime-kuma/blob/master/src/lang/en.json

the second point is nessesary as otherwise our awsome translators can't translate this.

@Rudedog9d
Copy link
Author

What I am also unsure if this is nessesary. => What is your inital motivation? Could you go further into this? #432 seems like a pretty faar strech and is something different.

My initial need was to monitor a TXT DNS record and verify when it's changed, related to ACME SSL certification validation.

If it was fully implemented, I could see myself adding several more DNS monitors for A records so I'm notified when a DNS entry changes - though I don't have any explicit need for it now.

To get #432, proposals like #3919 seem more promising and less of a testing nightmare to me. (remember that maintainers should test every combination of relevant settings)

Yea, I totally get that - and a change that affects everything like this adds ton of testing.

I was able to build a docker image locally for my needs, and I'm happy to continue using a dedicated custom-built instance for just the DNS monitors I need. I can't imagine this will be a widely used feature, and #3919 would also solve my TXT problem long-term with a far more robust solution. (It would require updating the content check with every change, but that's okay for such an edge case IMO).

Your other comments make sense, but I'll hold off implementing unless you explicitly say you're interested in the feature @CommanderStorm. I wanted to put up a PR because it is a functioning thing, but I won't be upset if this it's denied.

Thank you for both an amazing product and making it so easily extensible!! I hacked in my use case within just a couple hours 😄

@CommanderStorm
Copy link
Collaborator

Thanks for your work.

I wanted to put up a PR because it is a functioning thing, but I won't be upset if this it's denied.

I am going to close this PR, as I think #3919 is a better (="fells less messy") solution.

While I can imagine some other usecases for this exact change, those are mostly abusing our system and pusing it farther than what it was designed for (e.g. "You have 60% disk space avalible"). Those usecases can be better dealt with either alerts or metrics.

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 pr:needs review this PR needs a review by maintainers or other community members type:enhance-existing feature wants to enhance existing monitor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants