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

[Metricbeat] Fix silent failures in kafka and prometheus #13353

Merged
merged 4 commits into from
Aug 27, 2019
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.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Print errors that were being omitted in vSphere metricsets. {pull}12816[12816]
- Fix redis key metricset dashboard references to index pattern. {pull}13303[13303]
- Check if fields in DBInstance is nil in rds metricset. {pull}13294[13294] {issue}13037[13037]
- Fix silent failures in kafka and prometheus module. {pull}13353[13353] {issue}13252[13252]

*Packetbeat*

Expand Down
2 changes: 2 additions & 0 deletions metricbeat/helper/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/http"

"github.com/pkg/errors"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"

Expand Down Expand Up @@ -83,6 +84,7 @@ func (p *prometheus) GetFamilies() ([]*dto.MetricFamily, error) {
if err == io.EOF {
break
}
return nil, errors.Wrap(err, "decoding of metric family failed")
} else {
families = append(families, mf)
}
Expand Down
6 changes: 4 additions & 2 deletions metricbeat/module/kafka/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"strings"
"time"

"github.com/pkg/errors"

"github.com/Shopify/sarama"

"github.com/elastic/beats/libbeat/common"
Expand Down Expand Up @@ -174,12 +176,12 @@ func (b *Broker) PartitionOffset(
req.AddBlock(topic, partition, time, 1)
resp, err := b.broker.GetAvailableOffsets(req)
if err != nil {
return -1, err
return -1, errors.Wrap(err, "get available offsets failed")
}

block := resp.GetBlock(topic, partition)
if len(block.Offsets) == 0 {
return -1, nil
return -1, errors.Wrap(block.Err, "block offsets is empty")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried this can change some behaviour. But I don't think so, at the end an error was reported by the metricset on this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah previously it will return nil but offOK returned from queryOffsetRange will still be false so it goes into the same if statement.

}

return block.Offsets[0], nil
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/kafka/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ func queryOffsetRange(
) (int64, int64, bool, error) {
oldest, err := b.PartitionOffset(replicaID, topic, partition, sarama.OffsetOldest)
if err != nil {
return -1, -1, false, err
return -1, -1, false, errors.Wrap(err, "failed to get oldest offset")
}

newest, err := b.PartitionOffset(replicaID, topic, partition, sarama.OffsetNewest)
if err != nil {
return -1, -1, false, err
return -1, -1, false, errors.Wrap(err, "failed to get newest offset")
}

okOld := oldest != -1
Expand Down