Skip to content

Commit

Permalink
Refactor prometheus endpoint parsing to look similar to upstream prom…
Browse files Browse the repository at this point in the history
…etheus
  • Loading branch information
vjsamuel committed Feb 14, 2018
1 parent b6bf3b8 commit f777f5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,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]

*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

0 comments on commit f777f5b

Please sign in to comment.