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
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *targetStatus) getDurationFromLastScrape() time.Duration {
|
func (ts *targetStatus) getDurationFromLastScrape() string {
|
||||||
return time.Since(time.Unix(ts.scrapeTime/1000, (ts.scrapeTime%1000)*1e6))
|
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 {
|
type droppedTargets struct {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{% import (
|
{% import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/htmlcomponents"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/htmlcomponents"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||||
@ -26,7 +25,7 @@
|
|||||||
{% if filter.showOriginalLabels %}originalLabels={%s= ts.sw.Config.OriginalLabels.String() %},{% space %}{% endif %}
|
{% if filter.showOriginalLabels %}originalLabels={%s= ts.sw.Config.OriginalLabels.String() %},{% space %}{% endif %}
|
||||||
scrapes_total={%d ts.scrapesTotal %},{% space %}
|
scrapes_total={%d ts.scrapesTotal %},{% space %}
|
||||||
scrapes_failed={%d ts.scrapesFailed %},{% 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 %}
|
scrape_duration={%d int(ts.scrapeDuration) %}ms,{% space %}
|
||||||
samples_scraped={%d ts.samplesScraped %},{% space %}
|
samples_scraped={%d ts.samplesScraped %},{% space %}
|
||||||
error={% if ts.err != nil %}{%s= ts.err.Error() %}{% endif %}
|
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.
|
// The target is uniquely identified by a pointer to its original labels.
|
||||||
targetID := getLabelsID(originalLabels)
|
targetID := getLabelsID(originalLabels)
|
||||||
lastScrapeDuration := ts.getDurationFromLastScrape()
|
|
||||||
%}
|
%}
|
||||||
<tr {% if !ts.up %}{%space%}class="alert alert-danger" role="alert" {% endif %}>
|
<tr {% if !ts.up %}{%space%}class="alert alert-danger" role="alert" {% endif %}>
|
||||||
<td class="endpoint">
|
<td class="endpoint">
|
||||||
@ -269,12 +267,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td>{%d ts.scrapesTotal %}</td>
|
<td>{%d ts.scrapesTotal %}</td>
|
||||||
<td>{%d ts.scrapesFailed %}</td>
|
<td>{%d ts.scrapesFailed %}</td>
|
||||||
<td>
|
<td>{%s ts.getDurationFromLastScrape() %}
|
||||||
{% if lastScrapeDuration < 365*24*time.Hour %}
|
|
||||||
{%d int(lastScrapeDuration.Milliseconds()) %}ms ago
|
|
||||||
{% else %}
|
|
||||||
none
|
|
||||||
{% endif %}
|
|
||||||
<td>{%d int(ts.scrapeDuration) %}ms</td>
|
<td>{%d int(ts.scrapeDuration) %}ms</td>
|
||||||
<td>{%d ts.samplesScraped %}</td>
|
<td>{%d ts.samplesScraped %}</td>
|
||||||
<td>{% if ts.err != nil %}{%s ts.err.Error() %}{% endif %}</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