diff --git a/CHANGELOG.md b/CHANGELOG.md index 153c5b01..d713db60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## v1.0.21 (2022-08-12) +- Bug fixes +- ## v1.0.19 (2022-08-10) - Bug fixes diff --git a/README.md b/README.md index 36e96a28..f6c0e447 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,12 @@ See [Grafana docs](https://grafana.com/docs/grafana/latest/administration/plugin + +## Stargazers over time + +[![Stargazers over time](https://starchart.cc/grafana/oncall.svg)](https://starchart.cc/grafana/oncall) + + ## Further Reading - *Migration from the PagerDuty* - [Migrator](https://github.com/grafana/oncall/tree/dev/tools/pagerduty-migrator) - *Documentation* - [Grafana OnCall](https://grafana.com/docs/grafana-cloud/oncall/) diff --git a/engine/apps/auth_token/auth.py b/engine/apps/auth_token/auth.py index be4a99f3..551116c6 100644 --- a/engine/apps/auth_token/auth.py +++ b/engine/apps/auth_token/auth.py @@ -81,7 +81,10 @@ class PluginAuthentication(BaseAuthentication): @staticmethod def _get_user(request: Request, organization: Organization) -> User: context = json.loads(request.headers.get("X-Grafana-Context")) - user_id = context["UserId"] + try: + user_id = context["UserId"] + except KeyError: + user_id = context["UserID"] try: return organization.users.get(user_id=user_id) except User.DoesNotExist: diff --git a/engine/requirements.txt b/engine/requirements.txt index d0896ae0..5e0f4f61 100644 --- a/engine/requirements.txt +++ b/engine/requirements.txt @@ -1,4 +1,4 @@ -django==3.2.14 +django==3.2.15 djangorestframework==3.12.4 slackclient==1.3.0 whitenoise==5.3.0 diff --git a/examples/terraform/basic.tf b/examples/terraform/basic.tf new file mode 100644 index 00000000..6c33884d --- /dev/null +++ b/examples/terraform/basic.tf @@ -0,0 +1,42 @@ +terraform { + required_providers { + grafana = { + source = "grafana/grafana" + version = ">= 1.22.0" + } + } +} + +provider "grafana" { + alias = "oncall" + oncall_access_token = +} + +data "grafana_oncall_user" "ikonstantinov" { + provider = grafana.oncall + username = "ikonstantinov" +} + +resource "grafana_oncall_integration" "prod_alertmanager" { + provider = grafana.oncall + name = "Prod AM" + type = "alertmanager" + default_route { + escalation_chain_id = grafana_oncall_escalation_chain.default.id + } +} + +resource "grafana_oncall_escalation_chain" "default" { + provider = grafana.oncall + name = "default" +} + +resource "grafana_oncall_escalation" "notify_me_step" { + provider = grafana.oncall + escalation_chain_id = grafana_oncall_escalation_chain.default.id + type = "notify_persons" + persons_to_notify = [ + data.grafana_oncall_user.ikonstantinov.id + ] + position = 0 +} \ No newline at end of file diff --git a/examples/terraform/routes.tf b/examples/terraform/routes.tf new file mode 100644 index 00000000..fdbb81f1 --- /dev/null +++ b/examples/terraform/routes.tf @@ -0,0 +1,106 @@ +terraform { + required_providers { + grafana = { + source = "grafana/grafana" + version = ">= 1.22.0" + } + } +} + +provider "grafana" { + alias = "oncall" + oncall_access_token = +} + +// Users +data "grafana_oncall_user" "ikonstantinov" { + provider = grafana.oncall + username = "ikonstantinov" +} + +data "grafana_oncall_user" "mkukuy" { + provider = grafana.oncall + username = "mkukuy" +} + +// Schedule +resource "grafana_oncall_schedule" "primary" { + provider = grafana.oncall + name = "Primary" + type = "calendar" + time_zone = "UTC" + shifts = [ + grafana_oncall_on_call_shift.week_shift.id + ] +} + +resource "grafana_oncall_on_call_shift" "week_shift" { + provider = grafana.oncall + name = "Week shift" + type = "rolling_users" + start = "2022-06-01T00:00:00" + duration = 60 * 60 * 24 // 24 hours + frequency = "weekly" + by_day = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] + week_start = "MO" + rolling_users = [ + [data.grafana_oncall_user.ikonstantinov.id], + [data.grafana_oncall_user.mkukuy.id] + ] + time_zone = "UTC" +} + +// Prod Alertmanager Integration +resource "grafana_oncall_integration" "prod_alertmanager" { + provider = grafana.oncall + name = "Prod AM" + type = "alertmanager" + default_route { + escalation_chain_id = grafana_oncall_escalation_chain.default.id + } +} + +// Routes +resource "grafana_oncall_route" "critical_route" { + provider = grafana.oncall + integration_id = grafana_oncall_integration.prod_alertmanager.id + escalation_chain_id = grafana_oncall_escalation_chain.critical.id + routing_regex = "\"severity\": \"critical\"" + position = 0 +} + +// Default escalation chain +resource "grafana_oncall_escalation_chain" "default" { + provider = grafana.oncall + name = "default" +} + +resource "grafana_oncall_escalation" "wait" { + provider = grafana.oncall + escalation_chain_id = grafana_oncall_escalation_chain.default.id + type = "wait" + duration = 60 * 5 + position = 0 +} + +resource "grafana_oncall_escalation" "notify_schedule" { + provider = grafana.oncall + escalation_chain_id = grafana_oncall_escalation_chain.default.id + type = "notify_on_call_from_schedule" + notify_on_call_from_schedule = grafana_oncall_schedule.primary.id + position = 1 +} + +// Critical escalation chain +resource "grafana_oncall_escalation_chain" "critical" { + provider = grafana.oncall + name = "critical" +} + +resource "grafana_oncall_escalation" "notify_schedule_critical" { + provider = grafana.oncall + escalation_chain_id = grafana_oncall_escalation_chain.critical.id + type = "notify_on_call_from_schedule" + notify_on_call_from_schedule = grafana_oncall_schedule.primary.id + position = 0 +} \ No newline at end of file diff --git a/examples/terraform/shift_schedule.tf b/examples/terraform/shift_schedule.tf new file mode 100644 index 00000000..9b2eec37 --- /dev/null +++ b/examples/terraform/shift_schedule.tf @@ -0,0 +1,75 @@ +terraform { + required_providers { + grafana = { + source = "grafana/grafana" + version = ">= 1.22.0" + } + } +} + +provider "grafana" { + alias = "oncall" + oncall_access_token = +} + +// Users +data "grafana_oncall_user" "ikonstantinov" { + provider = grafana.oncall + username = "ikonstantinov" +} + +data "grafana_oncall_user" "mkukuy" { + provider = grafana.oncall + username = "mkukuy" +} + +// Schedule +resource "grafana_oncall_schedule" "primary" { + provider = grafana.oncall + name = "Primary" + type = "calendar" + time_zone = "UTC" + shifts = [ + grafana_oncall_on_call_shift.week_shift.id + ] +} + +resource "grafana_oncall_on_call_shift" "week_shift" { + provider = grafana.oncall + name = "Week shift" + type = "rolling_users" + start = "2022-06-01T00:00:00" + duration = 60 * 60 * 24 // 24 hours + frequency = "weekly" + by_day = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] + week_start = "MO" + rolling_users = [ + [data.grafana_oncall_user.ikonstantinov.id], + [data.grafana_oncall_user.mkukuy.id] + ] + time_zone = "UTC" +} + +// Prod Alertmanager Integration +resource "grafana_oncall_integration" "prod_alertmanager" { + provider = grafana.oncall + name = "Prod AM" + type = "alertmanager" + default_route { + escalation_chain_id = grafana_oncall_escalation_chain.default.id + } +} + +// Default escalation chain +resource "grafana_oncall_escalation_chain" "default" { + provider = grafana.oncall + name = "default" +} + +resource "grafana_oncall_escalation" "notify_schedule" { + provider = grafana.oncall + escalation_chain_id = grafana_oncall_escalation_chain.default.id + type = "notify_on_call_from_schedule" + notify_on_call_from_schedule = grafana_oncall_schedule.primary.id + position = 0 +} \ No newline at end of file diff --git a/grafana-plugin/CHANGELOG.md b/grafana-plugin/CHANGELOG.md index e48e4082..d713db60 100644 --- a/grafana-plugin/CHANGELOG.md +++ b/grafana-plugin/CHANGELOG.md @@ -1,9 +1,62 @@ # Change Log +## v1.0.21 (2022-08-12) +- Bug fixes +- +## v1.0.19 (2022-08-10) +- Bug fixes + +## v1.0.15 (2022-08-03) +- Bug fixes + +## v1.0.13 (2022-07-27) +- Optimize alert group list view +- Fix a bug related to Twilio setup + +## v1.0.12 (2022-07-26) +- Update push-notifications dependency +- Rework how absolute URLs are built +- Fix to show maintenance windows per team +- Logging improvements +- Internal api to get a schedule final events + +## v1.0.10 (2022-07-22) +- Speed-up of alert group web caching +- Internal api for OnCall shifts + +## v1.0.9 (2022-07-21) +- Frontend bug fixes & improvements +- Support regex_replace() in templates +- Bring back alert group caching and list view + +## v1.0.7 (2022-07-18) +- Backend & frontend bug fixes +- Deployment improvements +- Reshape webhook payload for outgoing webhooks +- Add escalation chain usage info on escalation chains page +- Improve alert group list load speeds and simplify caching system + +## v1.0.6 (2022-07-12) +- Manual Incidents enabled for teams +- Fix phone notifications for OSS +- Public API improvements + +## v1.0.5 (2022-07-06) +- Bump Django to 3.2.14 +- Fix PagerDuty iCal parsing + +## 1.0.4 (2022-06-28) +- Allow Telegram DMs without channel connection. + +## 1.0.3 (2022-06-27) +- Fix users public api endpoint. Now it returns users with all roles. +- Fix redundant notifications about gaps in schedules. +- Frontend fixes. + ## 1.0.2 (2022-06-17) - Fix Grafana Alerting integration to handle API changes in Grafana 9 -- Improve public API endpoint for outgoing webhooks (/actions) by adding ability to create, update and delete +- Improve public api endpoint for for outgoing webhooks (/actions) by adding ability to create, update and delete outgoing webhook instance ## 1.0.0 (2022-06-14) @@ -11,4 +64,4 @@ ## 0.0.71 (2022-06-06) -- Initial Commit Release \ No newline at end of file +- Initial Commit Release