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

Lower heartbeat interval when monitor is DOWN? #4025

Open
2 tasks done
Vincent-HD opened this issue Nov 13, 2023 · 7 comments · May be fixed by #4476
Open
2 tasks done

Lower heartbeat interval when monitor is DOWN? #4025

Vincent-HD opened this issue Nov 13, 2023 · 7 comments · May be fixed by #4476
Labels
area:monitor Everything related to monitors feature-request Request for new features to be added good first issue Good for newcomers type:enhance-existing feature wants to enhance existing monitor

Comments

@Vincent-HD
Copy link
Contributor

Vincent-HD commented Nov 13, 2023

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

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

I would like the possibility to lower the heartbeat interval when a monitor is marked as DOWN.
For example, here I have an Interval of 30 min betweens checks and 60 sec x 3 on pending. But as soon as it is marked as DOWN, it checks every 30 min again, can we change that behaviour?

It's useful if I don't want to “spam” our websites with checks, but I want to be able to be notified as soon as I want when a monitor is back up

So it would be, for example:

  • Check every 30 min if UP
  • Check every 30 sec if PENDING and max 3 times
  • Check every 5 min if DOWN

Thank you 👍

📝 Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.1

💻 Operating System and Arch

Ubuntu 20.04.5

🌐 Browser

Vivaldi 6.4.3160.42

🐋 Docker Version

23.0.0

🟩 NodeJS Version

No response

@chakflying
Copy link
Collaborator

Interesting, I think it would be more reasonable if the retry interval applies to down status as well.

@louislam
Copy link
Owner

Actually true, don't know why didn't think about it.

@chakflying chakflying added feature-request Request for new features to be added good first issue Good for newcomers and removed help labels Dec 4, 2023
@CommanderStorm CommanderStorm added the area:monitor Everything related to monitors label Dec 5, 2023
@CommanderStorm CommanderStorm changed the title Lower heartbeat interval when monitor is DOWN ? Lower heartbeat interval when monitor is DOWN? Dec 8, 2023
@CommanderStorm CommanderStorm added the type:enhance-existing feature wants to enhance existing monitor label Dec 9, 2023
@doitlikejustin

This comment was marked as spam.

@CommanderStorm

This comment was marked as resolved.

@neelbhanushali
Copy link

neelbhanushali commented Feb 11, 2024

@louislam

  1. Kindly validate if I understand the transition between Monitor Statuses (PENDING, UP, DOWN) correctly
  2. If my understanding about the transition is correct, also validate the requirement by @Vincent-HD (OP)
    • OP wants to change the behavior where the next action taken after DOWN status is Hit every Heartbeat Interval
    • Instead, there should be another input that controls transitioning from DOWN to UP; similar to how Heartbeat Retry Interval controls transitioning from PENDING to UP after a failure.

Flowchart

flowchart TD
    Start(Start => `!hasPreviousBeat`)
    P2(((Pending)))
    P(((Pending)))
    U(((Up)))
    D(((Down)))
    HI[Hit every `Heartbeat Interval`]
    HRI[Hit every `Heartbeat Retry Interval`]
    Reset_R[Reset `Retries` counter]
    isUp{Check successfull?}
    isMaxRetry{`Retries`-limit reached?}
    

    Start --> P2
    P2 --> HI
    HI --> isUp

    isUp --> |No| isMaxRetry
    isUp --> |Yes| Reset_R
    Reset_R --> U

    isMaxRetry --> |No| P
    P --> HRI
    isMaxRetry --> |Yes| D

    HRI --> isUp
    D --> HI
    U --> HI
Flow Chart Details

  1. Monitor Status are circle (PENDING, UP, DOWN)
  2. Rectangles are actions performed by Uptime Kuma
  3. Rhombuses are checks

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Feb 11, 2024

I have edited the diagram1 to hopefully clear the question a bit up (inlining, clarifying).

In terms of correctness of the diagram:

  • above diagram does not cover is the Upside Down Mode => this just reverses what is considered successful
  • I would need to look into the code if the Retries-counter is reset on DOWN

In terms of proposal:

  • Instead, there should be another input that controls transitioning from DOWN to UP; similar to how Heartbeat Retry Interval controls transitioning from PENDING to UP after a failure.

    Reusing the Heartbeat Retry Interval for DOWN beats (as suggested by @chakflying) seems intuitive enough. I don't think another setting needs to be added.

  • In any case, I think such adjustments might benefit if made after all monitors have been moved into their file (i.e. from monitor.js to monitor-types/*.js). Currently, reasoning about this is quite complicated, as can be seen by your comment.
    ⇒ If somebody wants to extract one of the monitors and test that it still works, our contribution guide can be found here

  • A thing why I am also not quite confident in this area is that the state model is largely untested. Testing of monitors (as closely related to the state mechanism) is something that we might be able to achieve via Unit Testing monitors with Testcontainers #4451, but currently I have not found the time to investigate this.

Footnotes

  1. The ability to have mermaid diagrams is very handy. ❤️

@neelbhanushali
Copy link

@CommanderStorm

For the case @Vincent-HD mentioned, another field would be handly

It's useful if I don't want to “spam” our websites with checks, but I want to be able to be notified as soon as I want when a monitor is back up

So it would be, for example:

  • Check every 30 min if UP
  • Check every 30 sec if PENDING and max 3 times
  • Check every 5 min if DOWN

However, I totally agree

  • Reusing the Heartbeat Retry Interval for DOWN beats (as suggested by @chakflying) seems intuitive enough. I don't think another setting needs to be added.

Modifying @Vincent-HD case as below can be a win-win

  • Check every 30 min if UP
  • Check every 30 sec if PENDING and max 3 times
  • Check every 30 sec if DOWN

I'm willing to send a PR for this

I've gone through the Contribution Guidelines

I will be creating my branch from master and will be sending the PR back to master considering this as a new feature
Let me know if I need to switch to 1.23.X

neelbhanushali added a commit to neelbhanushali/uptime-kuma that referenced this issue Feb 11, 2024
@neelbhanushali neelbhanushali linked a pull request Feb 11, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:monitor Everything related to monitors feature-request Request for new features to be added good first issue Good for newcomers type:enhance-existing feature wants to enhance existing monitor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants