Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheusreceiver] Handle staleNaN for up metric #9253

Merged
merged 5 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- `prometheusreceiver`: Fix the memory issue introduced in the 0.49.0 release (#9718)
- `couchdbreceiver`: Fix issue where the receiver would not respect custom metric settings (#9598)
- `nginxreceiver`: Include nginxreceiver in components (#9572)
- `prometheusreceiver`: Handle the condition where `up` metric value is NaN (#9253)

## v0.50.0

Expand Down
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