Skip to content

Commit

Permalink
[prometheusreceiver] Handle staleNaN for up metric
Browse files Browse the repository at this point in the history
When a target disappears, a StaleNaN is added. We should handle that case too.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
  • Loading branch information
gouthamve committed May 3, 2022
1 parent 92ab551 commit 4d4efa9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion receiver/prometheusreceiver/internal/otlp_metricsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/textparse"
"github.com/prometheus/prometheus/model/value"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -154,7 +155,8 @@ func (b *metricBuilderPdata) AddDataPoint(ls labels.Labels, t int64, v float64)
lm := ls.Map()
// See https://www.prometheus.io/docs/concepts/jobs_instances/#automatically-generated-labels-and-time-series
// up: 1 if the instance is healthy, i.e. reachable, or 0 if the scrape failed.
if metricName == scrapeUpMetricName && v != 1.0 {
// But it can also be a staleNaN, which is inserted when the target goes away.
if metricName == scrapeUpMetricName && v != 1.0 && !value.IsStaleNaN(v) {
if v == 0.0 {
b.logger.Warn("Failed to scrape Prometheus endpoint",
zap.Int64("scrape_timestamp", t),
Expand Down

0 comments on commit 4d4efa9

Please sign in to comment.