Associate self-managed Prometheus Alerts and Issues
What does this MR do?
This MR closes #33184 (closed).
This adds associations between Issues
and Prometheus alerts from self-managed Prometheus instances.
Background
Previously when a self-managed Prometheus instance sent an alert (https://docs.gitlab.com/ee/user/project/integrations/prometheus.html#external-prometheus-instances) to GitLab for a project, we would create an Issue but not keep history of the alerts we have received. This differs from GitLab managed Prometheus, where a PrometheusAlertEvent
gets related to a PrometheusAlert
(created via the UI). The PrometheusAlertEvent
is then associated to Issues via a join table.
Self managed Prometheus
In order to track external (self managed) Prometheus alerts, I've created a new model SelfManagedPrometheusAlertEvent
. This has it's own table, and is essentially a merged version of what we have with Gitlab-managed (PrometheusAlert
and PrometheusAlertEvent
). To link this to Issues, a join seperate join table has been created (issues_self_managed_prometheus_alert_events
).
I created new tables rather than re-using the existing PrometheusAlert tables to avoid Single Table Inheritance.
To allow handling of the slightly different structures of the two payloads, I've changed CreateEventsService
. While doing this I moved the parsing logic to use Gitlab::Alerting::Alert
, and extended this to provide more functionality. This keeps all event parsing in a single place so that it's easier to maintain.
ProcessPrometheusAlertWorker
has also been modified to support the two types of Prometheus alert payloads.
Result
This MR introduces support for linking self-managed Prometheus instance alerts to Issues, in the same way that link Gitlab-managed alerts and Issues (recently added here !17477 (merged)). This allows us to continue on further work such as #13401 (closed).
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #33184 (closed)