{{ template "head" . }}

{{ template "prom_right_table_head" }}
{{ range query "sum by (load_balancer_name)(aws_elb_healthy_host_count_average{job='aws_elb'})" | sortByLabel "load_balancer_name" }}
<tr>
  <th colspan="2">{{ .Labels.load_balancer_name }}</th>
</tr>
<tr>
  <td>Healthy Hosts</td>
  <td>{{ template "prom_query_drilldown" (args (printf "avg(aws_elb_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) ) }} / {{ template "prom_query_drilldown" (args (printf "avg(aws_elb_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'}) + avg(aws_elb_un_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name .Labels.load_balancer_name) ) }}</td>
</tr>
<tr>
  <td>Queries</td>
  <td>{{ template "prom_query_drilldown" (args (printf "sum(aws_elb_request_count_sum{job='aws_elb',load_balancer_name='%s'}) / 60" .Labels.load_balancer_name) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
  <td>Latency</td>
  <td>{{ template "prom_query_drilldown" (args (printf "avg(aws_elb_latency_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) "s" "humanize") }}</td>
</tr>
<tr>
  <td>Surge Queue</td>
  <td>{{ template "prom_query_drilldown" (args (printf "sum(aws_elb_surge_queue_length_sum{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) "" "humanize") }}</td>
</tr>
{{ end }}
{{ template "prom_right_table_tail" }}

{{ template "prom_content_head" . }}
<h1>AWS Elastic Load Balancer</h1>
<p><em>This console assumes that <code>period_seconds</code>  in the CloudWatch Exporter is the default of 60s.</em></p>

<h3>Queries</h3>
<div id="queryGraph"></div>
<script>
new PromConsole.Graph({
  node: document.querySelector("#queryGraph"),
  expr: "sum by (load_balancer_name)(aws_elb_request_count_sum{job='aws_elb'}) / 60",
  name: "[[load_balancer_name]]",
  yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yUnits: "/s",
  yTitle: "Queries"
})
</script>
{{ template "prom_content_tail" . }}

{{ template "tail" }}
