Commit graph

388 commits

Author SHA1 Message Date
Pēteris Caune
7346994ae8
Fix field name in TypedDict used for type checking 2024-07-18 18:19:01 +03:00
Pēteris Caune
bdb6f18a3d
Add "uuid" field in API responses when read/write key is used
The API responses already contain ping_url, update_url, resume_url,
pause_url fields where the UUID can be extracted from, so we are
not exposing new information. The extraction can be finicky in,
say, shell-scripting scenarios. So for API user convenience we will
now also provide the check's code (UUID) as a separate field.

Fixes: #1007
2024-07-18 18:15:52 +03:00
Pēteris Caune
8054191be3
Remove HipChat, Pagerteam, Zendesk channel kinds
HipChat and Pagerteam products have long been shut down,
the Zendesk integration was never fully implemented.
2024-07-18 16:21:45 +03:00
Pēteris Caune
61bdd975e8
Add "(stops working Oct 2024)" note to the old MS Teams integration 2024-07-18 10:27:51 +03:00
Pēteris Caune
e83f60cc0b
Implement Implement MS Teams Workflows integration
We already have a MS Teams integration but MS Teams is discontinuing
the incoming webhook feature used by this integration:

https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/

MS Teams now recommends to use Workflows to post messages
via webhook. MS Teams does not provide backwards compatibility or
an upgrade path for existing integrations.

This commit adds a new "msteamsw" integration which uses MS Teams
Workflows to post notifications. It also updates the instructions
and illustrations in the "Add MS Teams Integration" page.

cc: #1024
2024-07-17 13:35:17 +03:00
Pēteris Caune
3e5080d9eb
Remove Ping.body field 2024-07-11 16:34:18 +03:00
Pēteris Caune
997154e3b0
Remove usages of Ping.body 2024-07-11 16:17:21 +03:00
Pēteris Caune
bc8fb90fed
Update Check.ping() to use select_for_update()
Without it, on MariaDB, concurrent pings can lead to a deadlock.
This results in OperationalError and HTTP 500 response to the client.

cc: #1023
2024-07-10 19:50:39 +03:00
Pēteris Caune
324fa10ce7
Fix Check.lock_and_delete() to gracefully handle already deleted check 2024-06-20 15:57:53 +03:00
Pēteris Caune
d486d2db14
Add uniqueness constraint to api_notification.code
This is primarily to make notification lookups by code efficient.
We look up notifications by code in hc.api.views.boundces.

This field has a default value (uuid.uuid4), so any null values
will be filled with random UUIDs during migration.
2024-05-17 10:30:01 +03:00
Pēteris Caune
e683496bed
Move reusable ping formatting code to Ping model 2024-04-19 12:38:20 +03:00
Pēteris Caune
81f202e2ac
Rename notify_flip -> notify 2024-04-12 15:49:47 +03:00
Pēteris Caune
28fdfd1362
Change Channel.notify() signature to take Flip object as an argument
... and pass it to Transport.notify_flip().

This allows us to pass flip-specific information (the flip timestamp,
the new status) to transport classes.
2024-04-12 13:54:16 +03:00
Pēteris Caune
6e130f1749
Change Transport.is_noop() to accept status:str instead of check:Check
I'm planning to change Channel.notify() signature to take a Flip
object as an argument instead of a Check object. This change is
in preparation for these changes.
2024-04-12 13:23:29 +03:00
Pēteris Caune
aaa8681fec
Update Check.prune() to also delete flip objects.
Check.prune() now deletes flips older than the oldest
retained ping *and* older than 3*31=93 days.
2024-04-11 12:56:28 +03:00
Pēteris Caune
1322bb1123
Add support for per-check status badges
Fixes: #853
2024-02-27 12:55:51 +02:00
Pēteris Caune
767c3ae702
Add a management command for pruning all checks 2023-12-21 14:55:05 +02:00
Pēteris Caune
b0f8c730f5
Change query in Check.prune() to work around pg index selection issue
In prune(), we need to look up the earliest ping in the database
for a given check. The old version did:

    ping = self.ping_set.earliest("id")

The new version does:

    ping = self.ping_set.earliest("created")

Both yield the same result, but in the first case Postgres may
decide to use the index for the api_ping.id column and scan
almost the entire table.

In the second case it uses the index for the api_ping.owner_id column,
and scans just the rows associated with the check.
2023-12-21 12:00:05 +02:00
Pēteris Caune
c8897b7026
Improve the handling of StopIteration exceptions
Instead of returning a datetime in far future,
get_grace_start() now returns None which (meaning "never").
2023-12-19 14:05:10 +02:00
Pēteris Caune
1d6e7297be
Fix get_grace_start to handle StopIteration exceptions
These can happen with "one-shot" OnCalendar schedules,
for example: "2023-12-19 11:30"
2023-12-19 13:29:52 +02:00
Pēteris Caune
fc56cf2635
Add API support for OnCalendar schedules 2023-12-07 14:03:35 +02:00
Pēteris Caune
d65f41d192
Add support for systemd's OnCalendar schedules
(work-in-progress)

cc: #919
2023-12-06 15:42:57 +02:00
Pēteris Caune
f8a9077c76
Fix DST handling in Check.get_grace_start() 2023-10-30 11:53:52 +02:00
Pēteris Caune
1eb92c9fe7
Switch to using Pydantic for parsing Gotify configuration 2023-10-26 12:01:42 +03:00
Pēteris Caune
cdac9b3128
Switch to using Pydantic for parsing Trello configuration 2023-10-26 11:57:49 +03:00
Pēteris Caune
dea66b85af
Switch to using Pydantic for parsing ntfy configuration
Also, fix a bug in the "Edit ntfy integration" form,
where the token was not filled in the form on page load.
2023-10-26 10:32:41 +03:00
Pēteris Caune
343e55bd4f
Improve type hints 2023-10-25 18:12:12 +03:00
Pēteris Caune
3d5850d2da
Improve type hints, use pydantic for parsing Zulip configurations 2023-10-17 16:58:57 +03:00
Florian Apolloner
7057f6d3a5
Notification groups. Fixes #894 (#901)
* MVP for notification groups.

* Addressed review comments.

* Push notification group to the front.

* Updated icons.

* Reduce code duplication.

* Show groups at the top.

* Add label to group forms.

* Add checkboxes for integration selection.

* CSS for checkboxes.

* Added tests for group notify.
2023-10-06 17:02:41 +03:00
Pēteris Caune
d40ce1eaac
Rename DowntimeSummary -> DowntimeRecorder 2023-09-28 09:02:13 +03:00
Pēteris Caune
95b92a9b3b
Fix type warning 2023-09-27 17:47:25 +03:00
Pēteris Caune
2a0ae809a7
Add DowntimeRecord.no_data field 2023-09-27 17:43:18 +03:00
Pēteris Caune
58d7c8cc55
Simplify DowntimeSummary 2023-09-27 17:16:16 +03:00
Pēteris Caune
f7af738c76
Add monthly uptime percentage display in Check Details page
Fixes: #773
2023-09-27 13:44:35 +03:00
Pēteris Caune
db5d8adeb5
Switch from namedtuple to dataclass for mutability 2023-09-27 11:03:58 +03:00
Pēteris Caune
46dbaff2c3
Update Check.downtimes() to return records in descending datetime order
This way we can avoid one sort operation in Check.downtimes()
and one reverse operation in the "details_downtimes.html" template.
2023-09-27 10:42:05 +03:00
Pēteris Caune
f0085933c3
Update Check.downtimes() to return a list of namedtuples
This way it should be easier to add extra fields like uptime
to the returned data structure.
2023-09-27 10:18:52 +03:00
Pēteris Caune
aa541e760b
Add Channel.opsgenie property
It replaces:

* Channel.opsgenie_key
* Channel.opsgenie_region

Also, add data migration to normalize Opsgenie channel values
to always be JSON maps.
2023-09-11 16:44:38 +03:00
Pēteris Caune
dcf9f327f6
Add Channel.email property
It replaces:

* Channel.email_value
* Channel.email_notify_up
* Channel.email_notify_down
2023-09-11 11:45:25 +03:00
Pēteris Caune
cf4498eca2
Add Channel.phone property
It has typed fields: value, notify_up, notify_down.
It replaces:

* Channel.phone_number
* Channel.sms_notify_up
* Channel.sms_notify_down
* Channel.whatsapp_notify_up
* Channel.whatsapp_notify_down
* Channel.signal_notify_up
* Channel.signal_notify_down
2023-09-09 11:09:52 +03:00
Pēteris Caune
ee40cd8dab
Fix type warnings 2023-09-08 16:47:27 +03:00
Pēteris Caune
f1d1ccd281
Add Channel.shell and Channel.pd properties 2023-09-08 16:33:12 +03:00
Pēteris Caune
e17f555fb1
Replace Channel.telegram_* properties with a Channel.telegram property
The Channel.telegram property has typed fields:
id, thread_id, type, name.

Usage sites change from `channel.telegram_id` to `channel.telegram.id`
2023-09-08 16:02:26 +03:00
Pēteris Caune
5746bbb015
Improve type hints in hc.api.models 2023-09-08 15:58:39 +03:00
Pēteris Caune
9173475194
Improve type hints in hc.api.views 2023-09-07 14:38:55 +03:00
Pēteris Caune
05d2d0065e
Remove usage of backports.zoneinfo 2023-09-06 12:54:27 +03:00
Pēteris Caune
c9bf3132fe
Replace usage of typing.List, typing.Optional etc. with modern syntax 2023-09-06 11:27:43 +03:00
Pēteris Caune
65b3acf964
Improve type hints in hc.accounts.views 2023-09-06 10:02:50 +03:00
Pēteris Caune
0c83ca4fd8
Improve type hints in hc.accounts.forms 2023-09-05 18:31:35 +03:00
Pēteris Caune
8472bd5d1e
Update Channel.webhook_spec to return an object instead of a dict
This simplifies type annotations, as object's fields
can be type-annotated easily, and JSON->object parsing can be handled
by Pydantic.
2023-09-03 16:20:22 +03:00