mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Merge pull request #90 from prometheus/feature/scraping/named-target-state
Improve the Representations of /status
This commit is contained in:
commit
bd7ec4d5e1
|
@ -14,6 +14,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
@ -44,6 +45,53 @@ type LabelValue string
|
|||
// match.
|
||||
type LabelSet map[LabelName]LabelValue
|
||||
|
||||
func (l LabelSet) String() string {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
labels LabelNames
|
||||
labelCount int = len(l)
|
||||
)
|
||||
|
||||
for name := range l {
|
||||
labels = append(labels, name)
|
||||
}
|
||||
|
||||
sort.Sort(labels)
|
||||
|
||||
fmt.Fprintf(&buffer, "{")
|
||||
for i := 0; i < labelCount; i++ {
|
||||
var (
|
||||
label = labels[i]
|
||||
value = l[label]
|
||||
)
|
||||
|
||||
switch i {
|
||||
case labelCount - 1:
|
||||
fmt.Fprintf(&buffer, "%s=%s", label, value)
|
||||
default:
|
||||
fmt.Fprintf(&buffer, "%s=%s, ", label, value)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(&buffer, "}")
|
||||
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
type LabelNames []LabelName
|
||||
|
||||
func (l LabelNames) Len() int {
|
||||
return len(l)
|
||||
}
|
||||
|
||||
func (l LabelNames) Less(i, j int) bool {
|
||||
return l[i] < l[j]
|
||||
}
|
||||
|
||||
func (l LabelNames) Swap(i, j int) {
|
||||
l[i], l[j] = l[j], l[i]
|
||||
}
|
||||
|
||||
// A Metric is similar to a LabelSet, but the key difference is that a Metric is
|
||||
// a singleton and refers to one and only one stream of samples.
|
||||
type Metric map[LabelName]LabelValue
|
||||
|
|
|
@ -28,6 +28,19 @@ const (
|
|||
// The state of the given Target.
|
||||
type TargetState int
|
||||
|
||||
func (t TargetState) String() string {
|
||||
switch t {
|
||||
case UNKNOWN:
|
||||
return "UNKNOWN"
|
||||
case ALIVE:
|
||||
return "ALIVE"
|
||||
case UNREACHABLE:
|
||||
return "UNREACHABLE"
|
||||
}
|
||||
|
||||
panic("unknown state")
|
||||
}
|
||||
|
||||
const (
|
||||
// The Target has not been seen; we know nothing about it, except that it is
|
||||
// on our docket for examination.
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<ul>
|
||||
{{range $pool.Targets}}
|
||||
<li>
|
||||
<a href="{{.Address}}">{{.Address}}</a> (State: {{.State}}, Base labels: {{.BaseLabels}})
|
||||
<a href="{{.Address}}">{{.Address}}</a> (State: {{.State}}, Base Labels: {{.BaseLabels}})
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue