{{ template "head" . }}

{{ template "prom_right_table_head" }}
  <tr>
    <th>HAProxy</th>
    <th>{{ template "prom_query_drilldown" (args "sum(haproxy_up{job='haproxy'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='haproxy'})") }}</th></tr>
  </tr>
  <tr>
    <td>CPU</td>
    <td>{{ template "prom_query_drilldown" (args "avg by(job)(irate(haproxy_process_cpu_seconds_total{job='haproxy'}[5m]))" "s/s" "humanizeNoSmallPrefix") }}</td>
  </tr>
  <tr>
    <td>Memory</td>
    <td>{{ template "prom_query_drilldown" (args "avg by(job)(haproxy_process_resident_memory_bytes{job='haproxy'})" "B" "humanize1024") }}</td>
  </tr>
  <tr>
    <th colspan="2">Frontend</th>
  </tr>
  <tr>
    <td>Requests</td>
    <td>{{ template "prom_query_drilldown" (args "sum(irate(haproxy_frontend_http_requests_total{job='haproxy'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
  </tr>
  <tr>
    <td>Requests Denied</td>
    <td>{{ template "prom_query_drilldown" (args "sum(irate(haproxy_frontend_requests_denied_total{job='haproxy'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
  </tr>
  <tr>
    <td>Data In</td>
    <td>{{ template "prom_query_drilldown" (args "sum(irate(haproxy_frontend_bytes_in_total{job='haproxy'}[5m]))" "B/s" "humanize") }}</td>
  </tr>
  <tr>
    <td>Data Out</td>
    <td>{{ template "prom_query_drilldown" (args "sum(irate(haproxy_frontend_bytes_out_total{job='haproxy'}[5m]))" "B/s" "humanize") }}</td>
  </tr>
  <tr>
    <td>Current Sessions</td>
    <td>{{ template "prom_query_drilldown" (args "sum(haproxy_frontend_current_sessions{job='haproxy'})" "" "humanize") }}</td>
  </tr>
{{ template "prom_right_table_tail" }}

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

<h3>Frontend Requests</h3>
<div id="feRequestsGraph"></div>
<script>
new PromConsole.Graph({
  node: document.querySelector("#feRequestsGraph"),
  expr: "sum by (frontend)(irate(haproxy_frontend_http_requests_total{job='haproxy'}[5m]))",
  renderer: 'area',
  yTitle: 'Requests',
  name: '[[ frontend ]]',
  yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yUnits: '/s'
})
</script>
<h3>Backend Responses</h3>
<div id="responsesGraph"></div>
<script>
new PromConsole.Graph({
  node: document.querySelector("#responsesGraph"),
  expr: "sum by (backend)(irate(haproxy_backend_http_responses_total{job='haproxy'}[5m]))",
  renderer: 'area',
  yTitle: 'Responses',
  name: '[[ backend ]]',
  yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yUnits: '/s'
})
</script>
<h3>Current Sessions</h3>
<div id="sessionsGraph"></div>
<script>
new PromConsole.Graph({
  node: document.querySelector("#sessionsGraph"),
  expr: "sum(haproxy_frontend_current_sessions{job='haproxy'})",
  yTitle: 'Sessions',
  name: 'Sessions'
})
</script>
{{ template "prom_content_tail" . }}

{{ template "tail" }}
