{{ template "head" . }}

{{ template "prom_content_head" . }}
<h1>HAProxy Backends</h1>

<table class="table table-condensed table-striped table-bordered" style="width: 0%">
<tr>
  <th>Backend</th>
  <th>Servers Healthy</th>
  <th>Responses</th>
  <th>Sessions</th>
  <th>Queue</th>
</tr>
{{ range query "count by (backend)(haproxy_backend_http_responses_total{job='haproxy'})" | sortByLabel "backend" }}
<tr>
  <td><a href="haproxy-backend.html?backend={{ .Labels.backend }}">{{ .Labels.backend }}</a></td>
  <td>{{ template "prom_query_drilldown" (args (printf "sum(min by (server)(haproxy_server_up{job='haproxy',backend='%s'}))" .Labels.backend)) }} / {{ template "prom_query_drilldown" (args (printf "count(sum by (server)(haproxy_server_up{job='haproxy',backend='%s'}))" .Labels.backend))}}</tdd>
  <td>{{ template "prom_query_drilldown" (args (printf "sum by(backend)(irate(haproxy_backend_http_responses_total{job='haproxy',backend='%s'}[5m]))" .Labels.backend) "/s" "humanizeNoSmallPrefix") }}</td>
  <td>{{ template "prom_query_drilldown" (args (printf "sum by(backend)(haproxy_backend_current_sessions{job='haproxy',backend='%s'})" .Labels.backend) "" "humanize") }}</td>
  <td>{{ template "prom_query_drilldown" (args (printf "sum by(backend)(haproxy_backend_current_queue{job='haproxy',backend='%s'})" .Labels.backend) "" "humanize") }}</td>
</tr>
{{ else }}
<tr><td colspan=4>No backends found.</td></tr>
{{ end }}


{{ template "prom_content_tail" . }}

{{ template "tail" }}
