mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/promscrape: show never scraped
message for never scraped targets at /targets page
This commit is contained in:
parent
6a41e1ec0c
commit
e8dfecb3f1
@ -304,8 +304,12 @@ type targetStatus struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (ts *targetStatus) getDurationFromLastScrape() time.Duration {
|
||||
return time.Since(time.Unix(ts.scrapeTime/1000, (ts.scrapeTime%1000)*1e6))
|
||||
func (ts *targetStatus) getDurationFromLastScrape() string {
|
||||
if ts.scrapeTime <= 0 {
|
||||
return "never scraped"
|
||||
}
|
||||
d := time.Since(time.Unix(ts.scrapeTime/1000, (ts.scrapeTime%1000)*1e6))
|
||||
return fmt.Sprintf("%.3fs ago", d.Seconds())
|
||||
}
|
||||
|
||||
type droppedTargets struct {
|
||||
|
@ -1,6 +1,5 @@
|
||||
{% import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/htmlcomponents"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||
@ -26,7 +25,7 @@
|
||||
{% if filter.showOriginalLabels %}originalLabels={%s= ts.sw.Config.OriginalLabels.String() %},{% space %}{% endif %}
|
||||
scrapes_total={%d ts.scrapesTotal %},{% space %}
|
||||
scrapes_failed={%d ts.scrapesFailed %},{% space %}
|
||||
last_scrape={%d int(ts.getDurationFromLastScrape().Milliseconds()) %}ms ago,{% space %}
|
||||
last_scrape={%s ts.getDurationFromLastScrape() %},{% space %}
|
||||
scrape_duration={%d int(ts.scrapeDuration) %}ms,{% space %}
|
||||
samples_scraped={%d ts.samplesScraped %},{% space %}
|
||||
error={% if ts.err != nil %}{%s= ts.err.Error() %}{% endif %}
|
||||
@ -228,7 +227,6 @@
|
||||
|
||||
// The target is uniquely identified by a pointer to its original labels.
|
||||
targetID := getLabelsID(originalLabels)
|
||||
lastScrapeDuration := ts.getDurationFromLastScrape()
|
||||
%}
|
||||
<tr {% if !ts.up %}{%space%}class="alert alert-danger" role="alert" {% endif %}>
|
||||
<td class="endpoint">
|
||||
@ -269,12 +267,7 @@
|
||||
{% endif %}
|
||||
<td>{%d ts.scrapesTotal %}</td>
|
||||
<td>{%d ts.scrapesFailed %}</td>
|
||||
<td>
|
||||
{% if lastScrapeDuration < 365*24*time.Hour %}
|
||||
{%d int(lastScrapeDuration.Milliseconds()) %}ms ago
|
||||
{% else %}
|
||||
none
|
||||
{% endif %}
|
||||
<td>{%s ts.getDurationFromLastScrape() %}
|
||||
<td>{%d int(ts.scrapeDuration) %}ms</td>
|
||||
<td>{%d ts.samplesScraped %}</td>
|
||||
<td>{% if ts.err != nil %}{%s ts.err.Error() %}{% endif %}</td>
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user