diff --git a/retrieval/target.go b/retrieval/target.go index 6d50f287b..bc52e41e7 100644 --- a/retrieval/target.go +++ b/retrieval/target.go @@ -90,6 +90,8 @@ type Target interface { // // Right now, this is used as the sorting key in TargetPool. 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 // points in this interface, this one is the best candidate to change given // the ways to express the endpoint. @@ -110,14 +112,18 @@ type target struct { // scheduler provides the scheduling strategy that is used to formulate what // is returned in Target.scheduledFor. scheduler scheduler - state TargetState + // The current health state of the target. + state TargetState + // The last encountered scrape error, if any. + lastError error address string // What is the deadline for the HTTP or HTTPS against this endpoint. Deadline time.Duration // Any base labels that are added to this target and its metrics. baseLabels model.LabelSet - client http.Client + // The HTTP client used to scrape the target's endpoint. + client http.Client } // Furnish a reasonably configured target for querying. @@ -176,6 +182,7 @@ func (t *target) Scrape(earliest time.Time, results chan format.Result) (err err t.scheduler.Reschedule(earliest, futureState) t.state = futureState + t.lastError = err return err } @@ -221,6 +228,10 @@ func (t target) scheduledFor() time.Time { return t.scheduler.ScheduledFor() } +func (t target) LastError() error { + return t.lastError +} + func (t target) Address() string { return t.address } diff --git a/retrieval/targetmanager_test.go b/retrieval/targetmanager_test.go index fdd286e2d..0437ef30d 100644 --- a/retrieval/targetmanager_test.go +++ b/retrieval/targetmanager_test.go @@ -31,6 +31,10 @@ type fakeTarget struct { scheduleIndex int } +func (t fakeTarget) LastError() error { + return nil +} + func (t fakeTarget) Address() string { return "fake" } diff --git a/web/static/css/prometheus.css b/web/static/css/prometheus.css index 5e132ab85..4a44e3173 100644 --- a/web/static/css/prometheus.css +++ b/web/static/css/prometheus.css @@ -82,4 +82,10 @@ input[name=end_input], input[name=range_input] { .literal_output td { font-family: monospace; -} \ No newline at end of file +} + +.error_text { + background-color: #f2dede; + border: 1px solid #c0a0a0; + padding: 0 2px 0 2px; +} diff --git a/web/templates/status.html b/web/templates/status.html index 9b08cb32a..c821cab54 100644 --- a/web/templates/status.html +++ b/web/templates/status.html @@ -36,6 +36,10 @@ {{range $pool.Targets}}
  • {{.Address}} (State: {{.State}}, Base Labels: {{.BaseLabels}}) + {{if .LastError}} +
    + Scrape error: "{{.LastError}}" + {{end}}
  • {{end}}