StatusHandler renders build info

This commit is contained in:
Bernerd Schaefer 2013-04-25 11:57:08 +02:00
parent 033533c4c5
commit a2a4f94aae
4 changed files with 27 additions and 11 deletions

View file

@ -28,4 +28,5 @@ type ApplicationState struct {
RuleManager rules.RuleManager RuleManager rules.RuleManager
Storage metric.Storage Storage metric.Storage
TargetManager retrieval.TargetManager TargetManager retrieval.TargetManager
BuildInfo map[string]string
} }

View file

@ -91,6 +91,7 @@ func main() {
RuleManager: ruleManager, RuleManager: ruleManager,
Storage: ts, Storage: ts,
TargetManager: targetManager, TargetManager: targetManager,
BuildInfo: BuildInfo,
} }
web.StartServing(appState) web.StartServing(appState)

View file

@ -24,6 +24,7 @@ type PrometheusStatus struct {
Rules string Rules string
Status string Status string
TargetPools map[string]*retrieval.TargetPool TargetPools map[string]*retrieval.TargetPool
BuildInfo map[string]string
} }
type StatusHandler struct { type StatusHandler struct {
@ -36,6 +37,7 @@ func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Rules: "TODO: list rules here", Rules: "TODO: list rules here",
Status: "TODO: add status information here", Status: "TODO: add status information here",
TargetPools: h.appState.TargetManager.Pools(), TargetPools: h.appState.TargetManager.Pools(),
BuildInfo: h.appState.BuildInfo,
} }
executeTemplate(w, "status", status) executeTemplate(w, "status", status)
} }

View file

@ -2,23 +2,23 @@
{{define "content"}} {{define "content"}}
<h2>Status</h2> <h2>Status</h2>
<div class="grouping_box"> <div class="grouping_box">
{{.Status}} {{.Status}}
</div> </div>
<h2>Configuration</h2> <h2>Configuration</h2>
<div class="grouping_box"> <div class="grouping_box">
<pre> <pre>
{{.Config}} {{.Config}}
</pre> </pre>
</div> </div>
<h2>Rules</h2> <h2>Rules</h2>
<div class="grouping_box"> <div class="grouping_box">
{{.Rules}} {{.Rules}}
</div> </div>
<h2>Targets</h2> <h2>Targets</h2>
<div class="grouping_box"> <div class="grouping_box">
<ul> <ul>
{{range $job, $pool := .TargetPools}} {{range $job, $pool := .TargetPools}}
@ -33,5 +33,17 @@
</li> </li>
{{end}} {{end}}
</ul> </ul>
</div> </div>
<h2>Build Info</h2>
<div class="grouping_box">
<table>
{{range $key, $value := .BuildInfo}}
<tr>
<th scope="row">{{$key}}</th>
<td>{{$value}}</td>
</tr>
{{end}}
</table>
</div>
{{end}} {{end}}