diff --git a/hc/api/transports.py b/hc/api/transports.py index 05ef4ee7..884f3ce2 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -585,10 +585,9 @@ class Spike(HttpTransport): url = self.channel.value headers = {"Conent-Type": "application/json"} payload = { - "incident_key": str(check.code), "title": tmpl("spike_title.html", check=check), - "description": tmpl("spike_description.html", check=check), - "client": settings.SITE_NAME, + "message": tmpl("spike_description.html", check=check), + "status": check.status } return self.post(url, json=payload, headers=headers) diff --git a/hc/front/tests/test_add_spike.py b/hc/front/tests/test_add_spike.py new file mode 100644 index 00000000..bf7c9e72 --- /dev/null +++ b/hc/front/tests/test_add_spike.py @@ -0,0 +1,30 @@ +from hc.api.models import Channel +from hc.test import BaseTestCase + + +class AddSpikeTestCase(BaseTestCase): + url = "/integrations/add_spike/" + + def test_instructions_work(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get(self.url) + self.assertContains(r, "Spike") + + def test_it_works(self): + form = {"value": "http://example.org"} + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, form) + self.assertRedirects(r, "/integrations/") + + c = Channel.objects.get() + self.assertEqual(c.kind, "spike") + self.assertEqual(c.value, "http://example.org") + self.assertEqual(c.project, self.project) + + def test_it_rejects_bad_url(self): + form = {"value": "not an URL"} + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, form) + self.assertContains(r, "Enter a valid URL") \ No newline at end of file diff --git a/templates/front/channels.html b/templates/front/channels.html index caf600e5..7b5e7e34 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -361,7 +361,7 @@
Incident Management - On-Call Schedules, Alerts, & Notifications
Add Integration- Make HTTP requests to the Ping URL at regular intervals. - - When the URL is not pinged on time, - {% site_name %} will send you an alert. - - - You can monitor any service that can make HTTP requests - or send emails. -
-{{ ping_url }}
+ + Make HTTP requests to the Ping URL at regular intervals. + + When the URL is not pinged on time, + {% site_name %} will send you an alert. + + + You can monitor any service that can make HTTP requests + or send emails. +
+{{ ping_url }}
- As an alternative to HTTP and HTTPS requests, - you can "ping" this check by sending an - email message to - {{ check.email }} -
++ As an alternative to HTTP and HTTPS requests, + you can "ping" this check by sending an + email message to + {{ check.email }} +
+- A list of your checks, one for each Cron job, daemon or - scheduled task you want to monitor. -
-- Give names and assign tags to your checks to easily recognize - them later. -
-- Tap on the integration icons to toggle them on and off. -
-- Adjust Period and Grace time to match the - periodicity and duration of your tasks. -
-+ A list of your checks, one for each Cron job, daemon or + scheduled task you want to monitor. +
++ Give names and assign tags to your checks to easily recognize + them later. +
++ Tap on the integration icons to toggle them on and off. +
++ Adjust Period and Grace time to match the + periodicity and duration of your tasks. +
+- - | -- New. - A check that has been created, but has not received any pings yet. - | -
- - | -- Up. - Time since last ping has not exceeded Period. - | -
- - | -- Late. - Time since last ping has exceeded Period, - but has not yet exceeded Period + Grace. - | -
- - | -- Down. - Time since last ping has exceeded Period + Grace. - When check goes from "Late" to "Down", {% site_name %} - sends you a notification. - | -
+ + | ++ New. + A check that has been created, but has not received any pings yet. + | +
+ + | ++ Up. + Time since last ping has not exceeded Period. + | +
+ + | ++ Late. + Time since last ping has exceeded Period, + but has not yet exceeded Period + Grace. + | +
+ + | ++ Down. + Time since last ping has exceeded Period + Grace. + When check goes from "Late" to "Down", {% site_name %} + sends you a notification. + | +
- Alternatively, you can define the expected ping dates and times - using a cron expression. See - Cron Syntax Cheatsheet - for the supported syntax features. -
-- Grace Time specifies how "late" a ping can - be before you will be alerted. Set it to be a little above - the expected duration of your cron job. -
-+ Alternatively, you can define the expected ping dates and times + using a cron expression. See + Cron Syntax Cheatsheet + for the supported syntax features. +
++ Grace Time specifies how "late" a ping can + be before you will be alerted. Set it to be a little above + the expected duration of your cron job. +
+- You can add a longer, free-form description to each - check. Leave notes and pointers for yourself and - for your team. -
-- You can also see the log of received pings and - sent "Down" notifications. -
-+ You can add a longer, free-form description to each + check. Leave notes and pointers for yourself and + for your team. +
++ You can also see the log of received pings and + sent "Down" notifications. +
+- {% site_name %} provides status badges for each of the tags - you have used. Additionally, the "{% site_name %}" badge - shows the overall status of all checks in your account. -
-- The badges have public, but hard-to-guess URLs. - You can use them in your READMEs, dashboards or status pages. -
-+ {% site_name %} provides status badges for each of the tags + you have used. Additionally, the "{% site_name %}" badge + shows the overall status of all checks in your account. +
++ The badges have public, but hard-to-guess URLs. + You can use them in your READMEs, dashboards or status pages. +
+{% site_name %} monitoring is a great fit for cron jobs and cron-like systems - (systemd timers, Jenkins build jobs, Windows Scheduled Tasks, wp-cron, uwsgi cron-like - interface, Heroku Scheduler, ...). A failed cron job often has no immediate visible - consequences, and can go unnoticed for a long time.
+ (systemd timers, Jenkins build jobs, Windows Scheduled Tasks, wp-cron, uwsgi cron-like + interface, Heroku Scheduler, ...). A failed cron job often has no immediate visible + consequences, and can go unnoticed for a long time.Specific examples:
{% site_name %} monitoring can be used for lightweight server monitoring: - ensuring a particular system service, or the server as a whole is alive and healthy. - Write a shell script that checks for a specific condition, and pings {% site_name %} - if successful. Run the shell script regularly.
+ ensuring a particular system service, or the server as a whole is alive and healthy. + Write a shell script that checks for a specific condition, and pings {% site_name %} + if successful. Run the shell script regularly.Specific examples: