Commit 0b77441a authored by Vitali Tatarintev's avatar Vitali Tatarintev

Humanize Generic Alert params in AlertPresenter

parent 97e49725
......@@ -61,9 +61,9 @@ module Projects
metadata << list_item('Start time', starts_at) if starts_at
metadata << list_item('full_query', backtick(full_query)) if full_query
metadata << list_item('Service', service) if service
metadata << list_item('Monitoring Tool', monitoring_tool) if monitoring_tool
metadata << list_item('Hosts', hosts.join(' ')) if hosts
metadata << list_item(service.label.humanize, service.value) if service
metadata << list_item(monitoring_tool.label.humanize, monitoring_tool.value) if monitoring_tool
metadata << list_item(hosts.label.humanize, host_links.join(' ')) if hosts
metadata.join(MARKDOWN_LINE_BREAK)
end
......@@ -100,18 +100,14 @@ module Projects
"[#{title}](#{url})"
end
def service
annotations.find { |a| a.label == 'service' }.try(:value)
end
def monitoring_tool
annotations.find { |a| a.label == 'monitoring_tool' }.try(:value)
GENERIC_ALERT_SUMMARY_ANNOTATIONS.each do |annotation_name|
define_method(annotation_name) do
annotations.find { |a| a.label == annotation_name }
end
end
def hosts
if value = annotations.find { |a| a.label == 'hosts' }.try(:value)
Array(value).map { |host| markdown_link(host, host) }
end
def host_links
Array(hosts.value).map { |host| markdown_link(host, host) }
end
end
end
......
......@@ -115,7 +115,7 @@ describe Projects::Prometheus::AlertPresenter do
**Start time:** #{presenter.starts_at}#{markdown_line_break}
**Service:** service_name#{markdown_line_break}
**Monitoring Tool:** monitoring_tool_name#{markdown_line_break}
**Monitoring tool:** monitoring_tool_name#{markdown_line_break}
**Hosts:** [http://localhost:3000](http://localhost:3000) [http://localhost:3001](http://localhost:3001)
#### Alert Details
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment