Skip to content

Allow environment alerts to display alerts from any source

Sarah Yasonik requested to merge sy-rm-monitor-metrics-22 into master

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.

Screenshots or screen recordings

Before After
The alerts section has been blank since PromtheusAlerts were deprecated/removed. Screenshot_2024-07-23_at_8.22.18_PM

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

  1. 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"
  2. From Settings > Monitor > Alerts, create a new HTTP integration (name however, skip custom mappings)
  3. Send a test alert like { "title": "My awesome test", "gitlab_environment_name": "<replace-with-the-env-name>" }, using your environment's name
  4. Refresh the environment list and behold the beauty!
Edited by Sarah Yasonik

Merge request reports

Loading