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

Humanize Generic Alert params in AlertPresenter

parent 97e49725
...@@ -61,9 +61,9 @@ module Projects ...@@ -61,9 +61,9 @@ module Projects
metadata << list_item('Start time', starts_at) if starts_at metadata << list_item('Start time', starts_at) if starts_at
metadata << list_item('full_query', backtick(full_query)) if full_query metadata << list_item('full_query', backtick(full_query)) if full_query
metadata << list_item('Service', service) if service metadata << list_item(service.label.humanize, service.value) if service
metadata << list_item('Monitoring Tool', monitoring_tool) if monitoring_tool metadata << list_item(monitoring_tool.label.humanize, monitoring_tool.value) if monitoring_tool
metadata << list_item('Hosts', hosts.join(' ')) if hosts metadata << list_item(hosts.label.humanize, host_links.join(' ')) if hosts
metadata.join(MARKDOWN_LINE_BREAK) metadata.join(MARKDOWN_LINE_BREAK)
end end
...@@ -100,18 +100,14 @@ module Projects ...@@ -100,18 +100,14 @@ module Projects
"[#{title}](#{url})" "[#{title}](#{url})"
end end
def service GENERIC_ALERT_SUMMARY_ANNOTATIONS.each do |annotation_name|
annotations.find { |a| a.label == 'service' }.try(:value) define_method(annotation_name) do
end annotations.find { |a| a.label == annotation_name }
end
def monitoring_tool
annotations.find { |a| a.label == 'monitoring_tool' }.try(:value)
end end
def hosts def host_links
if value = annotations.find { |a| a.label == 'hosts' }.try(:value) Array(hosts.value).map { |host| markdown_link(host, host) }
Array(value).map { |host| markdown_link(host, host) }
end
end end
end end
end end
......
...@@ -115,7 +115,7 @@ describe Projects::Prometheus::AlertPresenter do ...@@ -115,7 +115,7 @@ describe Projects::Prometheus::AlertPresenter do
**Start time:** #{presenter.starts_at}#{markdown_line_break} **Start time:** #{presenter.starts_at}#{markdown_line_break}
**Service:** service_name#{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) **Hosts:** [http://localhost:3000](http://localhost:3000) [http://localhost:3001](http://localhost:3001)
#### Alert Details #### 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