Allow environment alerts to display alerts from any source
What does this MR do and why?
Previous behavior: For a given environment, the most recent & critical AlertManagement:Alert
which is associated with a PrometheusAlert
is displayed from the list at /path/to/project/-/environments
.
New behavior: For a given environment, the most recent & critical alert from 'Monitor > Alerts' will be displayed from the list.
Changes: Remove the requirement of a PrometheusAlert
to display alert info/rollback environments. While PrometheusAlert
records specifically are being removed from the app as a whole, alerts originating from prometheus instances can still be displayed.
Context: This MR cleans up a portion of dead code related to the removal of devopsmonitor Category:Metrics features.
The Metrics Dashboard & Prometheus Metrics/Alerts (used for monitoring apps deploying using gitlab) were deprecated in 14.7 and removed from the product in 16.0.
- grouprespond related issue: Metrics: Delete models & database tables/columns (#397142)
- Monitor:Metrics removal epic: Monitor: Metrics Deprecation and Removal (&10107)
- Reference MR with all related removals: Draft: Remove all remaining metrics dashboard-r... (!160325 - closed)
- Metrics removal is blocking cells: Drop old unused tables for prometheus alerts (#461838 - closed)
Screenshots or screen recordings
Before | After |
---|---|
The alerts section has been blank since PromtheusAlerts were deprecated/removed. |
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Through rails console -- new project & env
# ---- Setting up the environment -----
# tip: if project creation errors with 'Path has already been taken', help FactoryBot fix the naming sequence by running FactoryBot.build(:organization)
group = FactoryBot.create(:group, organization: Organizations::Organization.first)
project = FactoryBot.create(:project, :public, :repository, namespace: group, path: 'testing_environment_alerts')
environment = FactoryBot.create(:environment, :staging, project: project)
pipeline = FactoryBot.create(:ci_pipeline, :success, :with_job, project: project)
deployment = FactoryBot.create(:deployment, :success, environment: environment, user: User.first, project: project, deployable: pipeline.builds.first)
alert = FactoryBot.create(:alert_management_alert, environment: environment, project: project)
# ---- Open this route in the browser & expand the environment section -----
Gitlab::Routing.url_helpers.project_environments_url(project)
Through UI -- existing project & env with deployment
- In a project with an environment+deployments, you'll go to
Operate > Environments
& expand the relevant environment to see the alert section- If you don't have successful deployments, you can use FactoryBot to generate for you.
> FactoryBot.create(:deployment, environment: Environment.last, user: User.first, project: Environment.last.project) => #<Deployment:0x0000000307cf1908> > Gitlab::Routing.url_helpers.project_environments_url(Environment.last.project) => "http://gdk.test:3000/namespace1/project-1/-/environments"
- From
Settings > Monitor > Alerts
, create a new HTTP integration (name however, skip custom mappings) - Send a test alert like
{ "title": "My awesome test", "gitlab_environment_name": "<replace-with-the-env-name>" }
, using your environment's name - Refresh the environment list and behold the beauty!