diff --git a/app/services/metrics/dashboard/gitlab_alert_embed_service.rb b/app/services/metrics/dashboard/gitlab_alert_embed_service.rb index 08d65413e1d..33c93b25c71 100644 --- a/app/services/metrics/dashboard/gitlab_alert_embed_service.rb +++ b/app/services/metrics/dashboard/gitlab_alert_embed_service.rb @@ -8,6 +8,7 @@ module Metrics module Dashboard class GitlabAlertEmbedService < ::Metrics::Dashboard::BaseEmbedService + include Gitlab::Metrics::Dashboard::Defaults include Gitlab::Utils::StrongMemoize SEQUENCE = [ @@ -63,7 +64,8 @@ module Metrics { title: prometheus_metric.title, y_label: prometheus_metric.y_label, - metrics: [prometheus_metric.to_metric_hash] + metrics: [prometheus_metric.to_metric_hash], + type: DEFAULT_PANEL_TYPE } end diff --git a/changelogs/unreleased/sy-set-default-type-for-alert-embeds.yml b/changelogs/unreleased/sy-set-default-type-for-alert-embeds.yml new file mode 100644 index 00000000000..08e1fcd80bd --- /dev/null +++ b/changelogs/unreleased/sy-set-default-type-for-alert-embeds.yml @@ -0,0 +1,5 @@ +--- +title: Link to logs from GitLab-managed alert metrics +merge_request: 39487 +author: +type: added diff --git a/doc/operations/incident_management/index.md b/doc/operations/incident_management/index.md index a44d2cc0807..568b346ed8a 100644 --- a/doc/operations/incident_management/index.md +++ b/doc/operations/incident_management/index.md @@ -303,6 +303,21 @@ for information on how to appropriately configure your alerting rules. See [External Prometheus instances](../metrics/alerts.md#external-prometheus-instances) for information on setting up alerts for your self-managed Prometheus instance. +### View an Alert's logs + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217768) in GitLab 13.3. + +To view the logs for an alert: + + 1. Sign in as a user with Developer or higher [permissions](../../user/permissions.md). + 1. Navigate to **{cloud-gear}** **Operations > Alerts**. + 1. Click the alert you want to view. + 1. Below the title of the alert, click the **Metrics** tab. + 1. Click the [menu](../metrics/dashboards/index.md#chart-context-menu) of the metric chart to view options. + 1. Click **View logs**. + +Read [View logs from metrics panel](#view-logs-from-metrics-panel) for additional information. + ## Use cases for assigning alerts Consider a team formed by different sections of monitoring, collaborating on a diff --git a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb index 0f37d99d740..dd9d498e307 100644 --- a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb @@ -72,12 +72,18 @@ RSpec.describe Metrics::Dashboard::GitlabAlertEmbedService do it_behaves_like 'valid embedded dashboard service response' it_behaves_like 'raises error for users with insufficient permissions' - it 'uses the metric info corresponding to the alert' do + it 'generates an panel based on the alert' do result = service_call - metrics = result[:dashboard][:panel_groups][0][:panels][0][:metrics] + panel = result[:dashboard][:panel_groups][0][:panels][0] + metric = panel[:metrics].first - expect(metrics.length).to eq 1 - expect(metrics.first[:metric_id]).to eq alert.prometheus_metric_id + expect(panel[:metrics].length).to eq 1 + expect(panel).to include( + title: alert.prometheus_metric.title, + y_label: alert.prometheus_metric.y_label, + type: 'area-chart' + ) + expect(metric[:metric_id]).to eq alert.prometheus_metric_id end context 'when the metric does not exist' do