{{ template "head" . }}

{{ template "prom_right_table_head" }}
{{ range printf "sum by (cache_cluster_id)(aws_elasticache_cpuutilization_average{job='aws_elasticache'})" | query | sortByLabel "cache_cluster_id" }}
<tr>
  <th colspan="2">{{ .Labels.cache_cluster_id }}</th>
</tr>
<tr>
  <td>CPU</td>
  <td>{{ template "prom_query_drilldown" (args (printf "aws_elasticache_cpuutilization_average{job='aws_elasticache',cache_cluster_id='%s'}" .Labels.cache_cluster_id) "%" "printf.3g") }}</td>
</tr>
<tr>
  <td>Cache Size</td>
  <td>{{ template "prom_query_drilldown" (args (printf "aws_elasticache_bytes_used_for_cache_average{job='aws_elasticache',cache_cluster_id='%s'}" .Labels.cache_cluster_id) "B" "humanize1024") }}</td>
</tr>
<tr>
  <td>Cache Items</td>
  <td>{{ template "prom_query_drilldown" (args (printf "aws_elasticache_curr_items_average{job='aws_elasticache',cache_cluster_id='%s'}" .Labels.cache_cluster_id) "" "humanize") }}</td>
</tr>
<tr>
  <td>Freeable Memory</td>
  <td>{{ template "prom_query_drilldown" (args (printf "aws_elasticache_freeable_memory_average{job='aws_elasticache',cache_cluster_id='%s'}" .Labels.cache_cluster_id) "B" "humanize1024") }}</td>
</tr>
{{ end }}
{{ template "prom_right_table_tail" }}

{{ template "prom_content_head" . }}
<h1>AWS ElastiCache</h1>

<h3>CPU</h3>
<div id="queryGraph"></div>
<script>
new PromConsole.Graph({
  node: document.querySelector("#queryGraph"),
  expr: "sum by (cache_cluster_id)(aws_elasticache_cpuutilization_average{job='aws_elasticache'})",
  name: "[[cache_cluster_id]]",
  yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
  yUnits: "%",
  yTitle: "CPU"
})
</script>
{{ template "prom_content_tail" . }}

{{ template "tail" }}
