diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb index 36dd930c3d9d0822262cbd1ac3836d16aec9fdee..c17406b3e569667e7d82f0fd8afac2f0df7a5e7f 100644 --- a/app/graphql/types/alert_management/alert_type.rb +++ b/app/graphql/types/alert_management/alert_type.rb @@ -111,13 +111,6 @@ class AlertType < BaseObject null: true, description: 'Assignees of the alert.' - field :metrics_dashboard_url, - GraphQL::Types::String, - null: true, - description: 'URL for metrics embed for the alert.', - deprecated: { reason: 'Returns no data. Underlying feature was removed in 16.0', - milestone: '16.0' } - field :runbook, GraphQL::Types::String, null: true, @@ -143,12 +136,6 @@ class AlertType < BaseObject method: :details_url, null: false, description: 'URL of the alert.' - - def metrics_dashboard_url - return if Feature.enabled?(:remove_monitor_metrics) - - object.metrics_dashboard_url - end end end end diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb index 41831d50692a71548de51c14c7c36117054c3709..60fa351b4494dd2523d4bc5e5caf1a9bd25e7a5e 100644 --- a/app/presenters/alert_management/alert_presenter.rb +++ b/app/presenters/alert_management/alert_presenter.rb @@ -10,7 +10,7 @@ class AlertPresenter < Gitlab::View::Presenter::Delegated MARKDOWN_LINE_BREAK = " \n" HORIZONTAL_LINE = "\n\n---\n\n" - delegate :metrics_dashboard_url, :runbook, to: :parsed_payload + delegate :runbook, to: :parsed_payload def initialize(alert, **attributes) super @@ -60,8 +60,7 @@ def email_title def issue_summary_markdown <<~MARKDOWN.chomp - #{metadata_list} - #{metric_embed_for_alert} + #{metadata_list}\n MARKDOWN end @@ -80,10 +79,6 @@ def metadata_list metadata.join(MARKDOWN_LINE_BREAK) end - def metric_embed_for_alert - "\n[](#{metrics_dashboard_url})" if metrics_dashboard_url - end - def list_item(key, value) "**#{key}:** #{value}".strip end diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 5d897cfc923b30b6827a2e6aa0c1eb8e67a9e964..8d5cd68915008737c3aec90db075a396abfac504 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -12109,7 +12109,6 @@ Describes an alert from the project's Alert Management. | <a id="alertmanagementalertiid"></a>`iid` | [`ID!`](#id) | Internal ID of the alert. | | <a id="alertmanagementalertissue"></a>`issue` | [`Issue`](#issue) | Issue attached to the alert. | | <a id="alertmanagementalertissueiid"></a>`issueIid` **{warning-solid}** | [`ID`](#id) | **Deprecated** in 13.10. Use issue field. | -| <a id="alertmanagementalertmetricsdashboardurl"></a>`metricsDashboardUrl` **{warning-solid}** | [`String`](#string) | **Deprecated** in 16.0. Returns no data. Underlying feature was removed in 16.0. | | <a id="alertmanagementalertmonitoringtool"></a>`monitoringTool` | [`String`](#string) | Monitoring tool the alert came from. | | <a id="alertmanagementalertnotes"></a>`notes` | [`NoteConnection!`](#noteconnection) | All notes on this noteable. (see [Connections](#connections)) | | <a id="alertmanagementalertprometheusalert"></a>`prometheusAlert` | [`PrometheusAlert`](#prometheusalert) | Alert condition for Prometheus. | diff --git a/lib/gitlab/alert_management/payload/base.rb b/lib/gitlab/alert_management/payload/base.rb index 5b136431ce7242a5f7f33d041bdece2d21563aa6..3840a560c57cd0c93a7cf46071b669f57f0faf1b 100644 --- a/lib/gitlab/alert_management/payload/base.rb +++ b/lib/gitlab/alert_management/payload/base.rb @@ -33,7 +33,6 @@ class Base :has_required_attributes?, :hosts, :metric_id, - :metrics_dashboard_url, :monitoring_tool, :resolved?, :runbook, diff --git a/lib/gitlab/alert_management/payload/managed_prometheus.rb b/lib/gitlab/alert_management/payload/managed_prometheus.rb index 2236e60a0c62fd6381cd18bf0854e01913b4c7fd..4ed21108d3eaff4a9e95180a70241083157532db 100644 --- a/lib/gitlab/alert_management/payload/managed_prometheus.rb +++ b/lib/gitlab/alert_management/payload/managed_prometheus.rb @@ -35,18 +35,6 @@ def environment gitlab_alert&.environment || super end - def metrics_dashboard_url - return unless gitlab_alert - - metrics_dashboard_project_prometheus_alert_url( - project, - gitlab_alert.prometheus_metric_id, - environment_id: environment.id, - embedded: true, - **alert_embed_window_params - ) - end - private def plain_gitlab_fingerprint diff --git a/lib/gitlab/alert_management/payload/prometheus.rb b/lib/gitlab/alert_management/payload/prometheus.rb index cf6fe4493986f74f009b41ed77ee5c3c6b8656fb..15fa91646c802f2c69001b4aad0678cef6681e9c 100644 --- a/lib/gitlab/alert_management/payload/prometheus.rb +++ b/lib/gitlab/alert_management/payload/prometheus.rb @@ -96,29 +96,6 @@ def severity_mapping def plain_gitlab_fingerprint [starts_at_raw, title, full_query].join('/') end - - # Formatted for parsing by JS - def alert_embed_window_params - { - start: (starts_at - METRIC_TIME_WINDOW).utc.strftime('%FT%TZ'), - end: (starts_at + METRIC_TIME_WINDOW).utc.strftime('%FT%TZ') - } - end - - def dashboard_json - { - panel_groups: [{ - panels: [{ - type: 'area-chart', - title: title, - y_label: gitlab_y_label, - metrics: [{ - query_range: full_query - }] - }] - }] - }.to_json - end end end end diff --git a/spec/graphql/types/alert_management/alert_type_spec.rb b/spec/graphql/types/alert_management/alert_type_spec.rb index 4428fc0683a4623a5c4b17874750cb0698d78bfd..92e8104fc4d92da7d8ad71d7d065115c72b293ec 100644 --- a/spec/graphql/types/alert_management/alert_type_spec.rb +++ b/spec/graphql/types/alert_management/alert_type_spec.rb @@ -31,7 +31,6 @@ assignees notes discussions - metrics_dashboard_url runbook todos details_url diff --git a/spec/lib/gitlab/alert_management/payload/managed_prometheus_spec.rb b/spec/lib/gitlab/alert_management/payload/managed_prometheus_spec.rb index fa8afd47c53e24b61872d87bf385cfe354c03b4c..d7184c899332cda8f3b5d6515d3fbb0dfa705bf8 100644 --- a/spec/lib/gitlab/alert_management/payload/managed_prometheus_spec.rb +++ b/spec/lib/gitlab/alert_management/payload/managed_prometheus_spec.rb @@ -150,20 +150,4 @@ it { is_expected.to eq(environment) } end end - - describe '#metrics_dashboard_url' do - subject { parsed_payload.metrics_dashboard_url } - - context 'without alert' do - it { is_expected.to be_nil } - end - - context 'with gitlab alert' do - include_context 'gitlab-managed prometheus alert attributes' do - let(:raw_payload) { payload } - end - - it { is_expected.to eq(dashboard_url_for_alert) } - end - end end diff --git a/spec/lib/gitlab/alert_management/payload/prometheus_spec.rb b/spec/lib/gitlab/alert_management/payload/prometheus_spec.rb index cf525801aa0409109a67d4628965cb01527b37e6..92836915f7b80060f0d4a427d7da4b014df8c699 100644 --- a/spec/lib/gitlab/alert_management/payload/prometheus_spec.rb +++ b/spec/lib/gitlab/alert_management/payload/prometheus_spec.rb @@ -178,32 +178,6 @@ end end - describe '#metrics_dashboard_url' do - include_context 'self-managed prometheus alert attributes' do - let(:raw_payload) { payload } - end - - subject { parsed_payload.metrics_dashboard_url } - - context 'without environment' do - let(:raw_payload) { payload.except('labels') } - - it { is_expected.to be_nil } - end - - context 'without full query' do - let(:raw_payload) { payload.except('generatorURL') } - - it { is_expected.to be_nil } - end - - context 'without title' do - let(:raw_payload) { payload.except('annotations') } - - it { is_expected.to be_nil } - end - end - describe '#has_required_attributes?' do let(:starts_at) { Time.current.change(usec: 0).utc } let(:raw_payload) { { 'annotations' => { 'title' => 'title' }, 'startsAt' => starts_at.rfc3339 } } diff --git a/spec/presenters/alert_management/alert_presenter_spec.rb b/spec/presenters/alert_management/alert_presenter_spec.rb index fe228f174fed93d9f404abc1a60a32003295e5c9..eedb2e07fb69bdfcb568f2fea2b2709345c84923 100644 --- a/spec/presenters/alert_management/alert_presenter_spec.rb +++ b/spec/presenters/alert_management/alert_presenter_spec.rb @@ -91,24 +91,6 @@ ) end end - - context 'with metrics_dashboard_url' do - before do - allow(alert.parsed_payload).to receive(:metrics_dashboard_url).and_return('https://gitlab.com/metrics') - end - - it do - is_expected.to eq( - <<~MARKDOWN.chomp - **Start time:** #{presenter.start_time}#{markdown_line_break} - **Severity:** #{presenter.severity}#{markdown_line_break} - **GitLab alert:** #{alert_url} - - [](https://gitlab.com/metrics) - MARKDOWN - ) - end - end end describe '#start_time' do diff --git a/spec/requests/api/graphql/project/alert_management/alert/metrics_dashboard_url_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/metrics_dashboard_url_spec.rb deleted file mode 100644 index 2c49c9bc47be10dc3517e5eff96d246e2671d011..0000000000000000000000000000000000000000 --- a/spec/requests/api/graphql/project/alert_management/alert/metrics_dashboard_url_spec.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'getting Alert Management Alert Assignees', feature_category: :incident_management do - include GraphqlHelpers - - let_it_be(:project) { create(:project) } - let_it_be(:current_user) { create(:user) } - - let(:fields) do - <<~QUERY - nodes { - iid - metricsDashboardUrl - } - QUERY - end - - let(:graphql_query) do - graphql_query_for( - 'project', - { 'fullPath' => project.full_path }, - query_graphql_field('alertManagementAlerts', {}, fields) - ) - end - - let(:alerts) { graphql_data.dig('project', 'alertManagementAlerts', 'nodes') } - let(:first_alert) { alerts.first } - - before do - stub_feature_flags(remove_monitor_metrics: false) - project.add_developer(current_user) - end - - context 'with self-managed prometheus payload' do - include_context 'self-managed prometheus alert attributes' - - before do - create(:alert_management_alert, :prometheus, project: project, payload: payload) - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns nil' do - post_graphql(graphql_query, current_user: current_user) - expect(first_alert['metricsDashboardUrl']).to be_nil - end - end - end - - context 'with gitlab-managed prometheus payload' do - include_context 'gitlab-managed prometheus alert attributes' - - before do - create(:alert_management_alert, :prometheus, project: project, payload: payload, prometheus_alert: prometheus_alert) - end - - it 'includes the correct metrics dashboard url' do - post_graphql(graphql_query, current_user: current_user) - - expect(first_alert).to include('metricsDashboardUrl' => dashboard_url_for_alert) - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns nil' do - post_graphql(graphql_query, current_user: current_user) - expect(first_alert['metricsDashboardUrl']).to be_nil - end - end - end -end diff --git a/spec/requests/api/graphql/project/alert_management/alerts_spec.rb b/spec/requests/api/graphql/project/alert_management/alerts_spec.rb index 55d223daf278f22b3c85bf0075f7b60b754f1961..7f586edd510068df4cd5ff7aa4dc507bfec6ea1c 100644 --- a/spec/requests/api/graphql/project/alert_management/alerts_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alerts_spec.rb @@ -74,7 +74,6 @@ 'details' => { 'custom.alert' => 'payload', 'runbook' => 'runbook' }, 'createdAt' => triggered_alert.created_at.strftime('%Y-%m-%dT%H:%M:%SZ'), 'updatedAt' => triggered_alert.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ'), - 'metricsDashboardUrl' => nil, 'detailsUrl' => triggered_alert.details_url, 'prometheusAlert' => nil, 'runbook' => 'runbook'