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: keephq notification provider #4722

Merged
merged 7 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions server/notification-providers/keep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class Keep extends NotificationProvider {
name = "Keep";

/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";

try {
let data = {
heartbeat: heartbeatJSON,
monitor: monitorJSON,
msg,
};
let config = {
headers: {
"x-api-key": notification.webhookAPIKey,
"content-type": "application/json",
},
};

let url = notification.webhookURL;

if (url.endsWith("/")) {
url = url.slice(0, -1);
}

let webhookURL = url + "/alerts/event/uptimekuma";

await axios.post(webhookURL, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}

module.exports = Keep;
2 changes: 2 additions & 0 deletions server/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Gotify = require("./notification-providers/gotify");
const GrafanaOncall = require("./notification-providers/grafana-oncall");
const HomeAssistant = require("./notification-providers/home-assistant");
const HeiiOnCall = require("./notification-providers/heii-oncall");
const Keep = require("./notification-providers/keep");
const Kook = require("./notification-providers/kook");
const Line = require("./notification-providers/line");
const LineNotify = require("./notification-providers/linenotify");
Expand Down Expand Up @@ -95,6 +96,7 @@ class Notification {
new GrafanaOncall(),
new HomeAssistant(),
new HeiiOnCall(),
new Keep(),
new Kook(),
new Line(),
new LineNotify(),
Expand Down
1 change: 1 addition & 0 deletions src/components/NotificationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default {
"GrafanaOncall": "Grafana Oncall",
"HeiiOnCall": "Heii On-Call",
"HomeAssistant": "Home Assistant",
"Keep": "Keep",
"Kook": "Kook",
"line": "LINE Messenger",
"LineNotify": "LINE Notify",
Expand Down
42 changes: 42 additions & 0 deletions src/components/notifications/Keep.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div class="mb-3">
<label for="webhook-url" class="form-label">{{ $t("Host URL") }}</label>
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
<input
id="webhook-url"
v-model="$parent.notification.webhookURL"
type="url"
pattern="https?://.+"
class="form-control"
required
/>
<div class="form-text">
<i18n-t tag="p" keypath="Read more:">
<a href="https://docs.keephq.dev/providers/documentation/uptimekuma-provider" target="_blank">https://docs.keephq.dev/providers/documentation/uptimekuma-provider</a>
</i18n-t>
</div>
</div>

<div class="mb-3">
<label for="webhook-apikey" class="form-label">{{
$t("API Key")
}}</label>
<HiddenInput
id="webhook-apikey"
v-model="$parent.notification.webhookAPIKey"
:required="true"
></HiddenInput>
</div>
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
</template>

<script>
import HiddenInput from "../HiddenInput.vue";

export default {
components: {
HiddenInput,
},
mounted() {
this.$parent.notification.webhookURL ||= "";
},
};
</script>
2 changes: 2 additions & 0 deletions src/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import GrafanaOncall from "./GrafanaOncall.vue";
import GtxMessaging from "./GtxMessaging.vue";
import HomeAssistant from "./HomeAssistant.vue";
import HeiiOnCall from "./HeiiOnCall.vue";
import Keep from "./Keep.vue";
import Kook from "./Kook.vue";
import Line from "./Line.vue";
import LineNotify from "./LineNotify.vue";
Expand Down Expand Up @@ -82,6 +83,7 @@ const NotificationFormList = {
"GrafanaOncall": GrafanaOncall,
"HomeAssistant": HomeAssistant,
"HeiiOnCall": HeiiOnCall,
"Keep": Keep,
"Kook": Kook,
"line": Line,
"LineNotify": LineNotify,
Expand Down
1 change: 1 addition & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"Friendly Name": "Friendly Name",
"URL": "URL",
"Hostname": "Hostname",
"Host URL": "Host URL",
"locally configured mail transfer agent": "locally configured mail transfer agent",
"Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent": "Either enter the hostname of the server you want to connect to or {localhost} if you intend to use a {local_mta}",
"Port": "Port",
Expand Down
Loading