Merge pull request #491 from brian-brazil/but-wait-theres-more

Add cassandra console.
This commit is contained in:
juliusv 2015-01-30 12:47:23 +01:00
commit dc610f1eef
4 changed files with 105 additions and 5 deletions

View file

@ -57,6 +57,9 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if query "up{job='cassandra'}" }}
{{ template "_menuItem" (args . "cassandra.html" "Cassandra") }}
{{ end }}
{{ if query "up{job='node'}" }} {{ if query "up{job='node'}" }}
{{ template "_menuItem" (args . "node.html" "Node") }} {{ template "_menuItem" (args . "node.html" "Node") }}

View file

@ -36,11 +36,11 @@ Displays the result of the expression, with a link to /graph for it.
renderTemplate is the name of the template to use to render the value. renderTemplate is the name of the template to use to render the value.
*/}} */}}
{{ define "prom_query_drilldown" }} {{ define "prom_query_drilldown" }}
{{ $expr := .arg0 }}{{ $suffix := (or .arg1 "")}}{{ $renderTemplate := (or .arg2 "__prom_query_drilldown_noop")}} {{ $expr := .arg0 }}{{ $suffix := (or .arg1 "") }}{{ $renderTemplate := (or .arg2 "__prom_query_drilldown_noop") }}
<a class="prom_query_drilldown" href="{{ graphLink $expr }}">{{ with query $expr }}{{ tmpl $renderTemplate ( . | first | value ) }}{{ $suffix }}{{else}}-{{ end }}</a> <a class="prom_query_drilldown" href="{{ graphLink $expr }}">{{ with query $expr }}{{tmpl $renderTemplate ( . | first | value )}}{{ $suffix }}{{ else }}-{{ end }}</a>
{{ end }} {{ end }}
{{ define "prom_path" }}/consoles/{{ .Path }}?{{range $param, $value := .Params}}{{$param}}={{$value}}&amp;{{end}}{{ end }}" {{ define "prom_path" }}/consoles/{{ .Path }}?{{ range $param, $value := .Params }}{{ $param }}={{ $value }}&amp;{{ end }}{{ end }}"
{{ define "prom_right_table_head" }} {{ define "prom_right_table_head" }}
<div class="prom_console_rhs"> <div class="prom_console_rhs">
@ -49,9 +49,25 @@ renderTemplate is the name of the template to use to render the value.
{{ define "prom_right_table_tail" }} {{ define "prom_right_table_tail" }}
</table> </table>
</div> </div>
{{ end }} {{ end }}
{{/* RHS table head, pass job name. Should be used after prom_right_table_head. */}}
{{ define "prom_right_table_job_head" }}
<tr>
<th>{{ . }}</th>
<th>{{ template "prom_query_drilldown" (args (printf "sum(up{job='%s'})" .)) }} / {{ template "prom_query_drilldown" (args (printf "count(up{job='%s'})" .)) }}</th>
</tr>
<tr>
<td>CPU</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg by(job)(rate(process_cpu_seconds_total{job='%s'}[5m]))" .) "s/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Memory</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg by(job)(process_resident_memory_bytes{job='%s'})" .) "B" "humanize1024") }}</td>
</tr>
{{ end }}
{{ define "prom_content_head" }} {{ define "prom_content_head" }}
<div class="prom_console_content"> <div class="prom_console_content">
<div class="container"> <div class="container">
@ -83,7 +99,7 @@ renderTemplate is the name of the template to use to render the value.
<button class="btn btn-default pull-left" type="button" id="prom_graph_time_forward" title="Advance the end time."> <button class="btn btn-default pull-left" type="button" id="prom_graph_time_forward" title="Advance the end time.">
<i class="glyphicon glyphicon-forward"></i> <i class="glyphicon glyphicon-forward"></i>
</button> </button>
</div> </div>
<div class="prom_graph_timecontrol_group"> <div class="prom_graph_timecontrol_group">
<div class="btn-group dropup prom_graph_timecontrol_refresh pull-left"> <div class="btn-group dropup prom_graph_timecontrol_refresh pull-left">

77
consoles/cassandra.html Normal file
View file

@ -0,0 +1,77 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
{{ template "prom_right_table_job_head" "cassandra" }}
<tr>
<td>Queries</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Timeout Ratio</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_timeouts{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Unavailable Ratio</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_unavailables{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr><th colspan="2">Internals</th></tr>
<tr>
<td>Hints Inprogress</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(cassandra_storage_totalhintsinprogress{job='cassandra'})" "" "humanize") }}</td>
</tr>
<tr>
<td>Blocked Tasks</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(cassandra_threadpools_currentlyblockedtasks{job='cassandra'})" "" "humanize") }}</td>
</tr>
<tr><th colspan="2">Average Node Disk</th></tr>
<tr>
<td>Compacted</td>
<td>{{ template "prom_query_drilldown" (args "avg by (job)(rate(cassandra_compaction_bytescompacted{job='cassandra'}[5m]))" "B/s" "humanize1024") }}</td>
</tr>
<tr>
<td>Live CF</td>
<td>{{ template "prom_query_drilldown" (args "avg by (job)(sum by (job, instance)(cassandra_columnfamily_totaldiskspaceused{job='cassandra'}))" "B" "humanize1024") }}</td>
</tr>
<tr>
<td>Total CF</td>
<td>{{ template "prom_query_drilldown" (args "avg by (job)(sum by (job, instance)(cassandra_columnfamily_totaldiskspaceused{job='cassandra'}))" "B" "humanize1024") }}</td>
</tr>
<tr>
<td>Commit Log</td>
<td>{{ template "prom_query_drilldown" (args "avg by (job)(cassandra_commitlog_totalcommitlogsize{job='cassandra'})" "B" "humanize1024") }}</td>
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" .}}
<h1>Cassandra</h1>
<h3>Client Queries</h3>
<div id="queryGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#queryGraph"),
expr: "sum by (job, clientrequest)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))",
name: "[[clientrequest]]",
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: "/s",
yTitle: "Queries"
})
</script>
<h3>Client Latency</h3>
<div id="latencyGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#latencyGraph"),
expr: "sum by (job, clientrequest)(rate(cassandra_clientrequest_totallatency{job='cassandra'}[5m])) / sum by (job, clientrequest)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m])) / 1000000",
name: "[[clientrequest]]",
yAxisFormatter: PromConsole.NumberFormatter.humanize,
yHoverFormatter: PromConsole.NumberFormatter.humanize,
yUnits: "s",
yTitle: "Latency"
})
</script>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -25,6 +25,10 @@
<td>CloudWatch Exporter</td> <td>CloudWatch Exporter</td>
<td><code>cloudwatch</code></td> <td><code>cloudwatch</code></td>
</tr> </tr>
<tr>
<td>Cassandra (JMX Exporter)</td>
<td><code>cassandra</code></td>
</tr>
</table> </table>
{{ template "prom_content_tail" . }} {{ template "prom_content_tail" . }}