Represent targets in a tabular interface.

This commit represents a target group's endpoints in a tabular fashion for better differentiation
of their state in a concise manner.
This commit is contained in:
Matt T. Proud 2013-07-14 18:48:03 +02:00
parent 4d15f8fefe
commit 06b4a40661
5 changed files with 50 additions and 27 deletions

View File

@ -25,7 +25,7 @@ const (
// The base units for the exponential backoff.
DEFAULT_BACKOFF_VALUE_UNIT = time.Second
// The maximum allowed backoff time.
MAXIMUM_BACKOFF_VALUE = 30 * time.Minute
MAXIMUM_BACKOFF_VALUE = 2 * time.Minute
)
// scheduler is an interface that various scheduling strategies must fulfill

View File

@ -97,7 +97,7 @@ type Target interface {
// time, but it should occur no sooner than it.
//
// Right now, this is used as the sorting key in TargetPool.
scheduledFor() time.Time
ScheduledFor() time.Time
// Return the last encountered scrape error, if any.
LastError() error
// The address to which the Target corresponds. Out of all of the available
@ -176,11 +176,11 @@ func (t *target) recordScrapeHealth(results chan<- *extraction.Result, timestamp
}
}
func (t *target) Scrape(earliest time.Time, results chan<- *extraction.Result) (err error) {
func (t *target) Scrape(earliest time.Time, results chan<- *extraction.Result) error {
now := time.Now()
futureState := t.state
if err = t.scrape(now, results); err != nil {
err := t.scrape(now, results)
if err != nil {
t.recordScrapeHealth(results, now, false)
futureState = UNREACHABLE
} else {
@ -249,23 +249,23 @@ func (t *target) scrape(timestamp time.Time, results chan<- *extraction.Result)
return processor.ProcessSingle(buf, results, processOptions)
}
func (t target) State() TargetState {
func (t *target) State() TargetState {
return t.state
}
func (t target) scheduledFor() time.Time {
func (t *target) ScheduledFor() time.Time {
return t.scheduler.ScheduledFor()
}
func (t target) LastError() error {
func (t *target) LastError() error {
return t.lastError
}
func (t target) Address() string {
func (t *target) Address() string {
return t.address
}
func (t target) GlobalAddress() string {
func (t *target) GlobalAddress() string {
address := t.address
hostname, err := os.Hostname()
if err != nil {
@ -278,7 +278,7 @@ func (t target) GlobalAddress() string {
return address
}
func (t target) BaseLabels() clientmodel.LabelSet {
func (t *target) BaseLabels() clientmodel.LabelSet {
return t.baseLabels
}
@ -299,7 +299,7 @@ func (t targets) Len() int {
}
func (t targets) Less(i, j int) bool {
return t[i].scheduledFor().Before(t[j].scheduledFor())
return t[i].ScheduledFor().Before(t[j].ScheduledFor())
}
func (t targets) Swap(i, j int) {

View File

@ -66,7 +66,7 @@ func (t fakeTarget) State() TargetState {
return ALIVE
}
func (t *fakeTarget) scheduledFor() (time time.Time) {
func (t *fakeTarget) ScheduledFor() (time time.Time) {
time = t.schedules[t.scheduleIndex]
t.scheduleIndex++

View File

@ -146,7 +146,7 @@ func (p *TargetPool) runIteration(results chan<- *extraction.Result, interval ti
for _, target := range p.targets {
now := time.Now()
if target.scheduledFor().After(now) {
if target.ScheduledFor().After(now) {
// None of the remaining targets are ready to be scheduled. Signal that
// we're done processing them in this scrape iteration.
continue

View File

@ -43,17 +43,40 @@
<ul>
{{range $job, $pool := .TargetPools}}
<li>{{$job}}
<ul>
<table>
<thead>
<tr>
<th>Endpoint</th>
<th>State</th>
<th>Base Labels</th>
<th>Earliest Retrieval</th>
<th>Error</th>
</tr>
</thead>
<tbody>
{{range $pool.Targets}}
<li>
<a href="{{.GlobalAddress}}">{{.Address}}</a> (State: {{.State}}, Base Labels: {{.BaseLabels}})
<tr>
<td>
<a href="{{.GlobalAddress}}">{{.Address}}</a>
</td>
<td>
{{.State}}
</td>
<td>
{{.BaseLabels}}
</td>
<td>
{{.ScheduledFor}}
</td>
<td>
{{if .LastError}}
<br/>
<span class="error_text"><b>Scrape error:</b> "{{.LastError}}"</span>
<span class="error_text">{{.LastError}}</span>
{{end}}
</li>
</td>
</tr>
{{end}}
</ul>
</tbody>
</table>
</li>
{{end}}
</ul>