oncall-engine/engine/apps
Joey Orlando 06933a696a
Support alert routing based on labels (#3778)
# What this PR does

This PR adds support for routing alerts based on labels.
https://www.loom.com/share/4401de6e3c4945d5b8961fe43ee373c9

Additionally:
- improve the typing around the `get_object` method that is inherited by
[`PublicPrimaryKeyMixin.get_object`](https://github.com/grafana/oncall/blob/dev/engine/common/api_helpers/mixins.py#L153)
in most of our models. `PublicPrimaryKeyMixin` is generic, so it can be
more strongly typed when it is being subclassed, which results in better
typing of the `get_object` method in child classes
- I decided to do this because I started looking into this task via the
[`AlertReceiveChannelView.send_demo_alert`
method/endpoint](https://github.com/grafana/oncall/blob/dev/engine/apps/api/views/alert_receive_channel.py#L242).
Within that method, `instance` is not typed because the inherited
`get_object` method is not typed.. I digress 😄
- improve typing around `Alert.create` and
`apps.integrations.tasks.create_alert` functions
- make `Alert.render_group_data` more DRY by extracting some logic out
into `Alert._apply_jinja_template_to_alert_payload_and_labels`
- deduplicate the logic of `value.strip().lower() in ["1", "true",
"ok"]` into a shared function,
`common.jinja_templater.apply_jinja_template.templated_value_is_truthy`

Closes https://github.com/grafana/oncall-private/issues/2490

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
- [x] Documentation added (or `pr:no public docs` PR label added if not
required) (will be done in #3762)
2024-01-30 13:07:19 -05:00
..
alerts Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
api Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
api_for_grafana_incident Add render_for_web information to alert group incident API (#3005) 2023-09-12 12:02:42 +00:00
auth_token Add more logging to plugin sync and install (#3730) 2024-01-23 22:59:33 +00:00
base Create log record for telegram formatting error in notification (#3628) 2024-01-08 20:12:28 +00:00
email Fix inbound email integration endpoint (#3586) 2023-12-20 08:40:47 -05:00
grafana_plugin Enable labels feature only if labels plugin is enabled (#3769) 2024-01-30 07:29:16 +00:00
heartbeat Improve OpenAPI schema coverage (#3629) 2024-01-12 15:11:22 +00:00
integrations Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
labels Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
metrics_exporter address issue with metrics calculations when redis cluster is used (#3510) 2023-12-05 12:12:08 -05:00
mobile_app add some more logging to mobile app proxy 2024-01-26 10:48:35 -05:00
oss_installation Improve OpenAPI schema coverage (#3629) 2024-01-12 15:11:22 +00:00
phone_notifications Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
public_api Fix routes and schedules public api endpoints (#3751) 2024-01-25 12:52:55 +00:00
schedules Minor Fix to Format of REFRESH-INTERVAL in ical_utils.py (#3732) 2024-01-23 11:14:59 -03:00
slack Slack and telegram routes to test chatops-proxy v3 (#3723) 2024-01-22 13:48:19 +08:00
social_auth Chatops api v3 (#3721) 2024-01-20 06:56:17 +00:00
telegram Slack and telegram routes to test chatops-proxy v3 (#3723) 2024-01-22 13:48:19 +08:00
twilioapp add missing db migrations + add additional backend db migration check to CI (#3234) 2023-10-31 16:00:55 -04:00
user_management Enable labels feature only if labels plugin is enabled (#3769) 2024-01-30 07:29:16 +00:00
webhooks Fix unicode character encoding in JSON for webhooks (#3670) 2024-01-11 19:35:23 +00:00
zvonok add missing db migrations + add additional backend db migration check to CI (#3234) 2023-10-31 16:00:55 -04:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00