Class: Metrics::Dashboard::GitlabAlertEmbedService

Inherits:
BaseEmbedService show all
Includes:
Gitlab::Metrics::Dashboard::Defaults, Gitlab::Utils::StrongMemoize
Defined in:
app/services/metrics/dashboard/gitlab_alert_embed_service.rb

Constant Summary collapse

SEQUENCE =
[
  STAGES::MetricEndpointInserter,
  STAGES::PanelIdsInserter
].freeze

Constants included from Gitlab::Metrics::Dashboard::Defaults

Gitlab::Metrics::Dashboard::Defaults::DEFAULT_PANEL_TYPE

Constants inherited from BaseService

BaseService::STAGES

Constants included from Gitlab::Metrics::Dashboard::Errors

Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError, Gitlab::Metrics::Dashboard::Errors::LayoutError, Gitlab::Metrics::Dashboard::Errors::MissingIntegrationError, Gitlab::Metrics::Dashboard::Errors::MissingQueryError, Gitlab::Metrics::Dashboard::Errors::NOT_FOUND_ERROR, Gitlab::Metrics::Dashboard::Errors::PanelNotFoundError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseEmbedService

#cache_key, embedded?

Methods inherited from BaseService

all_dashboard_paths, #get_dashboard, out_of_the_box_dashboard?

Methods included from Gitlab::Metrics::Dashboard::Errors

#handle_errors, #panels_not_found!

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Class Method Details

.valid_params?(params) ⇒ Boolean

Determines whether the provided params are sufficient to uniquely identify a panel composed of user-defined custom metrics from the DB.

Returns:

  • (Boolean)

23
24
25
26
27
28
# File 'app/services/metrics/dashboard/gitlab_alert_embed_service.rb', line 23

def valid_params?(params)
  [
    embedded?(params[:embedded]),
    params[:prometheus_alert_id].is_a?(Integer)
  ].all?
end

Instance Method Details

#raw_dashboardObject


31
32
33
34
35
# File 'app/services/metrics/dashboard/gitlab_alert_embed_service.rb', line 31

def raw_dashboard
  panels_not_found!(alert_id: alert_id) unless alert && prometheus_metric

  { 'panel_groups' => [{ 'panels' => [panel] }] }
end