Merge pull request #583 from prometheus/nicer-target-health

Nicer formatting of target health table on /status.
This commit is contained in:
Julius Volz 2015-03-07 23:55:45 +01:00
commit a9cbcf442d
3 changed files with 18 additions and 7 deletions

View File

@ -10,7 +10,7 @@ th.job_header {
padding-bottom: 10px; padding-bottom: 10px;
} }
.error_text { .target_status_alert {
padding: 0 4px 0 4px; padding: 0 4px 0 4px;
} }

View File

@ -35,6 +35,14 @@ type PrometheusStatusHandler struct {
Birth time.Time Birth time.Time
} }
func (h *PrometheusStatusHandler) TargetStateToClass() map[retrieval.TargetState]string {
return map[retrieval.TargetState]string{
retrieval.Unknown: "warning",
retrieval.Healthy: "success",
retrieval.Unhealthy: "danger",
}
}
func (h *PrometheusStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *PrometheusStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
executeTemplate(w, "status", h) executeTemplate(w, "status", h)
} }

View File

@ -31,8 +31,9 @@
<pre>{{range .RuleManager.Rules}}{{.HTMLSnippet}}<br/>{{end}}</pre> <pre>{{range .RuleManager.Rules}}{{.HTMLSnippet}}<br/>{{end}}</pre>
<h2>Targets</h2> <h2>Targets</h2>
{{range $job, $pool := .TargetPools}} <table class="table table-condensed table-bordered table-striped table-hover">
<table class="table table-condensed table-bordered table-striped table-hover"> {{$stateToClass := .TargetStateToClass}}
{{range $job, $pool := .TargetPools}}
<thead> <thead>
<tr><th colspan="5" class="job_header">{{$job}}</th></tr> <tr><th colspan="5" class="job_header">{{$job}}</th></tr>
<tr> <tr>
@ -50,7 +51,9 @@
<a href="{{.GlobalURL}}">{{.URL}}</a> <a href="{{.GlobalURL}}">{{.URL}}</a>
</td> </td>
<td> <td>
{{.State}} <span class="alert alert-{{index $stateToClass .State}} target_status_alert">
{{.State}}
</span>
</td> </td>
<td> <td>
{{.BaseLabels}} {{.BaseLabels}}
@ -60,14 +63,14 @@
</td> </td>
<td> <td>
{{if .LastError}} {{if .LastError}}
<span class="alert alert-error error_text">{{.LastError}}</span> <span class="alert alert-danger target_status_alert">{{.LastError}}</span>
{{end}} {{end}}
</td> </td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>
</table> {{end}}
{{end}} </table>
<h2>Startup Flags</h2> <h2>Startup Flags</h2>
<table class="table table-condensed table-bordered table-striped table-hover"> <table class="table table-condensed table-bordered table-striped table-hover">