{% extends "skeleton.html" %}
{% block page_title %}Instances{% endblock %}

{% block page_head %}
  <style type="text/css">{% include "modules.css" %}</style>
{% endblock %}

{% block body %}
<div id="modules">
<h3>Instances</h3>
  <table id="ae-modules" class="ae-table">
    <thead>
      <tr>
        <th></th>
        <th>Latency (ms)</th>
        <th>QPS</th>
        <th>Total Requests</th>
        <th>Runtime</th>
      </tr>
    </thead>
    <tbody>
      {% for module in modules|sort(attribute='name') %}
        <tr>
          <th colspan=4>
            <a href="//{{ module.balanced_address }}" target="_blank">
              {{ module.name }}</a>
          </th>
          <td>
            {% if module.runtime == "vm" %}
              vm:
            {% endif %}
            {{ module.effective_runtime }}
          </td>
        </tr>
        {% for instance in module.instances|sort(attribute='instance_id') %}
          <tr class="instance">
            <td class="instance-id">
              {% if module.supports_individually_addressable_instances %}
                <a href="//{{ module.get_instance_address(instance.instance_id) }}"
                  target="_blank">
              {% endif %}
                {{ instance.instance_id }}
              {% if module.supports_individually_addressable_instances %}
                </a>
              {% endif %}
            </td>
            <td>
              {{ '%0.1f'|format(instance.get_latency_60s() * 1000) }}
            </td>
            <td>
              {{ '%0.2f'|format(instance.get_qps_60s()) }}
            </td>
            <td>
              {{ instance.total_requests }}
            </td>
          </tr>
        {% endfor %}
      {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}
