Add consoles for haproxy and cloudwatch.

Only display jobs in the LHS if they're present.
This commit is contained in:
Brian Brazil 2015-01-23 17:40:48 +00:00
parent 01f2bc4ee7
commit e3c375b9b0
17 changed files with 612 additions and 76 deletions

View file

@ -30,26 +30,79 @@
<div class="prom_lhs_menu">
<ul>
{{ template "_menuItem" (args . "index.html.example" "Overview") }}
{{ if query "up{job='haproxy'}" }}
{{ template "_menuItem" (args . "haproxy.html" "HAProxy") }}
{{ if match "^haproxy" .Path }}
<ul>
{{ template "_menuItem" (args . "haproxy-frontends.html" "Frontends") }}
{{ if .Params.frontend }}
<li>
<ul>
<li>
<a href="haproxy-frontend.html?frontend={{ .Params.frontend }}">{{ .Params.frontend }}</a></li>
</ul>
</li>
{{ end }}
{{ template "_menuItem" (args . "haproxy-backends.html" "Backends") }}
{{ if .Params.backend }}
<li>
<ul>
<li>
<a href="haproxy-backend.html?backend={{ .Params.backend }}">{{ .Params.backend }}</a></li>
</ul>
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ if query "up{job='node'}" }}
{{ template "_menuItem" (args . "node.html" "Node") }}
{{ if match "^node" .Path }}
{{ if .Params.instance }}
<ul>
<li {{ if eq .Path "node-overview.html" }}class="prom_lhs_menu_selected"{{end}}>
<li {{ if eq .Path "node-overview.html" }}class="prom_lhs_menu_selected"{{ end }}>
<a href="node-overview.html?instance={{ .Params.instance }}">{{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</a>
</li>
<ul>
<li {{ if eq .Path "node-cpu.html" }}class="prom_lhs_menu_selected"{{end}}>
<li {{ if eq .Path "node-cpu.html" }}class="prom_lhs_menu_selected"{{ end }}>
<a href="node-cpu.html?instance={{ .Params.instance }}">CPU</a>
</li>
<li {{ if eq .Path "node-disk.html" }}class="prom_lhs_menu_selected"{{end}}>
<li {{ if eq .Path "node-disk.html" }}class="prom_lhs_menu_selected"{{ end }}>
<a href="node-disk.html?instance={{ .Params.instance }}">Disk</a>
</li>
</ul>
</ul>
{{ end }}
{{ end }}
{{ end }}
{{ if query "up{job='cloudwatch'}" }}
{{ template "_menuItem" (args . "cloudwatch.html" "CloudWatch") }}
{{ end }}
{{ if query "aws_elasticache_cpuutilization_average{job='aws_elasticache'}" }}
{{ template "_menuItem" (args . "aws_elasticache.html" "ElastiCache") }}
{{ end }}
{{ if query "aws_elb_healthy_host_count_average{job='aws_elb'}" }}
{{ template "_menuItem" (args . "aws_elb.html" "ELB") }}
{{ end }}
{{ if query "aws_redshift_health_status_average{job='aws_redshift'}" }}
{{ template "_menuItem" (args . "aws_redshift.html" "Redshift") }}
{{ if and (eq "aws_redshift-cluster.html" .Path) .Params.cluster_identifier }}
<ul>
<li class="prom_lhs_menu_selected">
{{ reReplaceAll "^(.{8}).{8,}(.{8})$" "$1...$2" .Params.cluster_identifier }}
</li>
</ul>
{{ end }}
{{ end }}
</ul>
</div>
{{ end }}

View file

@ -1,6 +1,6 @@
{{/* vim: set ft=html: */}}
{{/* Load Prometheus console library JS/CSS. Should go in <head> */}}
{{define "prom_console_head"}}
{{ define "prom_console_head" }}
<link type="text/css" rel="stylesheet" href="/static/vendor/rickshaw/rickshaw.min.css">
<link type="text/css" rel="stylesheet" href="/static/vendor/bootstrap-3.3.1/css/bootstrap.css">
<link type="text/css" rel="stylesheet" href="/static/css/prom_console.css">
@ -10,18 +10,18 @@
<script src="/static/vendor/js/jquery.min.js"></script>
<script src="/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js"></script>
<script src="/static/js/prom_console.js"></script>
{{end}}
{{ end }}
{{/* Top of all pages. */}}
{{define "head"}}
{{ define "head" }}
<html>
<head>
{{template "prom_console_head"}}
{{ template "prom_console_head" }}
</head>
<body>
{{template "navbar" .}}
{{template "menu" .}}
{{end}}
{{ template "navbar" . }}
{{ template "menu" . }}
{{ end }}
{{ define "__prom_query_drilldown_noop" }}{{ . }}{{ end }}
{{ define "humanize" }}{{ humanize . }}{{ end }}
@ -36,33 +36,33 @@ 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.
*/}}
{{ define "prom_query_drilldown" }}
{{ $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>
{{ $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>
{{ 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">
<table class="table table-bordered table-hover table-condensed">
{{end}}
{{define "prom_right_table_tail"}}
{{ end }}
{{ define "prom_right_table_tail" }}
</table>
</div>
{{end}}
{{ end }}
{{define "prom_content_head"}}
{{ define "prom_content_head" }}
<div class="prom_console_content">
<div class="container">
{{template "prom_graph_timecontrol" .}}
{{end}}
{{define "prom_content_tail"}}
{{ template "prom_graph_timecontrol" . }}
{{ end }}
{{ define "prom_content_tail" }}
</div>
</div>
{{end}}
{{ end }}
{{define "prom_graph_timecontrol"}}
{{ define "prom_graph_timecontrol" }}
<div class="prom_graph_timecontrol">
<div class="prom_graph_timecontrol_inner">
<div class="prom_graph_timecontrol_group">
@ -104,10 +104,10 @@ renderTemplate is the name of the template to use to render the value.
new PromConsole.TimeControl();
</script>
</div>
{{end}}
{{ end }}
{{/* Bottom of all pages. */}}
{{define "tail"}}
{{ define "tail" }}
</body>
</html>
{{end}}
{{ end }}

View file

@ -0,0 +1,45 @@
{{ 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>
{{ template "prom_content_tail" . }}
<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 "tail" }}

46
consoles/aws_elb.html Normal file
View file

@ -0,0 +1,46 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
{{ range query "sum by (load_balancer_name)(aws_elb_healthy_host_count_average{job='aws_elb'})" | sortByLabel "load_balancer_name" }}
<tr>
<th colspan="2">{{ .Labels.load_balancer_name }}</th>
</tr>
<tr>
<td>Healthy Hosts</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_elb_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) ) }} / {{ template "prom_query_drilldown" (args (printf "avg(aws_elb_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'}) + avg(aws_elb_un_healthy_host_count_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name .Labels.load_balancer_name) ) }}</td>
</tr>
<tr>
<td>Queries</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(aws_elb_request_count_sum{job='aws_elb',load_balancer_name='%s'}) / 60" .Labels.load_balancer_name) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Latency</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_elb_latency_average{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) "s" "humanize") }}</td>
</tr>
<tr>
<td>Surge Queue</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(aws_elb_surge_queue_length_sum{job='aws_elb',load_balancer_name='%s'})" .Labels.load_balancer_name) "" "humanize") }}</td>
</tr>
{{ end }}
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" . }}
<h1>AWS Elastic Load Balancer</h1>
{{ template "prom_content_tail" . }}
<p><em>This console assumes that <code>period_seconds</code> in the CloudWatch Exporter is the default of 60s.</em></p>
<h3>Queries</h3>
<div id="queryGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#queryGraph"),
expr: "sum by (load_balancer_name)(aws_elb_request_count_sum{job='aws_elb'}) / 60",
name: "[[load_balancer_name]]",
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: "/s",
yTitle: "Queries"
})
</script>
{{ template "tail" }}

View file

@ -0,0 +1,83 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
<tr>
<td>Nodes</td>
<td>{{ template "prom_query_drilldown" (args (printf "count(aws_redshift_percentage_disk_space_used_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier)) }}</td>
</tr>
<tr>
<td>Healthy</td>
<td>{{ with printf "aws_redshift_health_status_average{job='aws_redshift',cluster_identifier='%s'}" .Params.cluster_identifier | query }}{{ if eq (. | first | value) 1.0 }}Yes{{ else }}No{{ end }} {{ end }}</td>
</tr>
<tr>
<td>Maintenance mode</td>
<td>{{ with printf "aws_redshift_maintenance_mode_average{job='aws_redshift',cluster_identifier='%s'}" .Params.cluster_identifier | query }}{{ if eq (. | first | value) 1.0 }}Yes{{ else }}No{{ end }} {{ end }}</td>
</tr>
<tr>
<td>Connections</td>
<td>{{ template "prom_query_drilldown" (args (printf "aws_redshift_database_connections_average{job='aws_redshift',cluster_identifier='%s'}" .Params.cluster_identifier)) }}</td>
</tr>
<tr>
<td>CPU</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_cpuutilization_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "%" "printf.3g") }}</td>
</tr>
<tr>
<td>Disk Used</td>
<td>{{ template "prom_query_drilldown" (args (printf "max(aws_redshift_percentage_disk_space_used_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "%" "printf.3g") }}</td>
</tr>
<tr>
<td>Network Transmitted</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_network_transmit_throughput_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Network Received</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_network_receive_throughput_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Read Throughput</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_read_throughput_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Read IOPS</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_read_iops_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Read Latency</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_read_latency_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "s" "humanize") }}</td>
</tr>
<tr>
<td>Write Throughput</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_write_throughput_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Write IOPS</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_write_iops_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Write Latency</td>
<td>{{ template "prom_query_drilldown" (args (printf "avg(aws_redshift_write_latency_average{job='aws_redshift',cluster_identifier='%s'})" .Params.cluster_identifier) "s" "humanize") }}</td>
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" . }}
<h1>AWS Redshift</h1>
<p><strong>Cluster:</strong> {{ .Params.cluster_identifier }}</p>
<h3>CPU Usage</h3>
<div id="cpuGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#cpuGraph"),
expr: "aws_redshift_cpuutilization_average{job='aws_redshift',cluster_identifier='{{ .Params.cluster_identifier }}'}",
name: '[[ node_id ]]',
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: "%",
yTitle: 'CPU'
})
</script>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -0,0 +1,28 @@
{{ template "head" . }}
{{ template "prom_content_head" . }}
<h1>AWS Redshift</h1>
<h3>Overview</h3>
<table class="table table-condensed table-striped table-bordered" style="width: 0%">
<tr>
<th>Cluster</th>
<th>Healthy</th>
<th>Maintenance Mode</th>
<th>Nodes</th>
<th>Disk Used</th>
</tr>
{{ range printf "sum by (cluster_identifier)(aws_redshift_health_status_average{job='aws_redshift'})" | query | sortByLabel "cluster_identifier" }}
<tr>
<td><a href="aws_redshift-cluster.html?cluster_identifier={{ .Labels.cluster_identifier }}">{{ .Labels.cluster_identifier }}</a></td>
<td>{{ with printf "aws_redshift_health_status_average{job='aws_redshift',cluster_identifier='%s'}" .Labels.cluster_identifier | query }}{{ if eq (. | first | value) 1.0 }}Yes{{ else }}No{{ end }} {{ end }}</td>
<td>{{ with printf "aws_redshift_maintenance_mode_average{job='aws_redshift',cluster_identifier='%s'}" .Labels.cluster_identifier | query }}{{ if eq (. | first | value) 1.0 }}Yes{{ else }}No{{ end }} {{ end }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "count(aws_redshift_percentage_disk_space_used_average{job='aws_redshift',cluster_identifier='%s'})" .Labels.cluster_identifier)) }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "max(aws_redshift_percentage_disk_space_used_average{job='aws_redshift',cluster_identifier='%s'})" .Labels.cluster_identifier) "%" "printf.3g") }}</td>
</tr>
{{ end }}
</table>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

