Support PD integrations without vendor (#1748)

This commit is contained in:
Innokentii Konstantinov 2023-04-14 14:32:23 +08:00 committed by GitHub
parent 449342b02a
commit 3544ab14ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View file

@ -84,10 +84,31 @@ docker run --rm \
pd-oncall-migrator
```
### Migrate unsupported user notification rules
It's possible to specify a default contact method type for user notification rules that cannot be migrated as-is by
changing the `ONCALL_DEFAULT_CONTACT_METHOD` env variable.
Options are: `email`, `sms`, `phone_call`, `slack`, `telegram`, `mobile_app` (default is `email`).
### Migrate unsupported integration types
It's possible to migrate unsupported integration types to [Grafana OnCall incoming webhooks](https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-webhook/).
by changing UNSUPPORTED_INTEGRATION_TO_WEBHOOKS env variable:
```shell
docker run --rm \
-e PAGERDUTY_API_TOKEN="<PAGERDUTY_API_TOKEN>" \
-e ONCALL_API_URL="<ONCALL_API_URL>" \
-e ONCALL_API_TOKEN="<ONCALL_API_TOKEN>" \
-e ONCALL_DEFAULT_CONTACT_METHOD="sms" \
-e MODE="migrate" \
-e UNSUPPORTED_INTEGRATION_TO_WEBHOOKS="true" \
pd-oncall-migrator
```
Consider modifying [alert templates](https://grafana.com/docs/oncall/latest/alert-behavior/alert-templates/) of the created
webhook integrations to adjust them for incoming payloads.
### After migration
- Connect integrations (press the "How to connect" button on the integration page)

View file

@ -74,7 +74,7 @@ def format_integration(integration: dict) -> str:
ERROR_SIGN, result, policy_name
)
else:
# check if integration not supported, but UNSUPPORTED_INTEGRATION_TO_WEBHOOKS set
# check if integration not supported, but UNSUPPORTED_INTEGRATION_TO_WEBHOOKS set
if integration.get("converted_to_webhook", False):
result = "{} {} Webhook integration will be created, Grafana OnCall not support this type directly ".format(
WARNING_SIGN, result

View file

@ -31,7 +31,11 @@ def match_integration_type(integration: dict, vendors: list[dict]) -> None:
if integration["vendor"] is None:
integration["vendor_name"] = None
integration["oncall_type"] = None
if UNSUPPORTED_INTEGRATION_TO_WEBHOOKS:
integration["oncall_type"] = "webhook"
integration["converted_to_webhook"] = True
else:
integration["oncall_type"] = None
return
vendor_id = integration["vendor"]["id"]