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

Refactor prometheus endpoint parsing to look similar to upstream prometheus #6332

Merged
merged 2 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all 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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Docker and Kubernetes modules are now GA, instead of Beta. {pull}6105[6105]
- Add pct calculated fields for Pod and container CPU and memory usages. {pull}6158[6158]
- Add statefulset support to Kubernetes module. {pull}6236[6236]
- Refactor prometheus endpoint parsing to look similar to upstream prometheus {pull}6332[6332]
Copy link
Contributor

Choose a reason for hiding this comment

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

When I initially read this I thought the parsing of prometheus input -> elasticsearch output changed. But it seems mainly the error handling changed / was improved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was always meant to change only the way parsing happens.

- Update prometheus dependencies to latest {pull}6333[6333]

*Packetbeat*
Expand Down
13 changes: 9 additions & 4 deletions metricbeat/helper/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package helper

import (
"fmt"

"github.com/elastic/beats/metricbeat/mb"
"io"

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

"github.com/elastic/beats/metricbeat/mb"
)

// Prometheus helper retrieves prometheus formatted metrics
Expand Down Expand Up @@ -42,10 +43,14 @@ func (p *Prometheus) GetFamilies() ([]*dto.MetricFamily, error) {
}

families := []*dto.MetricFamily{}
for err == nil {
for {
mf := &dto.MetricFamily{}
err = decoder.Decode(mf)
if err == nil {
if err != nil {
if err == io.EOF {
break
}
} else {
families = append(families, mf)
}
}
Expand Down