19
consoles/cloudwatch.html Normal file
View file

@ -0,0 +1,19 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
<tr>
<th>cloudwatch</th>
<th>{{ template "prom_query_drilldown" (args "sum(up{job='cloudwatch'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='cloudwatch'})") }}</th>
</tr>
<tr>
<td>API Requests</td>
<td>{{ template "prom_query_drilldown" (args "sum by (job)(rate(cloudwatch_requests_total{job='cloudwatch'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" . }}
<h1>CloudWatch Exporter</h1>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -0,0 +1,58 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
<tr><th>{{ .Params.backend }}</th><th>{{ template "prom_query_drilldown" (args (printf "sum(min by (server)(haproxy_server_up{job='haproxy',backend='%s'}))" .Params.backend)) }} / {{ template "prom_query_drilldown" (args (printf "count(sum by (server)(haproxy_server_up{job='haproxy',backend='%s'}))" .Params.backend))}}</th></tr>
<tr>
<td>Responses</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_http_responses_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Data In</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_bytes_in_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Data Out</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_bytes_out_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Current Sessions</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(haproxy_backend_current_sessions{job='haproxy',backend='%s'})" .Params.backend) "" "humanize") }}</td>
</tr>
<tr>
<td>Current Queue</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(haproxy_backend_current_queue{job='haproxy',backend='%s'})" .Params.backend) "" "humanize") }}</td>
</tr>
<tr><th colspan="2">Server Errors</th></tr>
<tr>
<td>Connection Errors</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_connection_errors_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Response Errors</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_connection_errors_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Retry Warnings</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_backend_retry_warnings_total{job='haproxy',backend='%s'}[5m]))" .Params.backend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" . }}
<h1>HAProxy Backend - {{ .Params.backend }}</h1>
<h3>Responses</h3>
<div id="responsesGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#responsesGraph"),
expr: "sum by (code)(rate(haproxy_backend_http_responses_total{job='haproxy',backend='{{ .Params.backend }}'}[5m]))",
renderer: 'area',
yTitle: 'Queries',
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: '/s'
})
</script>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -0,0 +1,29 @@
{{ 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)(rate(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" }}

View file

@ -0,0 +1,45 @@
{{ template "head" . }}
{{ template "prom_right_table_head" }}
<tr><th colspan="2">{{ .Params.frontend }}</th></tr>
<tr>
<td>Requests</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_frontend_http_requests_total{job='haproxy',frontend='%s'}[5m]))" .Params.frontend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Requests Denied</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_frontend_requests_denied_total{job='haproxy',frontend='%s'}[5m]))" .Params.frontend) "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Data In</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_frontend_bytes_in_total{job='haproxy',frontend='%s'}[5m]))" .Params.frontend) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Data Out</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(rate(haproxy_frontend_bytes_out_total{job='haproxy',frontend='%s'}[5m]))" .Params.frontend) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>Current Sessions</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(haproxy_frontend_current_sessions{job='haproxy',frontend='%s'})" .Params.frontend) "" "humanize") }}</td>
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_head" . }}
<h1>HAProxy Frontend - {{ .Params.frontend }}</h1>
<h3>Responses</h3>
<div id="responsesGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#responsesGraph"),
expr: "sum by (code)(rate(haproxy_frontend_http_responses_total{job='haproxy',frontend='{{ .Params.frontend }}'}[5m]))",
renderer: 'area',
yTitle: 'Queries',
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: ' /s'
})
</script>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -0,0 +1,25 @@
{{ template "head" . }}
{{ template "prom_content_head" . }}
<h1>HAProxy Frontends</h1>
<table class="table table-condensed table-striped table-bordered" style="width: 0%">
<tr>
<th>Frontend</th>
<th>Requests</th>
<th>Sessions</th>
</tr>
{{ range query "count by (frontend)(haproxy_frontend_http_requests_total{job='haproxy'})" | sortByLabel "frontend" }}
<tr>
<td><a href="haproxy-frontend.html?frontend={{ .Labels.frontend }}">{{ .Labels.frontend }}</a></td>
<td>{{ template "prom_query_drilldown" (args (printf "sum by(frontend)(rate(haproxy_frontend_http_requests_total{job='haproxy',frontend='%s'}[5m]))" .Labels.frontend) "/s" "humanizeNoSmallPrefix") }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum by(frontend)(haproxy_frontend_current_sessions{job='haproxy',frontend='%s'})" .Labels.frontend) "" "humanize") }}</td>
</tr>
{{ else }}
<tr><td colspan=4>No frontends found.</td></tr>
{{ end }}
{{ template "prom_content_tail" . }}
{{ template "tail" }}

84
consoles/haproxy.html Normal file
View file

@ -0,0 +1,84 @@
{{ 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)(rate(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(rate(haproxy_frontend_http_requests_total{job='haproxy'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Requests Denied</td>
<td>{{ template "prom_query_drilldown" (args "sum(rate(haproxy_frontend_requests_denied_total{job='haproxy'}[5m]))" "/s" "humanizeNoSmallPrefix") }}</td>
</tr>
<tr>
<td>Data In</td>
<td>{{ template "prom_query_drilldown" (args "sum(rate(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(rate(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)(rate(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)(rate(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" }}

View file

@ -1,11 +1,32 @@
{{ template "head" . }}
{{template "prom_right_table_head"}}
{{template "prom_right_table_tail"}}
{{ template "prom_right_table_head" }}
{{ template "prom_right_table_tail" }}
{{template "prom_content_head" .}}
{{ template "prom_content_head" . }}
<h1>Overview</h1>
<p>These are example consoles for Prometheus, they are still under development.</p>
{{template "prom_content_tail" .}}
{{template "tail"}}
<p>These consoles expect exporters to have the following job labels:</p>
<table class="table table-condensed table-striped table-bordered" style="width: 0%">
<tr>
<th>Exporter</th>
<th>Job label</th>
</tr>
<tr>
<td>Node Exporter</td>
<td><code>node</code></td>
</tr>
<tr>
<td>HAProxy Exporter</td>
<td><code>haproxy</code></td>
</tr>
<tr>
<td>CloudWatch Exporter</td>
<td><code>cloudwatch</code></td>
</tr>
</table>
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View file

@ -1,8 +1,8 @@
{{template "head" .}}
{{ template "head" . }}
{{template "prom_right_table_head"}}
{{ template "prom_right_table_head" }}
<tr><th colspan="2">CPU</th></tr>
{{ range printf "sum by (mode)(rate(node_cpu{job='node',instance='%s'}[5m])) * 100 / scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance .Params.instance | query | sortByLabel "mode"}}
{{ range printf "sum by (mode)(rate(node_cpu{job='node',instance='%s'}[5m])) * 100 / scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance .Params.instance | query | sortByLabel "mode" }}
<tr>
<td>{{ .Labels.mode | title }} CPU</td>
<td>{{ .Value | printf "%.3g" }}%</td>
@ -35,9 +35,9 @@
</tr>
<tr>
</tr>
{{template "prom_right_table_tail"}}
{{ template "prom_right_table_tail" }}
{{template "prom_content_head" .}}
{{ template "prom_content_head" . }}
<h1>Node CPU - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</h1>
<h3>CPU Usage</h3>
@ -45,14 +45,14 @@
<script>
new PromConsole.Graph({
node: document.querySelector("#cpuGraph"),
expr: "sum by (mode)(rate(node_cpu{job='node',instance='{{.Params.instance}}',mode!='idle'}[5m]))",
expr: "sum by (mode)(rate(node_cpu{job='node',instance='{{ .Params.instance }}',mode!='idle'}[5m]))",
renderer: 'area',
max: {{ with printf "count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance | query }}{{ . | first | value}}{{else}}undefined{{end}},
max: {{ with printf "count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance | query }}{{ . | first | value }}{{ else}}undefined{{end}},
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yTitle: 'Cores'
})
</script>
{{template "prom_content_tail" .}}
{{ template "prom_content_tail" . }}
{{template "tail"}}
{{ template "tail" }}

View file

@ -1,9 +1,9 @@
{{template "head" .}}
{{ template "head" . }}
{{template "prom_right_table_head"}}
{{ template "prom_right_table_head" }}
<th colspan="2">Disks</th>
</tr>
{{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device"}}
{{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device" }}
<th colspan="2">{{ .Labels.device }}</th>
<tr>
<td>Utilization</td>
@ -24,20 +24,20 @@
{{ end }}
<th colspan="2">Filesystem Fullness</th>
</tr>
{{ define "roughlyNearZero"}}
{{ define "roughlyNearZero" }}
{{ if gt .1 . }}~0{{ else }}{{ printf "%.3g" . }}{{ end }}
{{ end }}
{{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem"}}
{{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem" }}
<tr>
<td>{{.Labels.filesystem}}</td>
<td>{{ .Labels.filesystem }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "100 - node_filesystem_free{job='node',instance='%s',filesystem='%s'} / node_filesystem_size{job='node'} * 100" .Labels.instance .Labels.filesystem) "%" "roughlyNearZero") }}</td>
</tr>
{{ end }}
<tr>
</tr>
{{template "prom_right_table_tail"}}
{{ template "prom_right_table_tail" }}
{{template "prom_content_head" .}}
{{ template "prom_content_head" . }}
<h1>Node Disk - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</h1>
<h3>Disk I/O Utilization</h3>
@ -46,7 +46,7 @@
new PromConsole.Graph({
node: document.querySelector("#diskioGraph"),
expr: [
"rate(node_disk_io_time_ms{job='node',instance='{{.Params.instance}}',device!~'^(md\\d+$|dm-)'}[5m]) / 1000 * 100",
"rate(node_disk_io_time_ms{job='node',instance='{{ .Params.instance }}',device!~'^(md\\d+$|dm-)'}[5m]) / 1000 * 100",
],
min: 0,
name: '[[ device ]]',
@ -71,6 +71,6 @@
yTitle: 'Filesystem Fullness'
})
</script>
{{template "prom_content_tail" .}}
{{ template "prom_content_tail" . }}
{{template "tail"}}
{{ template "tail" }}

View file

@ -1,6 +1,6 @@
{{template "head" .}}
{{ template "head" . }}
{{template "prom_right_table_head"}}
{{ template "prom_right_table_head" }}
<tr><th colspan="2">Overview</th></tr>
<tr>
<td>User CPU</td>
@ -21,7 +21,7 @@
<tr>
<th colspan="2">Network</th>
</tr>
{{ range printf "node_network_receive_bytes{job='node',instance='%s',device!='lo'}" .Params.instance | query | sortByLabel "device"}}
{{ range printf "node_network_receive_bytes{job='node',instance='%s',device!='lo'}" .Params.instance | query | sortByLabel "device" }}
<tr>
<td>{{ .Labels.device }} Received</td>
<td>{{ template "prom_query_drilldown" (args (printf "rate(node_network_receive_bytes{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device) "B/s" "humanize") }}</td>
@ -35,13 +35,13 @@
<tr>
<th colspan="2">Disks</th>
</tr>
{{ range printf "node_disk_io_time_ms{job='node',instance='%s',device!~'^(md\\d+$|dm-)'}" .Params.instance | query | sortByLabel "device"}}
{{ range printf "node_disk_io_time_ms{job='node',instance='%s',device!~'^(md\\d+$|dm-)'}" .Params.instance | query | sortByLabel "device" }}
<tr>
<td>{{ .Labels.device }} Utilization</td>
<td>{{ template "prom_query_drilldown" (args (printf "rate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.3g") }}</td>
</tr>
{{ end }}
{{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device"}}
{{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device" }}
<tr>
<td>{{ .Labels.device }} Throughput</td>
<td>{{ template "prom_query_drilldown" (args (printf "rate(node_disk_sectors_read{job='node',instance='%s',device='%s'}[5m]) * 512 + rate(node_disk_sectors_written{job='node',instance='%s',device='%s'}[5m]) * 512" .Labels.instance .Labels.device .Labels.instance .Labels.device) "B/s" "humanize") }}</td>
@ -50,19 +50,19 @@
<tr>
<th colspan="2">Filesystem Fullness</th>
</tr>
{{ define "roughlyNearZero"}}
{{ define "roughlyNearZero" }}
{{ if gt .1 . }}~0{{ else }}{{ printf "%.3g" . }}{{ end }}
{{ end }}
{{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem"}}
{{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem" }}
<tr>
<td>{{.Labels.filesystem}}</td>
<td>{{ .Labels.filesystem }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "100 - node_filesystem_free{job='node',instance='%s',filesystem='%s'} / node_filesystem_size{job='node'} * 100" .Labels.instance .Labels.filesystem) "%" "roughlyNearZero") }}</td>
</tr>
{{ end }}
</tr>
{{template "prom_right_table_tail"}}
{{ template "prom_right_table_tail" }}
{{template "prom_content_head" .}}
{{ template "prom_content_head" . }}
<h1>Node Overview - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</h1>
<h3>CPU Usage</h3>
@ -70,9 +70,9 @@
<script>
new PromConsole.Graph({
node: document.querySelector("#cpuGraph"),
expr: "sum by (mode)(rate(node_cpu{job='node',instance='{{.Params.instance}}',mode!='idle'}[5m]))",
expr: "sum by (mode)(rate(node_cpu{job='node',instance='{{ .Params.instance }}',mode!='idle'}[5m]))",
renderer: 'area',
max: {{ with printf "count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance | query }}{{ . | first | value}}{{else}}undefined{{end}},
max: {{ with printf "count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance | query }}{{ . | first | value }}{{ else}}undefined{{end}},
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yTitle: 'Cores'
@ -85,7 +85,7 @@
new PromConsole.Graph({
node: document.querySelector("#diskioGraph"),
expr: [
"rate(node_disk_io_time_ms{job='node',instance='{{.Params.instance}}',device!~'^(md\\d+$|dm-)'}[5m]) / 1000 * 100",
"rate(node_disk_io_time_ms{job='node',instance='{{ .Params.instance }}',device!~'^(md\\d+$|dm-)'}[5m]) / 1000 * 100",
],
min: 0,
name: '[[ device ]]',
@ -103,10 +103,10 @@
node: document.querySelector("#memoryGraph"),
renderer: 'area',
expr: [
"node_memory_Cached{job='node',instance='{{.Params.instance}}'}",
"node_memory_Buffers{job='node',instance='{{.Params.instance}}'}",
"node_memory_MemTotal{job='node',instance='{{.Params.instance}}'} - node_memory_MemFree{job='node',instance='{{.Params.instance}}'} - node_memory_Buffers{job='node',instance='{{.Params.instance}}'} - node_memory_Cached{job='node',instance='{{.Params.instance}}'}",
"node_memory_MemFree{job='node',instance='{{.Params.instance}}'}",
"node_memory_Cached{job='node',instance='{{ .Params.instance }}'}",
"node_memory_Buffers{job='node',instance='{{ .Params.instance }}'}",
"node_memory_MemTotal{job='node',instance='{{ .Params.instance }}'} - node_memory_MemFree{job='node',instance='{{.Params.instance}}'} - node_memory_Buffers{job='node',instance='{{.Params.instance}}'} - node_memory_Cached{job='node',instance='{{.Params.instance}}'}",
"node_memory_MemFree{job='node',instance='{{ .Params.instance }}'}",
],
name: function(metric) {
return !metric.__name__ ? 'Used' : metric.__name__.split('_', 3)[2] },
@ -117,6 +117,6 @@
yTitle: 'Memory'
})
</script>
{{template "prom_content_tail" .}}
{{ template "prom_content_tail" . }}
{{template "tail"}}
{{ template "tail" }}

View file

@ -1,13 +1,13 @@
{{template "head" .}}
{{ template "head" . }}
{{template "prom_right_table_head"}}
{{ template "prom_right_table_head" }}
<tr>
<th>Node</th>
<th>{{ template "prom_query_drilldown" (args "sum(up{job='node'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='node'})") }}</th>
</tr>
{{template "prom_right_table_tail"}}
{{ template "prom_right_table_tail" }}
{{template "prom_content_head" .}}
{{ template "prom_content_head" . }}
<h1>Node</h1>
<table class="table table-condensed table-striped table-bordered" style="width: 0%">
@ -29,6 +29,6 @@
{{ end }}
{{template "prom_content_tail" .}}
{{ template "prom_content_tail" . }}
{{template "tail"}}
{{ template "tail" }}