diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c361a3c..8c965fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## v1.0.50 (2022-11-03) + +- Updates to documentation +- Improvements to web schedules +- Bug fixes + +## v1.0.49 (2022-11-01) + +- Enable SMTP email backend by default +- Fix Grafana sidebar frontend bug + +## v1.0.48 (2022-11-01) + +- verify_number management command +- chatops page redesign + +## v1.0.47 (2022-11-01) + +- Bug fixes + ## v1.0.46 (2022-10-28) - Bug fixes diff --git a/DEVELOPER.md b/DEVELOPER.md index e65f186a..f85cf648 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -20,6 +20,8 @@ ## Developer quickstart +Related: [How to develop integrations](/engine/config_integrations/README.md) + ### Code style - [isort](https://github.com/PyCQA/isort), [black](https://github.com/psf/black) and [flake8](https://github.com/PyCQA/flake8) are used to format backend code diff --git a/README.md b/README.md index 08019328..96455f6e 100644 --- a/README.md +++ b/README.md @@ -87,5 +87,6 @@ See [Grafana docs](https://grafana.com/docs/grafana/latest/administration/plugin - _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/) +- _How To Add Integration_ - [How to Add Integration](https://github.com/grafana/oncall/tree/dev/engine/config_integrations/README.md) - _Blog Post_ - [Announcing Grafana OnCall, the easiest way to do on-call management](https://grafana.com/blog/2021/11/09/announcing-grafana-oncall/) - _Presentation_ - [Deep dive into the Grafana, Prometheus, and Alertmanager stack for alerting and on-call management](https://grafana.com/go/observabilitycon/2021/alerting/?pg=blog) diff --git a/docker-compose-developer-pg.yml b/docker-compose-developer-pg.yml index f42f17e3..7c61cf35 100644 --- a/docker-compose-developer-pg.yml +++ b/docker-compose-developer-pg.yml @@ -15,6 +15,11 @@ services: limits: memory: 500m cpus: '0.5' + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 10s + timeout: 5s + retries: 5 redis: image: redis @@ -42,37 +47,27 @@ services: - "15672:15672" - "5672:5672" - mysql-to-create-grafana-db: - image: mysql:5.7 - platform: linux/x86_64 - command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - restart: always - ports: - - "3306:3306" - environment: - MYSQL_ROOT_PASSWORD: empty - MYSQL_DATABASE: grafana - deploy: - resources: - limits: - memory: 500m - cpus: '0.5' - healthcheck: - test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] - timeout: 20s - retries: 10 + postgres_to_create_grafana_db: + image: postgres:14.4 + command: bash -c "PGPASSWORD=empty psql -U postgres -h postgres -tc \"SELECT 1 FROM pg_database WHERE datname = 'grafana'\" | grep -q 1 || PGPASSWORD=empty psql -U postgres -h postgres -c \"CREATE DATABASE grafana\"" + depends_on: + postgres: + condition: service_healthy grafana: image: "grafana/grafana:main" restart: always environment: - GF_DATABASE_TYPE: mysql - GF_DATABASE_HOST: mysql - GF_DATABASE_USER: root + GF_DATABASE_TYPE: postgres + GF_DATABASE_HOST: postgres:5432 + GF_DATABASE_NAME: grafana + GF_DATABASE_USER: postgres GF_DATABASE_PASSWORD: empty - GF_SECURITY_ADMIN_USER: oncall - GF_SECURITY_ADMIN_PASSWORD: oncall + GF_DATABASE_SSL_MODE: disable + GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin} + GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin} GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app + GF_INSTALL_PLUGINS: grafana-oncall-app deploy: resources: limits: @@ -83,5 +78,7 @@ services: ports: - "3000:3000" depends_on: - mysql-to-create-grafana-db: + postgres_to_create_grafana_db: + condition: service_completed_successfully + postgres: condition: service_healthy diff --git a/docs/Makefile b/docs/Makefile index e66f1c1c..3762a58d 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -8,4 +8,4 @@ pull: .PHONY: docs docs: pull - docker run -v '$(shell pwd)/sources:$(CONTENT_PATH):Z' -p $(PORT) --rm -it $(IMAGE) + docker run -v '$(shell pwd)/sources:$(CONTENT_PATH):Z' -v '$(shell pwd)/sources:/jugo/content/docs/grafana-cloud/oncall:Z' -p $(PORT) --rm -it $(IMAGE) diff --git a/docs/sources/_index.md b/docs/sources/_index.md index 29928422..04026cb9 100644 --- a/docs/sources/_index.md +++ b/docs/sources/_index.md @@ -1,7 +1,7 @@ --- aliases: - - /docs/grafana-cloud/oncall/ - /docs/oncall/latest/ +canonical: https://grafana.com/docs/oncall/latest/ keywords: - Grafana Cloud - Alerts @@ -11,7 +11,6 @@ keywords: - OnCall - irm title: Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/" weight: 1000 --- @@ -22,7 +21,7 @@ weight: 1000 Grafana OnCall is an open source incident response management tool built to help teams improve their collaboration and resolve incidents faster. Some of the core strengths of Grafana OnCall include: -- **Support for a broad set of monitoring systems:** Grafana OnCall supports integrations with many monitoring systems, including Grafana, Prometheus, AlertManager, Zabbix, and more. +- **Support for a broad set of monitoring systems:** Grafana OnCall supports integrations with many monitoring systems, including Grafana, Prometheus, Alertmanager, Zabbix, and more. - **Reduce alert noise:** Automatic alert grouping helps avoid alert storms and reduce noise during incidents. Auto-resolve settings can resolve without human intervention when the resolve conditions are met, enabling you to control alert noise and reduce alert fatigue. - **Automatic escalation to on-call rotations:** Grafana OnCall’s flexible calendar integration allows you to define your on-call rotations while managing on-call schedules in your preferred calendar application with iCal format. Configurable alert escalation automatically escalates alerts to on-call team members, notifies slack channels, and more. - **ChatOps focused:** Grafana OnCall integrates closely with your slack workspace to deliver alert notifications to individuals and groups, making daily alerts more visible and easier to manage. diff --git a/docs/sources/alert-behavior/_index.md b/docs/sources/alert-behavior/_index.md new file mode 100644 index 00000000..79d01a20 --- /dev/null +++ b/docs/sources/alert-behavior/_index.md @@ -0,0 +1,20 @@ +--- +aliases: + - /docs/oncall/latest/alert-behavior/ +canonical: https://grafana.com/docs/oncall/latest/alert-behavior/ +title: Configure alert behavior for Grafana OnCall +weight: 900 +--- + +# Configure alert behavior for Grafana OnCall + +The available alert configurations in Grafana OnCall allow you to define how certain alerts are handled and ensure that alerts are routed, escalated, and grouped to fit your specific alerting needs. Grafana OnCall can receive alerts from any monitoring system that sends alerts via webhook. + + +## About alert behavior + +Once Grafana OnCall receives an alert, the following occurs, based on the alert content: + +- Default or customized alert templates are applied to deliver the most useful alert fields with the most valuable information, in a readable format. +- Alerts are grouped based on your alert grouping configurations, combining similar or related alerts to reduce alert noise. +- Alerts automatically resolve if an alert from the monitoring system matches the resolve condition for that alert. diff --git a/docs/sources/integrations/create-custom-templates.md b/docs/sources/alert-behavior/alert-templates/index.md similarity index 96% rename from docs/sources/integrations/create-custom-templates.md rename to docs/sources/alert-behavior/alert-templates/index.md index d99cce17..5bc4321c 100644 --- a/docs/sources/integrations/create-custom-templates.md +++ b/docs/sources/alert-behavior/alert-templates/index.md @@ -1,18 +1,19 @@ --- aliases: - - /docs/oncall/latest/integrations/create-custom-templates/ + - ../integrations/create-custom-templates/ + - /docs/oncall/latest/alert-behavior/alert-templates/ +canonical: https://grafana.com/docs/oncall/latest/alert-behavior/alert-templates/ keywords: - Grafana Cloud - Alerts - Notifications - on-call - Jinja -title: Configure alerts in Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/create-custom-templates/" +title: Configure alert templates weight: 300 --- -# Configure alerts in Grafana OnCall +# Configure alert templates Grafana OnCall can integrate with any monitoring systems that can send alerts using webhooks with JSON payloads. By default, webhooks deliver raw JSON payloads. When Grafana OnCall receives an alert and parses its payload, a default pre configured alert template is applied to modify the alert payload to be more human readable. These alert templates are customizable for any integration. diff --git a/docs/sources/integrations/configure-outgoing-webhooks.md b/docs/sources/alert-behavior/outgoing-webhooks/index.md similarity index 90% rename from docs/sources/integrations/configure-outgoing-webhooks.md rename to docs/sources/alert-behavior/outgoing-webhooks/index.md index bff8c74e..a88ccbf9 100644 --- a/docs/sources/integrations/configure-outgoing-webhooks.md +++ b/docs/sources/alert-behavior/outgoing-webhooks/index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/integrations/configure-outgoing-webhooks/ + - ../integrations/configure-outgoing-webhooks/ + - /docs/oncall/latest/alert-behavior/outgoing-webhooks/ +canonical: https://grafana.com/docs/oncall/latest/alert-behavior/outgoing-webhooks/ keywords: - Grafana Cloud - Alerts @@ -9,7 +11,6 @@ keywords: - amixr - webhooks title: Configure outgoing webhooks for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/configure-outgoing-webhooks/" weight: 500 --- diff --git a/docs/sources/calendar-schedules/_index.md b/docs/sources/calendar-schedules/_index.md index ca3bf92b..c4838c5d 100644 --- a/docs/sources/calendar-schedules/_index.md +++ b/docs/sources/calendar-schedules/_index.md @@ -1,6 +1,7 @@ --- aliases: - /docs/oncall/latest/calendar-schedules/ +canonical: https://grafana.com/docs/oncall/latest/calendar-schedules/ description: "" keywords: - Grafana @@ -8,7 +9,6 @@ keywords: - on-call - calendar title: Configure and manage on-call schedules -canonical: "https://grafana.com/docs/oncall/latest/calendar-schedules/" weight: 1100 --- diff --git a/docs/sources/configure-user-settings/_index.md b/docs/sources/configure-user-settings/_index.md index 287adf8e..afcefb69 100644 --- a/docs/sources/configure-user-settings/_index.md +++ b/docs/sources/configure-user-settings/_index.md @@ -1,6 +1,7 @@ --- aliases: - /docs/oncall/latest/configure-user-settings/ +canonical: https://grafana.com/docs/oncall/latest/configure-user-setting/ keywords: - Grafana Cloud - Alerts @@ -10,7 +11,6 @@ keywords: - oncall - integrations title: Manage users and teams for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/configure-user-setting/" weight: 1300 --- diff --git a/docs/sources/escalation-policies/_index.md b/docs/sources/escalation-policies/_index.md index 99326a51..ceb70476 100644 --- a/docs/sources/escalation-policies/_index.md +++ b/docs/sources/escalation-policies/_index.md @@ -1,13 +1,12 @@ --- -title: Configure escalation chains and routes for Grafana OnCall -weight: 700 -canonical: "https://grafana.com/docs/oncall/latest/escalation-policies/" aliases: - - /docs/oncall/latest/chat-options/escalation-policies/ + - /docs/oncall/latest/escalation-policies/ +canonical: https://grafana.com/docs/oncall/latest/escalation-policies/ +title: Escalation Chains and Routes +weight: 700 --- - -# Configure escalation chains and routes for Grafana OnCall +# Escalation Chains and Routes Escalation chains and routes for Grafana OnCall diff --git a/docs/sources/escalation-policies/configure-escalation-chains.md b/docs/sources/escalation-policies/configure-escalation-chains/index.md similarity index 94% rename from docs/sources/escalation-policies/configure-escalation-chains.md rename to docs/sources/escalation-policies/configure-escalation-chains/index.md index 8c244f15..9c19414b 100644 --- a/docs/sources/escalation-policies/configure-escalation-chains.md +++ b/docs/sources/escalation-policies/configure-escalation-chains/index.md @@ -1,6 +1,7 @@ --- aliases: - /docs/oncall/latest/escalation-policies/configure-escalation-chains/ +canonical: https://grafana.com/docs/oncall/latest/escalation-policies/configure-escalation-chains/ keywords: - Grafana Cloud - Alerts @@ -10,7 +11,6 @@ keywords: - oncall - integrations title: Configure and manage Escalation Chains -canonical: "https://grafana.com/docs/oncall/latest/escalation-policies/configure-escalation-chains/" weight: 100 --- diff --git a/docs/sources/escalation-policies/configure-routes.md b/docs/sources/escalation-policies/configure-routes/index.md similarity index 96% rename from docs/sources/escalation-policies/configure-routes.md rename to docs/sources/escalation-policies/configure-routes/index.md index becaa109..5de0a1a4 100644 --- a/docs/sources/escalation-policies/configure-routes.md +++ b/docs/sources/escalation-policies/configure-routes/index.md @@ -1,6 +1,7 @@ --- aliases: - /docs/oncall/latest/escalation-policies/configure-routes/ +canonical: https://grafana.com/docs/oncall/latest/escalation-policies/configure-routes/ keywords: - Grafana Cloud - Alerts @@ -10,11 +11,10 @@ keywords: - oncall - integrations title: Configure and manage routes -canonical: "https://grafana.com/docs/oncall/latest/escalation-policies/configure-routes/" weight: 300 --- -# Configure and manage routes +# Configure and manage Routes Set up escalation chains and routes to configure escalation behavior for alert group notifications. diff --git a/docs/sources/getting-started/_index.md b/docs/sources/get-started/_index.md similarity index 94% rename from docs/sources/getting-started/_index.md rename to docs/sources/get-started/_index.md index e84ffdd2..677b203e 100644 --- a/docs/sources/getting-started/_index.md +++ b/docs/sources/get-started/_index.md @@ -1,13 +1,13 @@ --- aliases: - - /docs/grafana-cloud/oncall/getting-started/ - - /docs/oncall/latest/getting-started/ + - /docs/oncall/latest/get-started/ + - /getting-started/ +canonical: https://grafana.com/docs/oncall/latest/get-started/ keywords: - Get started - On call - Grafana Cloud title: Get started with Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/getting-started/" weight: 300 --- @@ -59,7 +59,7 @@ Regardless of where your alerts originate, you can send them to Grafana OnCall v 2. Explore the alert by clicking on the title of the alert. 3. Acknowledge and resolve the test alert. -For more information on Grafana OnCall integrations and further configuration guidance, refer to, [Connect to Grafana OnCall]({{< relref "../integrations" >}}) +For more information on Grafana OnCall integrations and further configuration guidance, refer to, [Grafana OnCall integrations]({{< relref "../integrations" >}}) ### Configure Escalation Chains @@ -105,7 +105,7 @@ To configure Slack for Grafana OnCall: 5. Click Allow to allow Grafana OnCall to access Slack. 6. Ensure users verify their Slack accounts in their user profile in Grafana OnCall. -For further instruction on connecting to your Slack workspace, refer to [Connect Slack to Grafana OnCall]({{< relref "../chat-options/configure-slack" >}}) +For further instruction on connecting to your Slack workspace, refer to [Slack integration for Grafana OnCall]({{< relref "../integrations/chatops-integrations/configure-slack/" >}}) ### Add your on-call schedule diff --git a/docs/sources/integrations/_index.md b/docs/sources/integrations/_index.md index 354257a8..a49e7496 100644 --- a/docs/sources/integrations/_index.md +++ b/docs/sources/integrations/_index.md @@ -1,7 +1,7 @@ --- aliases: - - /docs/grafana-cloud/oncall/integrations/ - /docs/oncall/latest/integrations/ +canonical: https://grafana.com/docs/oncall/latest/integrations/ keywords: - Grafana Cloud - Alerts @@ -10,12 +10,11 @@ keywords: - amixr - oncall - integrations -title: Connect to Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/" +title: Grafana OnCall integrations weight: 500 --- -# Connect to Grafana OnCall +# Grafana OnCall integrations Integrations allow you to connect monitoring systems of your choice to send alerts to Grafana OnCall. Regardless of where your alerts originate, you can configure alerts to be sent to Grafana OnCall for alert escalation and notification. Grafana OnCall receives alerts in JSON format via a POST request, OnCall then parses alert data using preconfigured alert templates to determine alert grouping, apply routes, and determine correct escalation. @@ -53,7 +52,7 @@ To customize alert grouping for an integration: 2. Select **Alert Behavior** from the dropdown menu next to **Edit template for**. 3. Edit the **grouping id**, **acknowledge condition**, and **resolve condition** templates as needed to customize your alert behavior. -For more information on alert templates, see [Configure alerts in Grafana OnCall]({{< relref "create-custom-templates/" >}}) +For more information on alert templates, see [Configure alerts templates]({{< relref "../alert-behavior/alert-templates" >}}) #### Add Routes diff --git a/docs/sources/integrations/available-integrations/_index.md b/docs/sources/integrations/available-integrations/_index.md index c3127657..3d02ba76 100644 --- a/docs/sources/integrations/available-integrations/_index.md +++ b/docs/sources/integrations/available-integrations/_index.md @@ -1,7 +1,7 @@ --- aliases: - - /docs/grafana-cloud/oncall/integrations/add-integration/ - /docs/oncall/latest/integrations/available-integrations/ +canonical: https://grafana.com/docs/oncall/latest/integrations/available-integrations/ keywords: - Grafana Cloud - Alerts @@ -10,15 +10,14 @@ keywords: - Alertmanager - Prometheus title: Currently available integrations for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/available-integrations/" weight: 100 --- -# Currently available integrations +# Available integrations Grafana OnCall can connect directly to the monitoring services where your alerts originate. All currently available integrations are listed in the Grafana OnCall **Create Integration** section. -If the integration you're looking for isn't currently listed, see [Configure Webhook integrations for Grafana OnCall]({{< relref "../add-webhook-integration/" >}}) to integration your monitoring system with Grafana OnCall. +If the integration you're looking for isn't currently listed, see [Webhook integrations for Grafana OnCall]({{< relref "../available-integrations/configure-webhook" >}}) to integration your monitoring system with Grafana OnCall. > **Note:** Some integrations are available for Grafana Cloud instances only. See individual integration guides for more information. diff --git a/docs/sources/integrations/available-integrations/add-alertmanager.md b/docs/sources/integrations/available-integrations/configure-alertmanager/index.md similarity index 88% rename from docs/sources/integrations/available-integrations/add-alertmanager.md rename to docs/sources/integrations/available-integrations/configure-alertmanager/index.md index 74661625..e2569ed0 100644 --- a/docs/sources/integrations/available-integrations/add-alertmanager.md +++ b/docs/sources/integrations/available-integrations/configure-alertmanager/index.md @@ -1,7 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/available-integrations/add-alertmanager/ - - /docs/oncall/latest/integrations/available-integrations /add-alertmanager/ + - add-alertmanager/ + - /docs/oncall/latest/integrations/available-integrations/configure-alertmanager/ +canonical: https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-alertmanager/ keywords: - Grafana Cloud - Alerts @@ -9,12 +10,11 @@ keywords: - on-call - Alertmanager - Prometheus -title: Connect Alertmanager to Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/available-integrations/add-alertmanager/" +title: Alertmanager integration for Grafana OnCall weight: 300 --- -# Connect Alertmanager to Grafana OnCall +# Alertmanager integration for Grafana OnCall The Alertmanager integration for Grafana OnCall handles alerts sent by client applications such as the Prometheus server. diff --git a/docs/sources/integrations/available-integrations/add-grafana-alerting.md b/docs/sources/integrations/available-integrations/configure-grafana-alerting/index.md similarity index 90% rename from docs/sources/integrations/available-integrations/add-grafana-alerting.md rename to docs/sources/integrations/available-integrations/configure-grafana-alerting/index.md index e3af0a90..c3197649 100644 --- a/docs/sources/integrations/available-integrations/add-grafana-alerting.md +++ b/docs/sources/integrations/available-integrations/configure-grafana-alerting/index.md @@ -1,19 +1,19 @@ --- aliases: - - /docs/grafana-cloud/oncall/integrations/add-grafana-alerting/ - - /docs/oncall/latest/integrations/available-integrations /add-grafana-alerting/ + - add-grafana-alerting/ + - /docs/oncall/latest/integrations/available-integrations/configure-grafana-alerting/ +canonical: https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-grafana-alerting/ keywords: - Grafana Cloud - Alerts - Notifications - on-call - Prometheus -title: Connect Grafana Alerting to Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/available-integrations/add-grafana-alerting/" +title: Grafana Alerting integration for Grafana OnCall weight: 100 --- -# Connect Grafana Alerting to Grafana OnCall +# Grafana Alerting integration for Grafana OnCall Grafana Alerting for Grafana OnCall can be set up using two methods: diff --git a/docs/sources/integrations/add-webhook-integration.md b/docs/sources/integrations/available-integrations/configure-webhook/index.md similarity index 86% rename from docs/sources/integrations/add-webhook-integration.md rename to docs/sources/integrations/available-integrations/configure-webhook/index.md index f1d96eed..a762f006 100644 --- a/docs/sources/integrations/add-webhook-integration.md +++ b/docs/sources/integrations/available-integrations/configure-webhook/index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/integrations/add-webhook-integration/ + - ../add-webhook-integration/ + - /docs/oncall/latest/integrations/available-integrations/configure-webhook/ +canonical: https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-webhook/ keywords: - Grafana Cloud - Alerts @@ -9,11 +11,10 @@ keywords: - Alertmanager - Prometheus title: Webhook integration for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/add-webhook-integration/" weight: 700 --- -# Configure Webhook integrations for Grafana OnCall +# Webhook integrations for Grafana OnCall Grafana OnCall directly supports many integrations, those that aren’t currently listed in the Integrations menu can be connected using the webhook integration and configured alert templates. @@ -56,4 +57,4 @@ For example: }' ``` -To learn how to use custom alert templates for formatted webhooks, see [Configure alerts in Grafana OnCall]({{< relref "../integrations/create-custom-templates/" >}}). +To learn how to use custom alert templates for formatted webhooks, see [Configure alerts templates]({{< relref "../../../alert-behavior/alert-templates/" >}}). diff --git a/docs/sources/integrations/available-integrations/add-zabbix.md b/docs/sources/integrations/available-integrations/configure-zabbix/index.md similarity index 94% rename from docs/sources/integrations/available-integrations/add-zabbix.md rename to docs/sources/integrations/available-integrations/configure-zabbix/index.md index cfe663a1..7fc0bb8e 100644 --- a/docs/sources/integrations/available-integrations/add-zabbix.md +++ b/docs/sources/integrations/available-integrations/configure-zabbix/index.md @@ -1,18 +1,19 @@ --- aliases: - - /docs/oncall/latest/integrations/available-integrations /add-zabbix/ + - add-zabbix/ + - /docs/oncall/latest/integrations/available-integrations/configure-zabbix/ +canonical: https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-zabbix/ keywords: - Grafana Cloud - Alerts - Notifications - on-call - Zabbix -title: Connect Zabbix to Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/integrations/available-integrations/add-zabbix/" +title: Zabbix integration for Grafana OnCall weight: 500 --- -# Connect Zabbix to Grafana OnCall +# Zabbix integration for Grafana OnCall Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual machines, and cloud services. Zabbix provides monitoring for metrics such as network utilization, CPU load, and disk space consumption. diff --git a/docs/sources/chat-options/_index.md b/docs/sources/integrations/chatops-integrations/_index.md similarity index 63% rename from docs/sources/chat-options/_index.md rename to docs/sources/integrations/chatops-integrations/_index.md index ed858e62..c96e8d6e 100644 --- a/docs/sources/chat-options/_index.md +++ b/docs/sources/integrations/chatops-integrations/_index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/chat-options/ + - ../chat-options/ + - /docs/oncall/latest/integrations/chatops-integrations/ +canonical: https://grafana.com/docs/oncall/latest/integrations/chatops-integrations/ keywords: - Grafana Cloud - Alerts @@ -9,14 +11,13 @@ keywords: - amixr - oncall - slack -title: Connect ChatOps to Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/chat-options/" -weight: 900 +title: Available ChatOps integrations +weight: 300 --- -# Connect ChatOps to Grafana OnCall +# Available ChatOps integrations -Grafana OnCall directly supports the export of alert notifications to some popular messaging applications like Slack and Telegram. You can use outgoing webhooks to applications that aren't directly supported. For information on configuring outgoing webhooks, see [Send alert group notifications by webhook]({{< relref "../integrations/configure-outgoing-webhooks.md" >}}). +Grafana OnCall directly supports the export of alert notifications to some popular messaging applications like Slack and Telegram. You can use outgoing webhooks to applications that aren't directly supported. For information on configuring outgoing webhooks, see [Send alert group notifications by webhook]({{< relref "../../alert-behavior/outgoing-webhooks/" >}}). To configure supported messaging apps, see the following topics: diff --git a/docs/sources/chat-options/configure-slack.md b/docs/sources/integrations/chatops-integrations/configure-slack/index.md similarity index 92% rename from docs/sources/chat-options/configure-slack.md rename to docs/sources/integrations/chatops-integrations/configure-slack/index.md index 77126bb9..33d29016 100644 --- a/docs/sources/chat-options/configure-slack.md +++ b/docs/sources/integrations/chatops-integrations/configure-slack/index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/chat-options/configure-slack/ + - ../../chat-options/configure-slack/ + - /docs/oncall/latest/integrations/chatops-integrations/configure-slack/ +canonical: https://grafana.com/docs/oncall/latest/integrations/chatops-integrations/configure-slack/ keywords: - Grafana Cloud - Alerts @@ -10,7 +12,6 @@ keywords: - oncall - slack title: Slack integration for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/chat-options/configure-slack/" weight: 100 --- @@ -25,7 +26,7 @@ Integrating your Slack workspace with Grafana OnCall allows users and teams to b To install the Slack integration, you must have Admin permissions in your Grafana instance as well as the Slack workspace that you’d like to integrate with. -For Open Source Grafana OnCall Slack installation guidance, refer to [Open Source Grafana OnCall]({{< relref "../open-source" >}}). +For Open Source Grafana OnCall Slack installation guidance, refer to [Open Source Grafana OnCall]({{< relref "../../../open-source/" >}}). ## Install Slack integration for Grafana OnCall diff --git a/docs/sources/chat-options/configure-teams.md b/docs/sources/integrations/chatops-integrations/configure-teams/index.md similarity index 94% rename from docs/sources/chat-options/configure-teams.md rename to docs/sources/integrations/chatops-integrations/configure-teams/index.md index b17ca99d..b4f42450 100644 --- a/docs/sources/chat-options/configure-teams.md +++ b/docs/sources/integrations/chatops-integrations/configure-teams/index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/chat-options/configure-teams/ + - ../../chat-options/configure-teams/ + - /docs/oncall/latest/integrations/chatops-integrations/configure-teams/ +canonical: https://grafana.com/docs/oncall/latest/integrations/chatops-integrations/configure-teams/ keywords: - Grafana Cloud - Alerts @@ -11,7 +13,6 @@ keywords: - MS Team - Microsoft title: Microsoft Teams integration for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/chat-options/configure-teams/" weight: 500 --- diff --git a/docs/sources/chat-options/configure-telegram.md b/docs/sources/integrations/chatops-integrations/configure-telegram/index.md similarity index 91% rename from docs/sources/chat-options/configure-telegram.md rename to docs/sources/integrations/chatops-integrations/configure-telegram/index.md index daef6ab6..fd510340 100644 --- a/docs/sources/chat-options/configure-telegram.md +++ b/docs/sources/integrations/chatops-integrations/configure-telegram/index.md @@ -1,6 +1,8 @@ --- aliases: - - /docs/oncall/latest/chat-options/configure-telegram/ + - ../../chat-options/configure-telegram/ + - /docs/oncall/latest/integrations/chatops-integrations/configure-telegram/ +canonical: https://grafana.com/docs/oncall/latest/integrations/chatops-integrations/configure-telegram/ keywords: - Grafana Cloud - Alerts @@ -10,7 +12,6 @@ keywords: - oncall - telegram title: Telegram integration for Grafana OnCall -canonical: "https://grafana.com/docs/oncall/latest/chat-options/configure-telegram/" weight: 300 --- diff --git a/docs/sources/oncall-api-reference/_index.md b/docs/sources/oncall-api-reference/_index.md index 9f998e59..cc453fec 100644 --- a/docs/sources/oncall-api-reference/_index.md +++ b/docs/sources/oncall-api-reference/_index.md @@ -1,8 +1,8 @@ --- aliases: - /docs/oncall/latest/oncall-api-reference/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/ title: Grafana OnCall HTTP API reference -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/" weight: 1500 --- diff --git a/docs/sources/oncall-api-reference/alertgroups.md b/docs/sources/oncall-api-reference/alertgroups.md index 8e90f6d3..e578644d 100644 --- a/docs/sources/oncall-api-reference/alertgroups.md +++ b/docs/sources/oncall-api-reference/alertgroups.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/alertgroups/ - /docs/oncall/latest/oncall-api-reference/alertgroups/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/alertgroups/ title: Alert groups HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/alertgroups/" weight: 400 --- diff --git a/docs/sources/oncall-api-reference/alerts.md b/docs/sources/oncall-api-reference/alerts.md index 8a062581..d67f8e14 100644 --- a/docs/sources/oncall-api-reference/alerts.md +++ b/docs/sources/oncall-api-reference/alerts.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/alerts/ - /docs/oncall/latest/oncall-api-reference/alerts/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/alerts/ title: Alerts HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/alerts/" weight: 100 --- diff --git a/docs/sources/oncall-api-reference/escalation_chains.md b/docs/sources/oncall-api-reference/escalation_chains.md index 8723b6a6..f88b8d71 100644 --- a/docs/sources/oncall-api-reference/escalation_chains.md +++ b/docs/sources/oncall-api-reference/escalation_chains.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/escalation_chains/ - /docs/oncall/latest/oncall-api-reference/escalation_chains/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_chains/ title: Escalation Chains HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_chains/" weight: 200 --- diff --git a/docs/sources/oncall-api-reference/escalation_policies.md b/docs/sources/oncall-api-reference/escalation_policies.md index 76d253f3..26c8a470 100644 --- a/docs/sources/oncall-api-reference/escalation_policies.md +++ b/docs/sources/oncall-api-reference/escalation_policies.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/escalation_policies/ - /docs/oncall/latest/oncall-api-reference/escalation_policies/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_policies/ title: Escalation Policies HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/escalation_policies/" weight: 300 --- diff --git a/docs/sources/oncall-api-reference/integrations.md b/docs/sources/oncall-api-reference/integrations.md index 19e3edee..282e39df 100644 --- a/docs/sources/oncall-api-reference/integrations.md +++ b/docs/sources/oncall-api-reference/integrations.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/integrations/ - /docs/oncall/latest/oncall-api-reference/integrations/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/integrations/ title: Integrations HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/integrations/" weight: 500 --- @@ -68,7 +67,7 @@ The above command returns JSON structured in the following way: ``` Integrations are sources of alerts and alert groups for Grafana OnCall. -For example, to learn how to integrate Grafana OnCall with Alertmanager see [Alertmanager]({{< relref "../integrations/available-integrations/add-alertmanager/" >}}). +For example, to learn how to integrate Grafana OnCall with Alertmanager see [Alertmanager]({{< relref "../integrations/available-integrations/configure-alertmanager/" >}}). **HTTP request** diff --git a/docs/sources/oncall-api-reference/on_call_shifts.md b/docs/sources/oncall-api-reference/on_call_shifts.md index 8f43975d..f06a8d12 100644 --- a/docs/sources/oncall-api-reference/on_call_shifts.md +++ b/docs/sources/oncall-api-reference/on_call_shifts.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/on_call_shifts/ - /docs/oncall/latest/oncall-api-reference/on_call_shifts/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/on_call_shifts/ title: OnCall shifts HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/on_call_shifts/" weight: 600 --- diff --git a/docs/sources/oncall-api-reference/outgoing_webhooks.md b/docs/sources/oncall-api-reference/outgoing_webhooks.md index 0e26f012..deb26150 100644 --- a/docs/sources/oncall-api-reference/outgoing_webhooks.md +++ b/docs/sources/oncall-api-reference/outgoing_webhooks.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/outgoing_webhooks/ - /docs/oncall/latest/oncall-api-reference/outgoing_webhooks/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/outgoing_webhooks/ title: Outgoing webhooks HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/outgoing_webhooks/" weight: 700 --- diff --git a/docs/sources/oncall-api-reference/personal_notification_rules.md b/docs/sources/oncall-api-reference/personal_notification_rules.md index dc6e8562..fdf92646 100644 --- a/docs/sources/oncall-api-reference/personal_notification_rules.md +++ b/docs/sources/oncall-api-reference/personal_notification_rules.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/personal_notification_rules/ - /docs/oncall/latest/oncall-api-reference/personal_notification_rules/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/personal_notification_rules/ title: Personal Notification Rules HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/personal_notification_rules/" weight: 800 --- diff --git a/docs/sources/oncall-api-reference/postmortem_messages.md b/docs/sources/oncall-api-reference/postmortem_messages.md index b2fefa19..f3f5aff8 100644 --- a/docs/sources/oncall-api-reference/postmortem_messages.md +++ b/docs/sources/oncall-api-reference/postmortem_messages.md @@ -1,10 +1,9 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/postmortem_messages/ - /docs/oncall/latest/oncall-api-reference/postmortem_messages/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/postmortem_messages/ draft: true title: Postmortem Messages HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/postmortem_messages/" weight: 900 --- diff --git a/docs/sources/oncall-api-reference/postmortems.md b/docs/sources/oncall-api-reference/postmortems.md index c98026ae..91797f74 100644 --- a/docs/sources/oncall-api-reference/postmortems.md +++ b/docs/sources/oncall-api-reference/postmortems.md @@ -1,10 +1,9 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/postmortems/ - /docs/oncall/latest/oncall-api-reference/postmortems/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/postmortems/ draft: true title: Postmortem HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/postmortems/" weight: 1000 --- diff --git a/docs/sources/oncall-api-reference/routes.md b/docs/sources/oncall-api-reference/routes.md index 78eb387f..5f92e79a 100644 --- a/docs/sources/oncall-api-reference/routes.md +++ b/docs/sources/oncall-api-reference/routes.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/routes/ - /docs/oncall/latest/oncall-api-reference/routes/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/routes/ title: Routes HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/routes/" weight: 1100 --- diff --git a/docs/sources/oncall-api-reference/schedules.md b/docs/sources/oncall-api-reference/schedules.md index d7ec9273..53b19f81 100644 --- a/docs/sources/oncall-api-reference/schedules.md +++ b/docs/sources/oncall-api-reference/schedules.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/schedules/ - /docs/oncall/latest/oncall-api-reference/schedules/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/schedules/ title: Schedule HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/schedules/" weight: 1200 --- diff --git a/docs/sources/oncall-api-reference/slack_channels.md b/docs/sources/oncall-api-reference/slack_channels.md index 6c7d09c3..f5516688 100644 --- a/docs/sources/oncall-api-reference/slack_channels.md +++ b/docs/sources/oncall-api-reference/slack_channels.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/slack_channels/ - /docs/oncall/latest/oncall-api-reference/slack_channels/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/slack_channels/ title: Slack Channels HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/slack_channels/" weight: 1300 --- diff --git a/docs/sources/oncall-api-reference/user_groups.md b/docs/sources/oncall-api-reference/user_groups.md index e2021770..c078eb13 100644 --- a/docs/sources/oncall-api-reference/user_groups.md +++ b/docs/sources/oncall-api-reference/user_groups.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/user_groups/ - /docs/oncall/latest/oncall-api-reference/user_groups/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/user_groups/ title: OnCall User Groups HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/user_groups/" weight: 1400 --- diff --git a/docs/sources/oncall-api-reference/users.md b/docs/sources/oncall-api-reference/users.md index ca6d01df..4c520eeb 100644 --- a/docs/sources/oncall-api-reference/users.md +++ b/docs/sources/oncall-api-reference/users.md @@ -1,9 +1,8 @@ --- aliases: - - /docs/grafana-cloud/oncall/oncall-api-reference/users/ - /docs/oncall/latest/oncall-api-reference/users/ +canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/users/ title: Grafana OnCall Users HTTP API -canonical: "https://grafana.com/docs/oncall/latest/oncall-api-reference/users/" weight: 1500 --- diff --git a/docs/sources/open-source/_index.md b/docs/sources/open-source/_index.md index fdc3a1a8..5e3f03c6 100644 --- a/docs/sources/open-source/_index.md +++ b/docs/sources/open-source/_index.md @@ -1,6 +1,5 @@ --- aliases: - - /docs/grafana-cloud/oncall/open-source/ - /docs/oncall/latest/open-source/ keywords: - Open Source @@ -195,6 +194,7 @@ Grafana OnCall is capable of sending emails using SMTP as a user notification st - `EMAIL_HOST_USER` - SMTP server user - `EMAIL_HOST_PASSWORD` - SMTP server password - `EMAIL_PORT` (default is `587`) - SMTP server port -- `EMAIL_USE_TLS` (default is `True`) - to enable/disable TLS +- `EMAIL_USE_TLS` (default is `True`) - To enable/disable TLS +- `EMAIL_FROM_ADDRESS` (optional) - Email address used to send emails. If not specified, `EMAIL_HOST_USER` will be used. After enabling the email integration, it will be possible to use the `Notify by email` notification step in user settings. diff --git a/engine/apps/api/serializers/live_setting.py b/engine/apps/api/serializers/live_setting.py index bf431341..15806b0e 100644 --- a/engine/apps/api/serializers/live_setting.py +++ b/engine/apps/api/serializers/live_setting.py @@ -5,7 +5,7 @@ from apps.base.models import LiveSetting class LiveSettingSerializer(serializers.ModelSerializer): id = serializers.CharField(read_only=True, source="public_primary_key") - value = serializers.JSONField(allow_null=False) + value = serializers.JSONField(allow_null=True) class Meta: model = LiveSetting diff --git a/engine/apps/api/tests/test_schedules.py b/engine/apps/api/tests/test_schedules.py index 4c562307..9c73027d 100644 --- a/engine/apps/api/tests/test_schedules.py +++ b/engine/apps/api/tests/test_schedules.py @@ -205,11 +205,11 @@ def test_get_list_schedules_by_type( }, ] - for expected, schedule_type in enumerate(("api", "ical", "web")): + for schedule_type in range(3): url = reverse("api-internal:schedule-list") + "?type={}".format(schedule_type) response = client.get(url, format="json", **make_user_auth_headers(user, token)) assert response.status_code == status.HTTP_200_OK - assert response.json() == [expected_payload[expected]] + assert response.json() == [expected_payload[schedule_type]] @pytest.mark.django_db diff --git a/engine/apps/api/views/schedule.py b/engine/apps/api/views/schedule.py index 5a2d96aa..7ecebaf4 100644 --- a/engine/apps/api/views/schedule.py +++ b/engine/apps/api/views/schedule.py @@ -24,7 +24,7 @@ from apps.api.serializers.schedule_polymorphic import ( from apps.auth_token.auth import PluginAuthentication from apps.auth_token.constants import SCHEDULE_EXPORT_TOKEN_NAME from apps.auth_token.models import ScheduleExportAuthToken -from apps.schedules.models import OnCallSchedule, OnCallScheduleCalendar, OnCallScheduleICal, OnCallScheduleWeb +from apps.schedules.models import OnCallSchedule from apps.slack.models import SlackChannel from apps.slack.tasks import update_slack_user_group_for_schedules from common.api_helpers.exceptions import BadRequest, Conflict @@ -42,7 +42,9 @@ EVENTS_FILTER_BY_ROTATION = "rotation" EVENTS_FILTER_BY_OVERRIDE = "override" EVENTS_FILTER_BY_FINAL = "final" -SCHEDULE_TYPE_TO_CLASS = {"api": OnCallScheduleCalendar, "ical": OnCallScheduleICal, "web": OnCallScheduleWeb} +SCHEDULE_TYPE_TO_CLASS = { + str(num_type): cls for cls, num_type in PolymorphicScheduleSerializer.SCHEDULE_CLASS_TO_TYPE.items() +} class ScheduleView( @@ -262,7 +264,13 @@ class ScheduleView( if filter_by is not None and filter_by != EVENTS_FILTER_BY_FINAL: filter_by = OnCallSchedule.PRIMARY if filter_by == EVENTS_FILTER_BY_ROTATION else OnCallSchedule.OVERRIDES events = schedule.filter_events( - user_tz, starting_date, days=days, with_empty=True, with_gap=resolve_schedule, filter_by=filter_by + user_tz, + starting_date, + days=days, + with_empty=True, + with_gap=resolve_schedule, + filter_by=filter_by, + all_day_datetime=True, ) else: # return final schedule events = schedule.final_events(user_tz, starting_date, days) diff --git a/engine/apps/base/models/live_setting.py b/engine/apps/base/models/live_setting.py index 4e2664d7..09845e6f 100644 --- a/engine/apps/base/models/live_setting.py +++ b/engine/apps/base/models/live_setting.py @@ -38,6 +38,7 @@ class LiveSetting(models.Model): "EMAIL_HOST_USER", "EMAIL_HOST_PASSWORD", "EMAIL_USE_TLS", + "EMAIL_FROM_ADDRESS", "TWILIO_ACCOUNT_SID", "TWILIO_AUTH_TOKEN", "TWILIO_NUMBER", @@ -61,6 +62,7 @@ class LiveSetting(models.Model): "EMAIL_HOST_USER": "SMTP server user", "EMAIL_HOST_PASSWORD": "SMTP server password", "EMAIL_USE_TLS": "SMTP enable/disable TLS", + "EMAIL_FROM_ADDRESS": "Email address used to send emails. If not specified, EMAIL_HOST_USER will be used.", "SLACK_SIGNING_SECRET": ( "Check *OnCall* -> *Users*, " + "The information in workspace is read-only. To be able to intercat with OnCall alert groups you need to connect a personal account.\n" + "Please go to the *Grafana* -> *OnCall* -> *Users*, " "choose *your profile* and click the *connect* button.\n" ":rocket: :rocket: :rocket:" ) diff --git a/engine/config_integrations/README.md b/engine/config_integrations/README.md new file mode 100644 index 00000000..13c7189d --- /dev/null +++ b/engine/config_integrations/README.md @@ -0,0 +1,21 @@ +# Contribute the new Integration to OnCall + +Related: [DEVELOPER.md](/DEVELOPER.md) + +"Integration" in OnCall is a pre-configured webhook for alert consumption from alert sources. Usually, alert sources are monitoring systems such as Grafana or Zabbix. + +Integration is a set of "templates" which are dumped from the integration config once the integration is created. Further changes to "templates" don't reflect on the integration config. Read more about templates [here](https://grafana.com/docs/oncall/latest/integrations/create-custom-templates/). + +This instruction is supposed to help you to build templates to integrate OnCall with a new source of alerts. If you don't want to contribute to OnCall and are looking for a help integrating with custom alert source as a user, refer to [this](https://grafana.com/docs/oncall/latest/integrations/create-custom-templates/) instruction. + +# Files related to Integrations +0. Refer to "Grafana" integration as the most complete example. +1. Each integration should have a `{{integration_name_in_snake_case}}.py` file in `/engine/config_integrations`. There you'll find Templates that will be copied to the Integration Templates once the integration is created by the user in the OnCall UI; Example Payload; and Tests which should match the result of the rendering of Example Payload as using Templates. The best way to build such a file is to create Webhook Integration, write & debug templates in the UI first and copy-paste them to the file after. +2. Each integration should be listed in the `/engine/settings/base.py` file, section `INSTALLED_ONCALL_INTEGRATIONS`. +3. Each integration should have "How to connect" instruction stored as `integration_{{integration_name_in_snake_case}}.html` in the `engine/apps/integrations/html` folder. `.py` file has a `slug` field that is used to locate `.html` file. + +# What do we expect from high-quality integration? + +1. User-friendly integration instruction. +2. Proper grouping following source's logics. If source generates multiple alerts per "detection" it would be nice to provide suitable grouping & resolving configuration in the templates. +3. Awesome rendering. We all love when alerts look good in Slack, SMS and all other rendering destinations. diff --git a/engine/config_integrations/zabbix.py b/engine/config_integrations/zabbix.py new file mode 100644 index 00000000..63b3e3b5 --- /dev/null +++ b/engine/config_integrations/zabbix.py @@ -0,0 +1,62 @@ +# Main +enabled = True +title = "Zabbix" +slug = "zabbix" +short_description = None +description = None +is_displayed_on_web = True +is_featured = False +is_able_to_autoresolve = True +is_demo_alert_enabled = True + +description = None + +# Default templates +slack_title = """\ +*<{{ grafana_oncall_link }}|#{{ grafana_oncall_incident_id }} {{ payload.get("title", "Title undefined (check Slack Title Template)") }}>* via {{ integration_name }} +{% if source_link %} + (*<{{ source_link }}|source>*) +{%- endif %}""" + +slack_message = '{{ payload.get("message", "") }}' + +slack_image_url = '{{ payload.get("image_url", "") }}' + +web_title = '{{ payload.get("title", "Title undefined (check Web Title Template)") }}' + +web_message = slack_message + +web_image_url = slack_image_url + +sms_title = web_title + +phone_call_title = sms_title + +email_title = web_title + +email_message = web_message + +telegram_title = sms_title + +telegram_message = slack_message + +telegram_image_url = slack_image_url + +source_link = "{{ payload.link_to_upstream_details }}" + +grouping_id = '{{ payload.get("alert_uid", "")}}' + +resolve_condition = '{{ payload.get("state", "").upper() == "OK" }}' + +acknowledge_condition = None + +group_verbose_name = web_title + +example_payload = { + "alert_uid": "08d6891a-835c-e661-39fa-96b6a9e26552", + "title": "TestAlert: The whole system is down", + "image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ee/Grumpy_Cat_by_Gage_Skidmore.jpg", + "state": "alerting", + "link_to_upstream_details": "https://en.wikipedia.org/wiki/Downtime", + "message": "This alert was sent by user for the demonstration purposes\nSmth happened. Oh no!", +} diff --git a/engine/engine/management/commands/verify_phone.py b/engine/engine/management/commands/verify_phone.py new file mode 100644 index 00000000..80e6a7d7 --- /dev/null +++ b/engine/engine/management/commands/verify_phone.py @@ -0,0 +1,52 @@ +from django.core.management.base import BaseCommand + +from apps.twilioapp.twilio_client import twilio_client +from apps.twilioapp.utils import check_phone_number_is_valid +from apps.user_management.models import User + + +class Command(BaseCommand): + """ + This command is to manually verify user's phone numbers. + """ + + def add_arguments(self, parser): + parser.add_argument("user_id", type=int, help="User id to manually verify phone number") + parser.add_argument("phone_number", type=str, help="Phone number to verify") + + parser.add_argument( + "--override", + action="store_true", + help="Override existing phone number", + ) + + def handle(self, *args, **options): + user_id = options["user_id"] + phone_number = options["phone_number"] + + if not check_phone_number_is_valid(phone_number): + self.stdout.write(self.style.ERROR('Invalid phone number "%s"' % phone_number)) + return + + try: + user = User.objects.get(pk=user_id) + except User.objects.DoesNotExists: + self.stdout.write(self.style.ERROR('Invalid user_id "%s"' % user_id)) + return + + if user.verified_phone_number and not options["override"]: + self.stdout.write(self.style.ERROR('User "%s" already has a phone number' % user_id)) + return + + normalized_phone_number, _ = twilio_client.normalize_phone_number_via_twilio(phone_number) + if normalized_phone_number: + user.save_verified_phone_number(normalized_phone_number) + user.unverified_phone_number = phone_number + user.save(update_fields=["unverified_phone_number"]) + else: + self.stdout.write(self.style.ERROR('Invalid phone number "%s"' % phone_number)) + return + + self.stdout.write( + self.style.SUCCESS('Successfully verified phone number "%s" for user "%s"' % (phone_number, user_id)) + ) diff --git a/engine/engine/middlewares.py b/engine/engine/middlewares.py index 90c1e130..cf5878ad 100644 --- a/engine/engine/middlewares.py +++ b/engine/engine/middlewares.py @@ -23,19 +23,21 @@ class RequestTimeLoggingMiddleware(MiddlewareMixin): seconds = (dt - request._logging_start_dt).total_seconds() status_code = 0 if response is None else response.status_code content_length = request.headers.get("content-length", default=0) - integration_type = "N/A" - integration_token = "N/A" + message = ( + "inbound " + f"latency={str(seconds)} status={status_code} method={request.method} path={request.path} " + f"content-length={content_length} slow={int(seconds > settings.SLOW_THRESHOLD_SECONDS)} " + ) + if hasattr(request, "user") and request.user and request.user.id: + user_id = request.user.id + org_id = request.user.organization_id + message += f"user_id={user_id} org_id={org_id} " if request.path.startswith("/integrations/v1"): split_path = request.path.split("/") integration_type = split_path[3] integration_token = split_path[4] - logging.info( - "inbound " - f"latency={str(seconds)} status={status_code} method={request.method} path={request.path} " - f"content-length={content_length} slow={int(seconds > settings.SLOW_THRESHOLD_SECONDS)} " - f"integration_type={integration_type} " - f"integration_token={integration_token}" - ) + message += f"integration_type={integration_type} integration_token={integration_token} " + logging.info(message) def process_request(self, request): self.log_message(request, None, "request") diff --git a/engine/settings/base.py b/engine/settings/base.py index e3798b7b..49669434 100644 --- a/engine/settings/base.py +++ b/engine/settings/base.py @@ -50,7 +50,7 @@ BASE_URL = os.environ.get("BASE_URL") # Root URL of OnCall backend # Feature toggles FEATURE_LIVE_SETTINGS_ENABLED = getenv_boolean("FEATURE_LIVE_SETTINGS_ENABLED", default=True) FEATURE_TELEGRAM_INTEGRATION_ENABLED = getenv_boolean("FEATURE_TELEGRAM_INTEGRATION_ENABLED", default=True) -FEATURE_EMAIL_INTEGRATION_ENABLED = getenv_boolean("FEATURE_EMAIL_INTEGRATION_ENABLED", default=False) +FEATURE_EMAIL_INTEGRATION_ENABLED = getenv_boolean("FEATURE_EMAIL_INTEGRATION_ENABLED", default=True) FEATURE_SLACK_INTEGRATION_ENABLED = getenv_boolean("FEATURE_SLACK_INTEGRATION_ENABLED", default=True) FEATURE_WEB_SCHEDULES_ENABLED = getenv_boolean("FEATURE_WEB_SCHEDULES_ENABLED", default=False) GRAFANA_CLOUD_ONCALL_HEARTBEAT_ENABLED = getenv_boolean("GRAFANA_CLOUD_ONCALL_HEARTBEAT_ENABLED", default=True) @@ -570,7 +570,7 @@ EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER") EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") EMAIL_PORT = getenv_integer("EMAIL_PORT", 587) EMAIL_USE_TLS = getenv_boolean("EMAIL_USE_TLS", True) -DEFAULT_FROM_EMAIL = os.getenv("DEFAULT_FROM_EMAIL") +EMAIL_FROM_ADDRESS = os.getenv("EMAIL_FROM_ADDRESS") if FEATURE_EMAIL_INTEGRATION_ENABLED: EXTRA_MESSAGING_BACKENDS = [("apps.email.backend.EmailBackend", 8)] @@ -588,6 +588,7 @@ INSTALLED_ONCALL_INTEGRATIONS = [ "config_integrations.maintenance", "config_integrations.manual", "config_integrations.slack_channel", + "config_integrations.zabbix", ] if OSS_INSTALLATION: diff --git a/grafana-plugin/.stylelintrc b/grafana-plugin/.stylelintrc index c37d4c08..31c2b181 100644 --- a/grafana-plugin/.stylelintrc +++ b/grafana-plugin/.stylelintrc @@ -3,6 +3,10 @@ "plugins": ["stylelint-prettier"], "rules": { "block-no-empty": [true, { "severity": "warning" }], + "selector-max-type": [ 0, { + "severity": "error", + "ignore": ["child", "compounded", "descendant", "next-sibling"] + }], "selector-pseudo-class-no-unknown": [ true, { diff --git a/grafana-plugin/package.json b/grafana-plugin/package.json index 9398e5c9..ea95dd57 100644 --- a/grafana-plugin/package.json +++ b/grafana-plugin/package.json @@ -5,8 +5,8 @@ "scripts": { "lint": "eslint --cache --ext .js,.jsx,.ts,.tsx --max-warnings=0 ./src", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --max-warnings=0 --quiet ./src", - "stylelint": "stylelint ./src/**/*.css", - "stylelint:fix": "stylelint --fix ./src/**/*.css", + "stylelint": "stylelint ./src/**/*.{css,scss,module.css,module.scss}", + "stylelint:fix": "stylelint --fix ./src/**/*.{css,scss,module.css,module.scss}", "build": "grafana-toolkit plugin:build", "test": "jest --verbose", "dev": "grafana-toolkit plugin:dev", diff --git a/grafana-plugin/src/components/GBlock/Block.module.css b/grafana-plugin/src/components/GBlock/Block.module.css index cb56c069..49f4ed2d 100644 --- a/grafana-plugin/src/components/GBlock/Block.module.css +++ b/grafana-plugin/src/components/GBlock/Block.module.css @@ -4,11 +4,11 @@ } :global(.theme-dark) .root_bordered { - border: var(--border); + border: var(--border-weak); } :global(.theme-light) .root_bordered { - border: var(--border); + border: var(--border-weak); } :global(.theme-dark) .root_shadowed { diff --git a/grafana-plugin/src/components/ScheduleBorderedAvatar/ScheduleBorderedAvatar.module.scss b/grafana-plugin/src/components/ScheduleBorderedAvatar/ScheduleBorderedAvatar.module.scss index 0e179253..d65587a4 100644 --- a/grafana-plugin/src/components/ScheduleBorderedAvatar/ScheduleBorderedAvatar.module.scss +++ b/grafana-plugin/src/components/ScheduleBorderedAvatar/ScheduleBorderedAvatar.module.scss @@ -1,12 +1,14 @@ .root { position: relative; } + .avatar { position: absolute; - top: 0px; - left: 0px; + top: 0; + left: 0; z-index: -1; } + .icon { position: relative; top: -8px; diff --git a/grafana-plugin/src/components/SourceCode/SourceCode.module.scss b/grafana-plugin/src/components/SourceCode/SourceCode.module.scss index ec139080..76c51d24 100644 --- a/grafana-plugin/src/components/SourceCode/SourceCode.module.scss +++ b/grafana-plugin/src/components/SourceCode/SourceCode.module.scss @@ -1,10 +1,6 @@ .root { position: relative; width: 100%; - - &:hover .copyButton { - opacity: 1; - } } .scroller { @@ -24,6 +20,11 @@ right: 15px; transition: opacity 0.2s ease; } + .copyButton { opacity: 0; } + +.root:hover .copyButton { + opacity: 1; +} diff --git a/grafana-plugin/src/components/Text/Text.module.scss b/grafana-plugin/src/components/Text/Text.module.scss index febd6c75..618bb298 100644 --- a/grafana-plugin/src/components/Text/Text.module.scss +++ b/grafana-plugin/src/components/Text/Text.module.scss @@ -6,31 +6,39 @@ &--primary { color: var(--primary-text-color); } + &--secondary { color: var(--secondary-text-color); } + &--disabled { color: var(--disabled-text-color); } + &--warning { color: var(--warning-text-color); } + &--link { color: var(--primary-text-link); - text-decoration: underline; } + &--success { color: var(--green-5); } + &--strong { font-weight: bold; } + &--underline { text-decoration: underline; } + &--small { font-size: 12px; } + &--large { font-size: 20px; } diff --git a/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.module.css b/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.module.css new file mode 100644 index 00000000..0083dc6f --- /dev/null +++ b/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.module.css @@ -0,0 +1,11 @@ +.slack-infoblock { + width: 725px; +} + +.slack-infoblock input { + color: var(--primary-text-link); +} + +.slack-icon { + width: 60px; +} diff --git a/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.tsx b/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.tsx new file mode 100644 index 00000000..edd7a21b --- /dev/null +++ b/grafana-plugin/src/containers/SlackInstructions/SlackInstructions.tsx @@ -0,0 +1,71 @@ +import React, { FC } from 'react'; + +import { Button, VerticalGroup, Icon, Field, Input } from '@grafana/ui'; +import cn from 'classnames/bind'; +import { observer } from 'mobx-react'; + +import Block from 'components/GBlock/Block'; +import Text from 'components/Text/Text'; +import { SlackNewIcon } from 'icons'; + +import styles from './SlackInstructions.module.css'; + +const cx = cn.bind(styles); + +interface SlackInstructionsProps {} +/* This component will be used when we will work on moving ENV variables to chat-ops, but we need to do work on backend side first */ +const SlackInstructions: FC = observer(() => { + return ( +
+ + Connect Slack workspace + + + + + You can manage alert groups in your Slack workspace. + Before start you need to connect your Slack bot to Grafana OnCall. + + For bot creating instructions and additional information please read{' '} + + our documentation + + {' '} + + + Setup environment + + Create OnCall Slack bot using{' '} + + our instructions + {' '} + and fill out app credentials below. + +
+ + {}} defaultValue={'appId'} /> + + + {}} defaultValue={'clientsecret'} /> + + + {}} defaultValue={'signingsecret'} /> + + + {}} defaultValue={'https://'} /> + +
+ + + Your host to Slack must start with “https://” and be publicly available (meaning + that it can be reached by Slack servers). If your host is private or local, you can use redirecting services + like Ngrok. + + + + +
+ ); +}); + +export default SlackInstructions; diff --git a/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx b/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx index f5e9d366..2b1fdbc5 100644 --- a/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx +++ b/grafana-plugin/src/containers/SlackIntegrationButton/SlackIntegrationButton.tsx @@ -63,7 +63,7 @@ const SlackIntegrationButton = observer((props: { className: string; disabled?: disabled={disabled} onClick={onInstallModalCallback} > - Install Slack integration + Connect Slack {showModal && } @@ -80,8 +80,8 @@ const SlackModal = (props: SlackModalProps) => { const { onHide, onConfirm } = props; return ( - -
+ +
You can view your Slack Workspace at the top-right corner after you are redirected. It should be a Workspace with App Bot installed:
diff --git a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.module.css b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.module.css index 59d60c4e..8ec18f73 100644 --- a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.module.css +++ b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.module.css @@ -19,3 +19,18 @@ .telegram-instruction-cancel { margin-top: 24px; } + +.telegram-block { + width: 100%; +} + +.field-command { + margin-top: 8px; + width: 100%; + display: inline-block; +} + +.infoblock-text { + margin-left: 48px; + margin-right: 48px; +} diff --git a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx index 692e1fd7..4c307180 100644 --- a/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx +++ b/grafana-plugin/src/containers/TelegramIntegrationButton/TelegramIntegrationButton.tsx @@ -1,10 +1,11 @@ import React, { useCallback, useState, useEffect } from 'react'; -import { Button, Modal, Icon, HorizontalGroup } from '@grafana/ui'; +import { Button, Modal, Icon, HorizontalGroup, VerticalGroup, Field, Input } from '@grafana/ui'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; +import Block from 'components/GBlock/Block'; import Text from 'components/Text/Text'; import { WithPermissionControl } from 'containers/WithPermissionControl/WithPermissionControl'; import { useStore } from 'state/useStore'; @@ -44,7 +45,7 @@ const TelegramIntegrationButton = observer((props: TelegramIntegrationProps) => <> {showModal && } @@ -73,101 +74,66 @@ const TelegramModal = (props: TelegramModalProps) => { }, []); return ( - -
- Follow these steps to create and connect to a dedicated OnCall channel. -
- -
- - If you already have a dedicated channel to use with OnCall, you can use the following activation code:{' '} - {verificationCode} - - { - openNotification('Verification code copied'); - }} - > - - - + + + + + If you already have a private channel to work with OnCall, use the following activation code: + + + { + openNotification('Code is copied'); + }} + > + + + } + /> + + + Setup new channel + + 1. Open Telegram, create a new Private Channel and enable{' '} + Sign Messages in settings. -
- -
- 1. Create a New Channel, and set it to Private. -
- -
- - 2. In Manage Channel, make sure Sign messages is enabled. + + 2. Create a new Discussion group. This group handles alert actions and comments.{' '} -
- -
- 3. Create a new discussion group. This group handles alert actions and comments. -
- -
- - 4. Add the discussion group to the channel. In Manage Channel, click Discussion to find and add - the new group. + + 3. Connect the discussion group with the channel. In Manage Channel, click{' '} + Discussion to find and add your group.{' '} -
- -
- - 5. Click{' '} - - {botLink} - {' '} - to add the OnCall bot to your contacts. Add the bot to your channel as an Admin. Allow it to{' '} - Post Messages. + + 4. Go to {botLink} to add the OnCall bot to your contacts. Then add the bot to your + channel as an Admin and allow it to Post Messages. -
- -
- 6. Add the bot to the discussion group. -
- -
- - 7. Send the verification code, {verificationCode} - - { - openNotification('Verification code copied'); - }} - > - - - {' '} - , to the channel and wait for the confirmation message. + 5. Add the bot to the discussion group. + + 6. Send this verification code to the channel and wait for the confirmation message: + + { + openNotification('Code is copied'); + }} + > + + + } + /> + -
- -
- 8. Make sure users connect their Telegram accounts in their OnCall user profile. -
- -
- 9. Done! Now you can manage alerts in your Telegram workspace. -
- -
- - Each alert group notification is assigned a dedicated discussion. Users can perform notification actions - (acknowledge, resolve, silence) and discuss alerts in the comments section of the discussions. - - -
- -
+ 7. Start to manage alerts in your team Telegram workspace. -
+
); }; diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.module.css b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.module.css index ce2afbc6..51473abb 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.module.css +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.module.css @@ -2,3 +2,13 @@ display: flex; justify-content: flex-end; } + +.slack-infoblock { + text-align: center; + width: 725px; +} + +.external-link-style { + margin-right: 4px; + align-self: baseline; +} diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx index 4edd5ab5..3a305949 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/SlackTab/SlackTab.tsx @@ -1,9 +1,11 @@ import React, { useCallback } from 'react'; -import { Button, VerticalGroup } from '@grafana/ui'; +import { Button, VerticalGroup, Icon } from '@grafana/ui'; import cn from 'classnames/bind'; +import Block from 'components/GBlock/Block'; import Text from 'components/Text/Text'; +import { SlackNewIcon } from 'icons'; import { useStore } from 'state/useStore'; import styles from './SlackTab.module.css'; @@ -18,20 +20,32 @@ export const SlackTab = () => { }, [slackStore]); return ( - - - You can view your Slack Workspace at the top-right corner after you are redirected. It should be a Workspace - with App Bot installed: - - -
- -
+ + + + + + Personal Slack connection will allow you to manage alert grouops in your connected team Internal Slack + workspace. + + To setup personal Slack click the button below, choose workspace and click Allow. + + + More details in{' '} + + our documentation + + + + + + + ); }; diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.module.css b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.module.css index b5c7e681..fea6889e 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.module.css +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.module.css @@ -6,3 +6,15 @@ display: flex; justify-content: space-between; } + +.automatic-connect-telegram-block { + width: 100%; + display: flex; + justify-content: space-between; + margin-bottom: 24px; +} + +.field-command { + width: 100%; + display: inline-block; +} diff --git a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx index c0378cae..f0750886 100644 --- a/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx +++ b/grafana-plugin/src/containers/UserSettings/parts/tabs/TelegramInfo/TelegramInfo.tsx @@ -1,12 +1,14 @@ import React, { HTMLAttributes, useEffect, useState } from 'react'; -import { Alert, Button, HorizontalGroup, Icon, VerticalGroup } from '@grafana/ui'; +import { Button, Icon, VerticalGroup, Field, Input } from '@grafana/ui'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; import CopyToClipboard from 'react-copy-to-clipboard'; +import Block from 'components/GBlock/Block'; import PluginLink from 'components/PluginLink/PluginLink'; import Text from 'components/Text/Text'; +import { TelegramColorIcon } from 'icons'; import { AppFeature } from 'state/features'; import { useStore } from 'state/useStore'; import { openNotification } from 'utils'; @@ -37,45 +39,66 @@ const TelegramInfo = observer((_props: TelegramInfoProps) => { <> {telegramConfigured || !store.hasFeature(AppFeature.LiveSettings) ? ( - - - - Or add bot manually: - - - 1) Go to{' '} - - {botLink} - - - - - 2) Send - {verificationCode} - { - openNotification('Verification code copied'); - }} - > - - - to telegram bot - + Connect personal Telegram + + Connect Telegram automatically + + + + + Manual connection + + + 1. Go to{' '} + + {botLink} + + + + + 2. Send this verification code to the bot and wait for the confirmation message: + + + { + openNotification('Code is copied'); + }} + > + + + } + /> + + 3. Refresh the page and start to manage alerts in your personal Telegram. ) : ( - - Can't connect Telegram. Check ENV variables{' '} - related to Telegram. - - } - /> + + Connect Telegram workspace + + + + You can manage alert groups in your team Telegram channel or from personal direct messages. + + + To connect channel setup Telegram environment first, which includes connection to your bot and host URL. + + + More details in{' '} + + our documentation + + + + + + + + )} ); diff --git a/grafana-plugin/src/icons/index.tsx b/grafana-plugin/src/icons/index.tsx index 896d4576..c5675c28 100644 --- a/grafana-plugin/src/icons/index.tsx +++ b/grafana-plugin/src/icons/index.tsx @@ -273,3 +273,59 @@ export const IsOncallIcon = (props: IsOncallIconProps) => { ); }; + +export const TelegramColorIcon = () => { + return ( + + + + + + + ); +}; +export const SlackNewIcon = () => ( + + + + + + + + + + +); diff --git a/grafana-plugin/src/img/slack_instructions.png b/grafana-plugin/src/img/slack_instructions.png new file mode 100644 index 00000000..0093b533 Binary files /dev/null and b/grafana-plugin/src/img/slack_instructions.png differ diff --git a/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.module.css b/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.module.css index b9ab506c..49111eb0 100644 --- a/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.module.css +++ b/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.module.css @@ -15,3 +15,27 @@ margin-bottom: 20px; border-bottom: 1px solid rgba(204, 204, 220, 0.25); } + +.slack-infoblock { + text-align: center; + width: 725px; +} + +.external-link-style { + margin-right: 4px; + align-self: baseline; +} + +.team_workspace { + height: 30px; +} + +.infoblock-text { + margin-left: 48px; + margin-right: 48px; + margin-top: 24px; +} + +.infoblock-icon { + margin-top: 24px; +} diff --git a/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.tsx b/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.tsx index 67abb7d5..3bd3e13e 100644 --- a/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.tsx +++ b/grafana-plugin/src/pages/chat-ops/parts/tabs/SlackSettings/SlackSettings.tsx @@ -1,17 +1,17 @@ import React, { Component } from 'react'; -import { Field, HorizontalGroup, LoadingPlaceholder, VerticalGroup } from '@grafana/ui'; +import { Field, HorizontalGroup, LoadingPlaceholder, VerticalGroup, Icon, Button } from '@grafana/ui'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; +import Block from 'components/GBlock/Block'; import PluginLink from 'components/PluginLink/PluginLink'; import Text from 'components/Text/Text'; -import Tutorial from 'components/Tutorial/Tutorial'; -import { TutorialStep } from 'components/Tutorial/Tutorial.types'; +import WithConfirm from 'components/WithConfirm/WithConfirm'; import GSelect from 'containers/GSelect/GSelect'; import RemoteSelect from 'containers/RemoteSelect/RemoteSelect'; -import SlackIntegrationButton from 'containers/SlackIntegrationButton/SlackIntegrationButton'; import { WithPermissionControl } from 'containers/WithPermissionControl/WithPermissionControl'; +import { SlackNewIcon } from 'icons'; import { PRIVATE_CHANNEL_NAME } from 'models/slack_channel/slack_channel.config'; import { SlackChannel } from 'models/slack_channel/slack_channel.types'; import { AppFeature } from 'state/features'; @@ -25,16 +25,32 @@ const cx = cn.bind(styles); interface SlackProps extends WithStoreProps {} -interface SlackState {} +interface SlackState { + showENVVariablesButton: boolean; +} @observer class SlackSettings extends Component { - state: SlackState = {}; + state: SlackState = { + showENVVariablesButton: false, + }; componentDidMount() { - this.update(); + const { store } = this.props; + if (store.hasFeature(AppFeature.LiveSettings)) { + this.getSlackLiveSettings().then(() => { + this.update(); + }); + } else { + this.update(); + } } + handleOpenSlackInstructions = () => { + const { store } = this.props; + store.slackStore.installSlackIntegration(); + }; + update = () => { const { store } = this.props; @@ -42,6 +58,27 @@ class SlackSettings extends Component { store.slackStore.updateSlackSettings(); }; + getSlackLiveSettings = async () => { + const { store } = this.props; + const results = await store.globalSettingStore.getAll(); + + const slackClientOAUTH = results.find((element: { name: string }) => element.name === 'SLACK_CLIENT_OAUTH_ID'); + const slackClientOAUTHSecret = results.find( + (element: { name: string }) => element.name === 'SLACK_CLIENT_OAUTH_SECRET' + ); + const slackRedirectHost = results.find((element: { name: string }) => element.name === 'SLACK_CLIENT_OAUTH_ID'); + const slackSigningSecret = results.find((element: { name: string }) => element.name === 'SLACK_SIGNING_SECRET'); + + if ( + slackClientOAUTH?.error || + slackClientOAUTHSecret?.error || + slackRedirectHost?.error || + slackSigningSecret?.error + ) { + this.setState({ showENVVariablesButton: true }); + } + }; + render() { const { store } = this.props; const { teamStore } = store; @@ -59,34 +96,47 @@ class SlackSettings extends Component { return (
- - Slack - -
- - - - - +
+ Slack
- + + + +
+ {store.teamStore.currentTeam.slack_team_identity?.cached_name} +
+
+ + + + + +
+ + + + + +
+
+
+ Additional settings - + {
- - Remove integration - -
); }; + renderSlackWorkspace = () => { + const { store } = this.props; + return {store.teamStore.currentTeam.slack_team_identity?.cached_name}; + }; + + renderSlackChannels = () => { + const { store } = this.props; + return ( + + + + ); + }; + + renderActionButtons = () => { + + + + + ; + }; + + removeSlackIntegration = () => { + const { store } = this.props; + store.slackStore.removeSlackIntegration().then(() => { + store.teamStore.loadCurrentTeam(); + }); + }; + getSlackSettingsChangeHandler = (field: string) => { const { store } = this.props; const { slackStore } = store; @@ -138,28 +225,56 @@ class SlackSettings extends Component { renderSlackStub = () => { const { store } = this.props; + const { showENVVariablesButton } = this.state; + const isLiveSettingAvailable = store.hasFeature(AppFeature.LiveSettings) && showENVVariablesButton; return ( - - - Bring the whole incident lifecycle to Slack, from alerts, monitoring, escalations to resolution notes and - reports. + + Connect Slack workspace + + +
+ +
+ + Slack connection will allow you to manage alert groups in your team Slack workspace. - - - - {store.hasFeature(AppFeature.LiveSettings) && ( - - Before installing check ENV variables related - to Slack please + + After a basic workspace connection your team members need to connect their personal Slack accounts in + order to be allowed to manage alert groups. + + {isLiveSettingAvailable && ( + + For bot creating instructions and additional information please read{' '} + + our documentation + )} + +
- } - /> +
+ {isLiveSettingAvailable ? ( + + + + ) : ( + + + {store.hasFeature(AppFeature.LiveSettings) && ( + + + + )} + + )} +
); }; } diff --git a/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.module.css b/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.module.css index 837f409b..158c14a2 100644 --- a/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.module.css +++ b/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.module.css @@ -6,3 +6,22 @@ display: flex; justify-content: space-between; } + +.telegram-infoblock { + text-align: center; + width: 725px; +} + +.features-list > ul { + margin: 20px 30px; +} + +.infoblock-text { + margin-left: 48px; + margin-right: 48px; + margin-top: 24px; +} + +.infoblock-icon { + margin-top: 24px; +} diff --git a/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.tsx b/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.tsx index d8b694c6..c6eb5dc5 100644 --- a/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.tsx +++ b/grafana-plugin/src/pages/chat-ops/parts/tabs/TelegramSettings/TelegramSettings.tsx @@ -1,16 +1,16 @@ import React, { Component } from 'react'; -import { Alert, Button, HorizontalGroup, Icon, LoadingPlaceholder, VerticalGroup } from '@grafana/ui'; +import { Badge, Button, HorizontalGroup, Icon, LoadingPlaceholder, VerticalGroup } from '@grafana/ui'; import cn from 'classnames/bind'; import { observer } from 'mobx-react'; +import Block from 'components/GBlock/Block'; import GTable from 'components/GTable/GTable'; import PluginLink from 'components/PluginLink/PluginLink'; import Text from 'components/Text/Text'; -import Tutorial from 'components/Tutorial/Tutorial'; -import { TutorialStep } from 'components/Tutorial/Tutorial.types'; import WithConfirm from 'components/WithConfirm/WithConfirm'; import TelegramIntegrationButton from 'containers/TelegramIntegrationButton/TelegramIntegrationButton'; +import { TelegramColorIcon } from 'icons'; import { TelegramChannel } from 'models/telegram_channel/telegram_channel.types'; import { AppFeature } from 'state/features'; import { WithStoreProps } from 'state/types'; @@ -47,16 +47,32 @@ class TelegramSettings extends Component { if (!telegramConfigured && store.hasFeature(AppFeature.LiveSettings)) { return ( - - Can't connect Telegram. Check ENV variables{' '} - related to Telegram. - - } - /> + + Connect Telegram workspace + + +
+ +
+ + You can manage alert groups in your team Telegram channel or from personal direct messages.{' '} + + + + To connect channel setup Telegram environment first, which includes connection to your bot and host URL. + + + More details in{' '} + + our documentation + + +
+
+ + + +
); } @@ -66,38 +82,59 @@ class TelegramSettings extends Component { if (!connectedChannels.length) { return ( - - - Bring the whole incident lifecycle into your chat workspace. Everything from alerts, monitoring, and - escalations to reports. + + Connect Telegram workspace + + +
+ +
+ + You can manage alert groups in your team Telegram channel or from personal direct messages.{' '} + + + More details in{' '} + + our documentation + -
- } - /> +
+ + Features +
+
    +
  • perform actions (acknowledge, resolve, silence)
  • +
  • discuss alerts in comments
  • +
  • notifications to users accounts will be served as links to the main channel
  • +
+
+ Make sure your team connects Telegram in their OnCall user profiles too or they cannot manage alert groups. +
+ + + {store.hasFeature(AppFeature.LiveSettings) && ( + + + + )} + +
); } const columns = [ { - width: '30%', - title: 'Channel name', - dataIndex: 'channel_name', + width: '35%', + title: 'Channel', + key: 'name', + render: this.renderChannelName, }, { - width: '30%', - title: 'Discussion group name', + width: '35%', + title: 'Discussion group', dataIndex: 'discussion_group_name', }, - { - width: '10%', - title: 'Is default channel', - dataIndex: 'is_default_channel', - render: this.renderDefaultChannel, - }, { width: '30%', key: 'action', @@ -126,6 +163,13 @@ class TelegramSettings extends Component { ); } + renderChannelName = (record: TelegramChannel) => { + return ( + <> + {record.channel_name} {record.is_default_channel && } + + ); + }; renderDefaultChannel = (isDefault: boolean) => { return <>{isDefault && }; }; diff --git a/grafana-plugin/src/pages/livesettings/LiveSettingsPage.tsx b/grafana-plugin/src/pages/livesettings/LiveSettingsPage.tsx index 7028e366..db5cd138 100644 --- a/grafana-plugin/src/pages/livesettings/LiveSettingsPage.tsx +++ b/grafana-plugin/src/pages/livesettings/LiveSettingsPage.tsx @@ -89,13 +89,13 @@ class LiveSettings extends React.Component { width: '20%', title: 'Value', - render: this.renderValue, + render: (item: GlobalSetting) => this.renderValue(item), // to avoid caching previous render result key: 'value', }, { width: '20%', title: 'ENV or default', - render: this.renderDefault, + render: (item: GlobalSetting) => this.renderDefault(item), // to avoid caching previous render result key: 'default', }, { diff --git a/helm/oncall/Chart.lock b/helm/oncall/Chart.lock new file mode 100644 index 00000000..a91cbcb0 --- /dev/null +++ b/helm/oncall/Chart.lock @@ -0,0 +1,24 @@ +dependencies: +- name: cert-manager + repository: https://charts.jetstack.io + version: v1.8.0 +- name: mariadb + repository: https://charts.bitnami.com/bitnami + version: 11.0.10 +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.9.10 +- name: rabbitmq + repository: https://charts.bitnami.com/bitnami + version: 10.1.1 +- name: redis + repository: https://charts.bitnami.com/bitnami + version: 16.10.1 +- name: grafana + repository: https://grafana.github.io/helm-charts + version: 6.29.6 +- name: ingress-nginx + repository: https://kubernetes.github.io/ingress-nginx + version: 4.1.4 +digest: sha256:8e17f2f6a087b6db52670458fc0e1cb39b0a3f7962ff7ebbc7be4c982a4e1720 +generated: "2022-10-18T11:22:39.061819+02:00" diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index f7708ca6..b1b7e18a 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -8,13 +8,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.6 +version: 1.0.8 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "v1.0.40" +appVersion: "v1.0.49" dependencies: - name: cert-manager version: v1.8.0 @@ -25,6 +25,10 @@ dependencies: version: 11.0.10 repository: https://charts.bitnami.com/bitnami condition: mariadb.enabled + - name: postgresql + version: 11.9.10 + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled - name: rabbitmq version: 10.1.1 repository: https://charts.bitnami.com/bitnami diff --git a/helm/oncall/README.md b/helm/oncall/README.md index 87a41f0d..92fcd911 100644 --- a/helm/oncall/README.md +++ b/helm/oncall/README.md @@ -6,23 +6,27 @@ It will also deploy cert manager and nginx ingress controller, as Grafana OnCall to receive alerts from other monitoring systems. Grafana OnCall engine acts as a backend and can be connected to the Grafana frontend plugin named Grafana OnCall. Architecture diagram can be found [here](https://raw.githubusercontent.com/grafana/oncall/dev/docs/img/architecture_diagram.png) +## Production usage -### Production usage **Default helm chart configuration is not intended for production.** The helm chart includes all the services into a single release, which is not recommended for production usage. It is recommended to run stateful services such as MySQL and RabbitMQ separately from this release or use managed PaaS solutions. It will significantly reduce the overhead of managing them. Here are the instructions on how to set up your own [ingress](#set-up-external-access), [MySQL](#connect-external-mysql), [RabbitMQ](#connect-external-rabbitmq), [Redis](#connect-external-redis) - ### Cluster requirements + * ensure you can run x86-64/amd64 workloads. arm64 architecture is currently not supported * kubernetes version 1.25+ is not supported, if cert-manager is enabled ## Install + ### Prepare the repo -``` + +```bash # Add the repository helm repo add grafana https://grafana.github.io/helm-charts helm repo update ``` + ### Installing the helm chart + ```bash # Install the chart helm install \ @@ -34,7 +38,8 @@ helm install \ ``` Follow the `helm install` output to finish setting up Grafana OnCall backend and Grafana OnCall frontend plugin e.g. -``` + +```bash 👋 Your Grafana OnCall instance has been successfully deployed ❗ Set up a DNS record for your domain (use A Record and "@" to point a root domain to the IP address) @@ -73,6 +78,7 @@ Follow the `helm install` output to finish setting up Grafana OnCall backend and ## Configuration You can edit values.yml to make changes to the helm chart configuration and re-deploy the release with the following command: + ```bash helm upgrade \ --install \ @@ -87,7 +93,7 @@ helm upgrade \ You can set up Slack connection via following variables: -``` +```yaml oncall: slack: enabled: true @@ -103,7 +109,7 @@ oncall: To set up Telegram tokem and webhook url use: -``` +```yaml oncall: telegram: enabled: true @@ -112,13 +118,14 @@ oncall: ``` ### Set up external access + Grafana OnCall can be connected to the external monitoring systems or grafana deployed to the other cluster. Nginx Ingress Controller and Cert Manager charts are included in the helm chart with the default configuration. -If you set the DNS A Record pointing to the external IP address of the installation with the Hostname matching base_url parameter, https will be automatically set up. If grafana is enabled in the chart values, it will also be available on https:///grafana/. See the details in `helm install` output. +If you set the DNS A Record pointing to the external IP address of the installation with the Hostname matching base_url parameter, https will be automatically set up. If grafana is enabled in the chart values, it will also be available on `https:///grafana/`. See the details in `helm install` output. To use a different ingress controller or tls certificate management system, set the following values to false and edit ingress settings -``` +```yaml ingress-nginx: enabled: false @@ -132,18 +139,36 @@ ingress: cert-manager.io/issuer: "letsencrypt-prod" ``` +### Use PostgreSQL instead of MySQL + +It is possible to use PostgreSQL instead of MySQL. To do so, set mariadb.enabled to `false`, +postgresql.enabled to `true` and database.type to `postgresql`. + +```yaml +mariadb: + enabled: false + +postgresql: + enabled: true + +database: + type: postgresql +``` + ### Connect external MySQL It is recommended to use the managed MySQL 5.7 database provided by your cloud provider Make sure to create the database with the following parameters before installing this chart -``` + +```sql CREATE DATABASE oncall CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ``` -To use an external MySQL instance set mysql.enabled to `false` and configure the `externalMysql` parameters. -``` +To use an external MySQL instance set mariadb.enabled to `false` and configure the `externalMysql` parameters. + +```yaml mariadb: - enabled: true + enabled: false # Make sure to create the database with the following parameters: # CREATE DATABASE oncall CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -155,13 +180,42 @@ externalMysql: password: ``` +### Connect external PostgreSQL + +To use an external PostgreSQL instance set mariadb.enabled to `false`, +postgresql.enabled to `false`, database.type to `postgresql` and configure +the `externalPostgresql` parameters. + +```yaml +mariadb: + enabled: false + +postgresql: + enabled: false + +database: + type: postgresql + +# Make sure to create the database with the following parameters: +# CREATE DATABASE oncall CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +externalPostgresql: + host: + port: + db_name: + user: + password: + existingSecret: "" + passwordKey: password + ``` + ### Connect external RabbitMQ Option 1. Install RabbitMQ separately into the cluster using the [official documentation](https://www.rabbitmq.com/kubernetes/operator/operator-overview.html) Option 2. Use managed solution such as [CloudAMPQ](https://www.cloudamqp.com/) To use an external RabbitMQ instance set rabbitmq.enabled to `false` and configure the `externalRabbitmq` parameters. -``` + +```yaml rabbitmq: enabled: false # Disable the RabbitMQ dependency from the release @@ -170,12 +224,18 @@ externalRabbitmq: port: user: password: + protocol: + vhost: + existingSecret: "" + passwordKey: password + usernameKey: username ``` ### Connect external Redis To use an external Redis instance set redis.enabled to `false` and configure the `externalRedis` parameters. -``` + +```yaml redis: enabled: false # Disable the Redis dependency from the release @@ -185,7 +245,8 @@ externalRedis: ``` ## Update -```shell + +```bash # Add & upgrade the repository helm repo add grafana https://grafana.github.io/helm-charts helm repo update @@ -203,19 +264,23 @@ helm upgrade \ After re-deploying, please also update the Grafana OnCall plugin on the plugin version page. See [Grafana docs](https://grafana.com/docs/grafana/latest/administration/plugin-management/#update-a-plugin) for more info on updating Grafana plugins. ## Uninstall + ### Uninstalling the helm chart + ```bash helm delete release-oncall ``` ### Clean up PVC's + ```bash kubectl delete pvc data-release-oncall-mariadb-0 data-release-oncall-rabbitmq-0 \ redis-data-release-oncall-redis-master-0 redis-data-release-oncall-redis-replicas-0 \ redis-data-release-oncall-redis-replicas-1 redis-data-release-oncall-redis-replicas-2 ``` - + ### Clean up secrets + ```bash kubectl delete secrets certificate-tls release-oncall-cert-manager-webhook-ca release-oncall-ingress-nginx-admission ``` diff --git a/helm/oncall/charts/postgresql-11.9.10.tgz b/helm/oncall/charts/postgresql-11.9.10.tgz new file mode 100644 index 00000000..2e267653 Binary files /dev/null and b/helm/oncall/charts/postgresql-11.9.10.tgz differ diff --git a/helm/oncall/templates/NOTES.txt b/helm/oncall/templates/NOTES.txt index 675e20a5..d2a3290c 100644 --- a/helm/oncall/templates/NOTES.txt +++ b/helm/oncall/templates/NOTES.txt @@ -37,7 +37,7 @@ Issue the one-time token to connect Grafana OnCall backend and Grafana OnCall plugin by running these commands: export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oncall.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=engine" -o jsonpath="{.items[0].metadata.name}") - kubectl exec -it $POD_NAME -- bash -c "python manage.py issue_invite_for_the_frontend --override" + kubectl exec -it $POD_NAME --namespace {{ .Release.Namespace }} -- bash -c "python manage.py issue_invite_for_the_frontend --override" Fill the Grafana OnCall Backend URL: diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 25072fc1..746669ec 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -21,7 +21,9 @@ value: "True" - name: UWSGI_LISTEN value: "1024" -{{- end }} +- name: BROKER_TYPE + value: {{ .Values.broker.type | default "rabbitmq" }} +{{- end -}} {{- define "snippet.oncall.slack.env" -}} {{- if .Values.oncall.slack.enabled -}} @@ -36,12 +38,12 @@ - name: SLACK_SIGNING_SECRET value: {{ .Values.oncall.slack.signingSecret | default "" | quote }} - name: SLACK_INSTALL_RETURN_REDIRECT_HOST - value: "https://{{ .Values.base_url }}" + value: {{ .Values.oncall.slack.redirectHost | default (printf "https://%s" .Values.base_url) | quote }} {{- else -}} - name: FEATURE_SLACK_INTEGRATION_ENABLED value: {{ .Values.oncall.slack.enabled | toString | title | quote }} {{- end -}} -{{- end }} +{{- end -}} {{- define "snippet.oncall.telegram.env" -}} {{- if .Values.oncall.telegram.enabled -}} @@ -55,7 +57,36 @@ - name: FEATURE_TELEGRAM_INTEGRATION_ENABLED value: {{ .Values.oncall.telegram.enabled | toString | title | quote }} {{- end -}} -{{- end }} +{{- end -}} + +{{- define "snippet.oncall.twilio.env" -}} +{{- with .Values.oncall.twilio -}} +{{- if .accountSid }} +- name: TWILIO_ACCOUNT_SID + value: {{ .accountSid | quote }} +{{- end -}} +{{- if .authToken }} +- name: TWILIO_AUTH_TOKEN + value: {{ .authToken | quote }} +{{- end -}} +{{- if .phoneNumber }} +- name: TWILIO_NUMBER + value: {{ .phoneNumber | quote }} +{{- end -}} +{{- if .verifySid }} +- name: TWILIO_VERIFY_SERVICE_SID + value: {{ .verifySid | quote }} +{{- end -}} +{{- if .apiKeySid }} +- name: TWILIO_API_KEY_SID + value: {{ .apiKeySid | quote }} +{{- end -}} +{{- if .apiKeySecret }} +- name: TWILIO_API_KEY_SECRET + value: {{ .apiKeySecret | quote }} +{{- end -}} +{{- end -}} +{{- end -}} {{- define "snippet.celery.env" -}} {{- if .Values.celery.worker_queue }} @@ -78,7 +109,7 @@ - name: CELERY_WORKER_SHUTDOWN_INTERVAL value: {{ .Values.celery.worker_shutdown_interval }} {{- end -}} -{{- end }} +{{- end -}} {{- define "snippet.mysql.env" -}} - name: MYSQL_HOST @@ -121,8 +152,8 @@ {{- end -}} {{- define "snippet.mysql.db" -}} -{{- if and (not .Values.mariadb.enabled) .Values.externalMysql.db -}} -{{- required "externalMysql.db is required if not mariadb.enabled" .Values.externalMysql.db | quote}} +{{- if and (not .Values.mariadb.enabled) .Values.externalMysql.db_name -}} +{{- required "externalMysql.db is required if not mariadb.enabled" .Values.externalMysql.db_name | quote}} {{- else -}} "oncall" {{- end -}} @@ -130,20 +161,97 @@ {{- define "snippet.mysql.user" -}} {{- if and (not .Values.mariadb.enabled) .Values.externalMysql.user -}} -{{- .Values.externalMysql.user | quote}} +{{- .Values.externalMysql.user | quote }} {{- else -}} "root" {{- end -}} {{- end -}} +{{- define "snippet.postgresql.env" -}} +- name: DATABASE_TYPE + value: {{ .Values.database.type }} +- name: DATABASE_HOST + value: {{ include "snippet.postgresql.host" . }} +- name: DATABASE_PORT + value: {{ include "snippet.postgresql.port" . }} +- name: DATABASE_NAME + value: {{ include "snippet.postgresql.db" . }} +- name: DATABASE_USER + value: {{ include "snippet.postgresql.user" . }} +- name: DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "snippet.postgresql.password.secret.name" . }} + key: {{ include "snippet.postgresql.password.secret.key" . }} +{{- end }} + +{{- define "snippet.postgresql.password.secret.name" -}} +{{- if and (not .Values.postgresql.enabled) .Values.externalPostgresql.password -}} +{{ include "oncall.fullname" . }}-postgresql-external +{{- else if and (not .Values.postgresql.enabled) .Values.externalPostgresql.existingSecret -}} +{{ .Values.externalPostgresql.existingSecret }} +{{- else -}} +{{ include "oncall.postgresql.fullname" . }} +{{- end -}} +{{- end -}} + +{{- define "snippet.postgresql.password.secret.key" -}} +{{- if and (not .Values.postgresql.enabled) .Values.externalPostgresql.passwordKey -}} +{{ .Values.externalPostgresql.passwordKey }} +{{- else -}} +"postgres-password" +{{- end -}} +{{- end -}} + +{{- define "snippet.postgresql.host" -}} +{{- if and (not .Values.postgresql.enabled) .Values.externalPostgresql.host -}} +{{- required "externalPostgresql.host is required if not postgresql.enabled" .Values.externalPostgresql.host | quote }} +{{- else -}} +{{ include "oncall.postgresql.fullname" . }} +{{- end -}} +{{- end -}} + +{{- define "snippet.postgresql.port" -}} +{{- if and (not .Values.mariadb.enabled) .Values.externalPostgresql.port -}} +{{- required "externalPostgresql.port is required if not postgresql.enabled" .Values.externalPostgresql.port | quote }} +{{- else -}} +"5432" +{{- end -}} +{{- end -}} + +{{- define "snippet.postgresql.db" -}} +{{- if and (not .Values.postgresql.enabled) .Values.externalPostgresql.db -}} +{{- required "externalPostgresql.db is required if not postgresql.enabled" .Values.externalPostgresql.db | quote}} +{{- else -}} +"oncall" +{{- end -}} +{{- end -}} + +{{- define "snippet.postgresql.user" -}} +{{- if and (not .Values.postgresql.enabled) .Values.externalPostgresql.user -}} +{{- .Values.externalPostgresql.user | quote}} +{{- else -}} +"postgres" +{{- end -}} +{{- end -}} + {{- define "snippet.rabbitmq.env" -}} +{{- if eq .Values.broker.type "rabbitmq" -}} +{{- if and (not .Values.rabbitmq.enabled) (not .Values.externalRabbitmq.existingSecret) (not .Values.externalRabbitmq.usernameKey) .Values.externalRabbitmq.user }} - name: RABBITMQ_USERNAME value: {{ include "snippet.rabbitmq.user" . }} +{{- else if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.existingSecret .Values.externalRabbitmq.usernameKey (not .Values.externalRabbitmq.user) }} +- name: RABBITMQ_USERNAME + valueFrom: + secretKeyRef: + name: {{ include "snippet.rabbitmq.password.secret.name" . }} + key: {{ .Values.externalRabbitmq.usernameKey }} +{{- end }} - name: RABBITMQ_PASSWORD valueFrom: secretKeyRef: name: {{ include "snippet.rabbitmq.password.secret.name" . }} - key: rabbitmq-password + key: {{ include "snippet.rabbitmq.password.secret.key" . }} - name: RABBITMQ_HOST value: {{ include "snippet.rabbitmq.host" . }} - name: RABBITMQ_PORT @@ -153,6 +261,7 @@ - name: RABBITMQ_VHOST value: {{ include "snippet.rabbitmq.vhost" . }} {{- end }} +{{- end -}} {{- define "snippet.rabbitmq.user" -}} {{- if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.user -}} @@ -197,11 +306,21 @@ {{- define "snippet.rabbitmq.password.secret.name" -}} {{- if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.password -}} {{ include "oncall.fullname" . }}-rabbitmq-external +{{- else if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.existingSecret -}} +{{ .Values.externalRabbitmq.existingSecret }} {{- else -}} {{ include "oncall.rabbitmq.fullname" . }} {{- end -}} {{- end -}} +{{- define "snippet.rabbitmq.password.secret.key" -}} +{{- if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.passwordKey -}} +{{ .Values.externalRabbitmq.passwordKey }} +{{- else -}} +rabbitmq-password +{{- end -}} +{{- end -}} + {{- define "snippet.redis.host" -}} {{- if and (not .Values.redis.enabled) .Values.externalRedis.host -}} {{- required "externalRedis.host is required if not redis.enabled" .Values.externalRedis.host | quote }} @@ -247,7 +366,7 @@ key: smtp-password - name: EMAIL_USE_TLS value: {{ .Values.oncall.smtp.tls | toString | title | quote }} -- name: DEFAULT_FROM_EMAIL +- name: EMAIL_FROM_ADDRESS value: {{ .Values.oncall.smtp.fromEmail | quote }} {{- else -}} - name: FEATURE_EMAIL_INTEGRATION_ENABLED diff --git a/helm/oncall/templates/_helpers.tpl b/helm/oncall/templates/_helpers.tpl index 18bcee42..110bc525 100644 --- a/helm/oncall/templates/_helpers.tpl +++ b/helm/oncall/templates/_helpers.tpl @@ -66,6 +66,11 @@ Create the name of the service account to use {{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* Generate the fullname of postgresql subchart */}} +{{- define "oncall.postgresql.fullname" -}} +{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" }} +{{- end }} + {{- define "oncall.grafana.fullname" -}} {{- printf "%s-%s" .Release.Name "grafana" | trunc 63 | trimSuffix "-" }} {{- end }} @@ -81,6 +86,31 @@ Create the name of the service account to use {{- end }} {{- define "oncall.mariadb.wait-for-db" }} +- name: wait-for-db + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ['sh', '-c', "until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done"] + securityContext: + {{ toYaml .Values.init.securityContext| nindent 4}} + env: + {{- include "snippet.oncall.env" . | nindent 4 }} + {{- include "snippet.mysql.env" . | nindent 4 }} + {{- include "snippet.rabbitmq.env" . | nindent 4 }} + {{- include "snippet.redis.env" . | nindent 4 }} + {{- if .Values.env }} + {{- if (kindIs "map" .Values.env) }} + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value }} + {{- end -}} + {{/* support previous schema */}} + {{- else }} + {{- toYaml .Values.env | nindent 4 }} + {{- end }} + {{- end }} +{{- end }} + +{{- define "oncall.postgresql.wait-for-db" }} - name: wait-for-db image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -89,7 +119,7 @@ Create the name of the service account to use {{ toYaml .Values.init.securityContext| nindent 4}} env: {{- include "snippet.oncall.env" . | nindent 12 }} - {{- include "snippet.mysql.env" . | nindent 12 }} + {{- include "snippet.postgresql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} {{- if .Values.env }} diff --git a/helm/oncall/templates/celery/_deployment.tpl b/helm/oncall/templates/celery/_deployment.tpl index 0892c0cb..4e09cb30 100644 --- a/helm/oncall/templates/celery/_deployment.tpl +++ b/helm/oncall/templates/celery/_deployment.tpl @@ -28,7 +28,12 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: - {{- include "oncall.mariadb.wait-for-db" . | indent 8 }} + {{- if eq .Values.database.type "mysql" }} + {{- include "oncall.mariadb.wait-for-db" . | indent 8 }} + {{- end }} + {{- if eq .Values.database.type "postgresql" }} + {{- include "oncall.postgresql.wait-for-db" . | indent 8 }} + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: @@ -42,11 +47,24 @@ spec: {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- if eq .Values.database.type "mysql" }} {{- include "snippet.mysql.env" . | nindent 12 }} + {{- end }} + {{- if eq .Values.database.type "postgresql" }} + {{- include "snippet.postgresql.env" . | nindent 12 }} + {{- end }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} {{- if .Values.env }} - {{- toYaml .Values.env | nindent 12 }} + {{- if (kindIs "map" .Values.env) }} + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value }} + {{- end -}} + {{/* support previous schema */}} + {{- else }} + {{- toYaml .Values.env | nindent 12 }} + {{- end }} {{- end }} {{- if .Values.celery.livenessProbe.enabled }} livenessProbe: diff --git a/helm/oncall/templates/engine/deployment.yaml b/helm/oncall/templates/engine/deployment.yaml index 5b1f7776..640bb84b 100644 --- a/helm/oncall/templates/engine/deployment.yaml +++ b/helm/oncall/templates/engine/deployment.yaml @@ -32,7 +32,12 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: - {{- include "oncall.mariadb.wait-for-db" . | indent 8 }} + {{- if eq .Values.database.type "mysql" }} + {{- include "oncall.mariadb.wait-for-db" . | indent 8 }} + {{- end }} + {{- if eq .Values.database.type "postgresql" }} + {{- include "oncall.postgresql.wait-for-db" . | indent 8 }} + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: @@ -48,11 +53,25 @@ spec: {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- include "snippet.oncall.twilio.env" . | nindent 12 }} + {{- if eq .Values.database.type "mysql" }} {{- include "snippet.mysql.env" . | nindent 12 }} + {{- end }} + {{- if eq .Values.database.type "postgresql" }} + {{- include "snippet.postgresql.env" . | nindent 12 }} + {{- end }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} {{- if .Values.env }} - {{- toYaml .Values.env | nindent 12 }} + {{- if (kindIs "map" .Values.env) }} + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value }} + {{- end -}} + {{/* support previous schema */}} + {{- else }} + {{- toYaml .Values.env | nindent 12 }} + {{- end }} {{- end }} livenessProbe: httpGet: diff --git a/helm/oncall/templates/engine/job-migrate.yaml b/helm/oncall/templates/engine/job-migrate.yaml index 8778f420..86fcbaa9 100644 --- a/helm/oncall/templates/engine/job-migrate.yaml +++ b/helm/oncall/templates/engine/job-migrate.yaml @@ -35,16 +35,30 @@ spec: command: - /bin/sh - -c + {{- if eq .Values.database.type "mysql" }} - | until (nc -vz $MYSQL_HOST $MYSQL_PORT); do echo "waiting for MySQL"; sleep 1; done python manage.py migrate + {{- else if eq .Values.database.type "postgresql" }} + - | + until (nc -vz $DATABASE_HOST $DATABASE_PORT); + do + echo "waiting for PostgreSQL"; sleep 1; + done + python manage.py migrate + {{- end }} env: {{- include "snippet.oncall.env" . | nindent 12 }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- if eq .Values.database.type "mysql" }} {{- include "snippet.mysql.env" . | nindent 12 }} + {{- end }} + {{- if eq .Values.database.type "postgresql" }} + {{- include "snippet.postgresql.env" . | nindent 12 }} + {{- end }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} {{- if .Values.env }} diff --git a/helm/oncall/templates/secrets.yaml b/helm/oncall/templates/secrets.yaml index 64d1e22c..dfd7cdb2 100644 --- a/helm/oncall/templates/secrets.yaml +++ b/helm/oncall/templates/secrets.yaml @@ -11,7 +11,7 @@ data: MIRAGE_CIPHER_IV: {{ randAlphaNum 40 | b64enc | quote }} --- -{{ if not .Values.mariadb.enabled -}} +{{ if and (not .Values.mariadb.enabled) (eq .Values.database.type "mysql") -}} apiVersion: v1 kind: Secret metadata: @@ -21,14 +21,14 @@ data: mariadb-root-password: {{ required "externalMysql.password is required if not mariadb.enabled" .Values.externalMysql.password | b64enc | quote }} {{- end }} --- -{{ if not .Values.rabbitmq.enabled -}} +{{ if and (eq .Values.broker.type "rabbitmq") (not .Values.rabbitmq.enabled) (not .Values.externalRabbitmq.existingSecret) -}} apiVersion: v1 kind: Secret metadata: name: {{ include "oncall.fullname" . }}-rabbitmq-external type: Opaque data: - rabbitmq-password: {{ required "externalRabbitmq.password is required if not rabbitmq.enabled" .Values.externalRabbitmq.password | b64enc | quote }} + rabbitmq-password: {{ required "externalRabbitmq.password is required if not rabbitmq.enabled and not externalRabbitmq.existingSecret" .Values.externalRabbitmq.password | b64enc | quote }} {{- end }} --- {{ if not .Values.redis.enabled -}} @@ -50,3 +50,13 @@ type: Opaque data: smtp-password: {{ required "oncall.smtp.password is required if oncall.smtp.enabled" .Values.oncall.smtp.password | b64enc | quote }} {{- end }} +--- +{{ if and (not .Values.postgresql.enabled) (eq .Values.database.type "postgresql") (not .Values.externalPostgresql.existingSecret) -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "oncall.fullname" . }}-postgresql-external +type: Opaque +data: + postgres-password: {{ required "externalPostgresql.password is required if not postgresql.enabled and not externalPostgresql.existingSecret" .Values.externalPostgresql.password | b64enc | quote }} +{{- end }} diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index db665bd6..3de0e122 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -84,6 +84,8 @@ oncall: # requests comming from Slack. # api.slack.com/apps/ -> Basic Information -> App Credentials -> Signing Secret signingSecret: ~ + # OnCall external URL + redirectHost: ~ telegram: enabled: false token: ~ @@ -96,13 +98,27 @@ oncall: password: ~ tls: ~ fromEmail: ~ + twilio: + # Twilio account SID/username to allow OnCall to send SMSes and make phone calls + accountSid: "" + # Twilio password to allow OnCall to send SMSes and make calls + authToken: "" + # Number from which you will receive calls and SMS (NOTE: must be quoted, otherwise would be rendered as float value) + phoneNumber: "" + # SID of Twilio service for number verification. You can create a service in Twilio web interface. + # twilio.com -> verify -> create new service + verifySid: "" + # Twilio API key SID/username to allow OnCall to send SMSes and make phone calls + apiKeySid: "" + # Twilio API key secret/password to allow OnCall to send SMSes and make phone calls + apiKeySecret: "" # Whether to run django database migrations automatically migrate: enabled: true # Additional env variables to add to deployments -env: [] +env: {} # Enable ingress object for external access to the resources ingress: @@ -111,7 +127,7 @@ ingress: annotations: kubernetes.io/ingress.class: "nginx" cert-manager.io/issuer: "letsencrypt-prod" - tls: + tls: - hosts: - "{{ .Values.base_url }}" secretName: certificate-tls @@ -153,6 +169,10 @@ cert-manager: - 8.8.8.8 - 1.1.1.1 +database: + # can be either mysql or postgresql + type: mysql + # MySQL is included into this release for the convenience. # It is recommended to host it separately from this release # Set mariadb.enabled = false and configure externalMysql @@ -182,12 +202,36 @@ externalMysql: user: password: +# PostgreSQL is included into this release for the convenience. +# It is recommended to host it separately from this release +# Set postgresql.enabled = false and configure externalPostgresql +postgresql: + enabled: false + auth: + database: oncall + +# Make sure to create the database with the following parameters: +# CREATE DATABASE oncall CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +externalPostgresql: + host: + port: + db_name: + user: + password: + # use an existing secret for the database password + existingSecret: "" + # the key in the secret containing the database password + passwordKey: password + # RabbitMQ is included into this release for the convenience. # It is recommended to host it separately from this release # Set rabbitmq.enabled = false and configure externalRabbitmq rabbitmq: enabled: true +broker: + type: rabbitmq + externalRabbitmq: host: port: @@ -195,6 +239,12 @@ externalRabbitmq: password: protocol: vhost: + # use an existing secret for the rabbitmq password + existingSecret: "" + # the key in the secret containing the rabbitmq password + passwordKey: password + # the key in the secret containing the rabbitmq username + usernameKey: username # Redis is included into this release for the convenience. # It is recommended to host it separately from this release