Class: Projects::Prometheus::AlertPresenter
Constant Summary
collapse
- GENERIC_ALERT_SUMMARY_ANNOTATIONS =
%w(monitoring_tool service hosts).freeze
- MARKDOWN_LINE_BREAK =
" \n".freeze
- INCIDENT_LABEL_NAME =
::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES[:title].freeze
- METRIC_TIME_WINDOW =
30.minutes
Instance Attribute Summary
#subject
Instance Method Summary
collapse
#initialize
#can?, #declarative_policy_delegate, #is_a?, #present, #url_builder, #web_path, #web_url
#can?
add_helpers, includes_helpers, redirect_legacy_paths, url_helpers
Instance Method Details
#details_list ⇒ Object
58
59
60
61
62
63
64
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 58
def details_list
strong_memoize(:details_list) do
details
.map { |label, value| list_item(label, value) }
.join(MARKDOWN_LINE_BREAK)
end
end
|
#details_url ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 76
def details_url
return unless am_alert
::Gitlab::Routing.url_helpers.details_project_alert_management_url(
project,
am_alert.iid
)
end
|
#environment_name ⇒ Object
23
24
25
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 23
def environment_name
environment&.name
end
|
#full_title ⇒ Object
11
12
13
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 11
def full_title
[environment_name, alert_title].compact.join(': ')
end
|
#incident_issues_link ⇒ Object
43
44
45
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 43
def incident_issues_link
project_issues_url(project, label_name: INCIDENT_LABEL_NAME)
end
|
#issue_summary_markdown ⇒ Object
51
52
53
54
55
56
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 51
def issue_summary_markdown
<<~MARKDOWN.chomp
#{metadata_list}
#{alert_details}#{metric_embed_for_alert}
MARKDOWN
end
|
#metric_embed_for_alert ⇒ Object
66
67
68
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 66
def metric_embed_for_alert
"\n[](#{metrics_dashboard_url})" if metrics_dashboard_url
end
|
#metric_query ⇒ Object
19
20
21
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 19
def metric_query
gitlab_alert&.full_query
end
|
#metrics_dashboard_url ⇒ Object
70
71
72
73
74
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 70
def metrics_dashboard_url
strong_memoize(:metrics_dashboard_url) do
embed_url_for_gitlab_alert || embed_url_for_self_managed_alert
end
end
|
27
28
29
30
31
32
33
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 27
def performance_dashboard_link
if environment
metrics_project_environment_url(project, environment)
else
metrics_project_environments_url(project)
end
end
|
#project_full_path ⇒ Object
15
16
17
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 15
def project_full_path
project.full_path
end
|
#show_incident_issues_link? ⇒ Boolean
39
40
41
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 39
def show_incident_issues_link?
project.incident_management_setting&.create_issue?
end
|
35
36
37
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 35
def show_performance_dashboard_link?
gitlab_alert.present?
end
|
#start_time ⇒ Object
47
48
49
|
# File 'app/presenters/projects/prometheus/alert_presenter.rb', line 47
def start_time
starts_at&.strftime('%d %B %Y, %-l:%M%p (%Z)')
end
|