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

feat: implement very crude and bare-bones RSS feed #5047

Merged
merged 5 commits into from
Sep 3, 2024

Conversation

MrYakobo
Copy link
Contributor

⚠️⚠️⚠️ 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

Fixes #1673.

This PR adds RSS capabilities to status-pages without extra configuration.
It's implemented as a custom route: append /rss to any status URL to get the RSS feed.
I've checked out the discussions in #2129 and #1673.
This PR adds a new server-side dependency feed.

Right now, the RSS feed looks like this:

curl http://localhost:3001/status/abc/rss

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>uptime kuma rss feed</title>
        <link>http://localhost:3001/status/abc</link>
        <description>feed for monitors that are down</description>
        <lastBuildDate>Sat, 24 Aug 2024 21:55:21 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[myserver is down]]></title>
            <pubDate>Sat, 24 Aug 2024 19:55:05 GMT</pubDate>
            <description><![CDATA[myserver has been down since 2024-08-24 21:55:05.738]]></description>
        </item>
    </channel>
</rss>

Right now, the RSS feed is missing this information that exists on the regular status page:

  • The label "All Systems Operational"
  • Description of status page
  • Percentage of uptime for each service

Type of change

  • 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.

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.

Good job 👍🏻

I have left a few inline comments

server/model/status_page.js Outdated Show resolved Hide resolved
server/model/status_page.js Show resolved Hide resolved
heartbeats.forEach(heartbeat => {
feed.addItem({
title: `${heartbeat.name} is down`,
description: `${heartbeat.name} has been down since ${heartbeat.time}`,
Copy link
Collaborator

@CommanderStorm CommanderStorm Aug 24, 2024

Choose a reason for hiding this comment

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

Not quite true.
That is just the last heartbeat that failed.
That description however can be misinterpreted as the first DOWN heartbeat (=> the total downtime for said heatbeat).

Also: I don't think that it has to be down, right? (we also have MAINTENANCE, UP and Pending as statuses, but I would need to look up if they can be heartbeats)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found this code in StatusPage.vue that interprets the status field from the database:

            let status = STATUS_PAGE_ALL_UP;
            let hasUp = false;

            for (let id in this.$root.publicLastHeartbeatList) {
                let beat = this.$root.publicLastHeartbeatList[id];

                if (beat.status === MAINTENANCE) {
                    return STATUS_PAGE_MAINTENANCE;
                } else if (beat.status === UP) {
                    hasUp = true;
                } else {
                    status = STATUS_PAGE_PARTIAL_DOWN;
                }
            }

            if (! hasUp) {
                status = STATUS_PAGE_ALL_DOWN;
            }

            return status;

I'll do something similar for the RSS feed 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To your questions,

That is just the last heartbeat that failed.
That description however can be misinterpreted as the first DOWN heartbeat (=> the total downtime for said heatbeat).

in getRSSPageData, I'm filtering for the last heartbeat of monitor_id=?. If that heartbeat is falsy, its added to the RSS feed. When the monitor is UP again, the RSS feed won't publish it anymore. I think this is the desired behaviour.

Copy link
Collaborator

@CommanderStorm CommanderStorm Aug 26, 2024

Choose a reason for hiding this comment

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

Filtering for DOWN sounds fine (I don't use RSS-Feeds, your call).

Have you tested that a falsy heartbeat means what you think it does?
Only the following values are falsy: https://developer.mozilla.org/en-US/docs/Glossary/Falsy

=> you are not filtering for the things you think you are..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great call mate. I've not worked with js for many years, so I'm a little bit rusty on these quirks 👍

server/model/status_page.js Outdated Show resolved Hide resolved
server/model/status_page.js Outdated Show resolved Hide resolved
@CommanderStorm CommanderStorm added area:status-page Everything related to the status page pr:please address review comments this PR needs a bit more work to be mergable labels Aug 25, 2024
Repository owner deleted a comment from MrYakobo Aug 26, 2024
@MrYakobo
Copy link
Contributor Author

MrYakobo commented Sep 2, 2024

Hello again! I think I've addressed your comments @CommanderStorm. What's hindering us from getting this PR merged? 👍

@CommanderStorm
Copy link
Collaborator

Blocking merging is Amongst others that my last review #5047 (comment) is not addressed as far as I can tell..

You are still filtering for truthy-ness and thus likely displaying UP heartbeats as down.

@MrYakobo
Copy link
Contributor Author

MrYakobo commented Sep 3, 2024

@CommanderStorm that's in my opinion addressed in commit 35349a , where I explicitly look for DOWN beats.

What do you mean with "Amongst others"? Are there more unanswered comments?

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.

Sorry, I could not do a proper review yesterday because of a terrible internet connection in Shanghai (firewall and stuffs you know).
(I flew onto vacation to Tokio)

LGTM now, I overlooked the reason why this is not filtered below.

Merging with junior-approval

@CommanderStorm CommanderStorm added this to the 2.0.0 milestone Sep 3, 2024
@CommanderStorm CommanderStorm removed the pr:please address review comments this PR needs a bit more work to be mergable label Sep 3, 2024
@CommanderStorm CommanderStorm merged commit 935194b into louislam:master Sep 3, 2024
18 checks passed
@MrYakobo
Copy link
Contributor Author

MrYakobo commented Sep 3, 2024

Thank you @CommanderStorm for your guidance in this PR! Happy vacation!

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

Successfully merging this pull request may close these issues.

An Atom (RSS) feed for notifications (including the public)
2 participants