Skip to content

Commit

Permalink
Incorporating review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel committed Apr 21, 2017
1 parent 3b9279c commit a5ee39f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
metricset. The configuration option for the feature was renamed from
`cgroups` to `process.cgroups.enabled`. {pull}3519[3519]
- Change fieldnames couchbase.node.couch.*.actual_disk_size.* to couchbase.node.couch.*.disk_size.* {pull}3545[3545]
- Fixing prometheus collector to aggregate metrics based on metric family. {pull}4075[4075]

*Packetbeat*
- Remove deprecated geoip. {pull}3766[3766]
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/prometheus/collector/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"prometheus": {
"collector": {
"labels": {
"label": {
"type": "quarantine_completed"
},
"prometheus_local_storage_series_ops_total": {
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/prometheus/collector/collector.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package collector

import (
"fmt"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"

"fmt"
"github.com/elastic/beats/metricbeat/module/prometheus"
)

Expand Down Expand Up @@ -78,7 +78,7 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {

// Add labels
if len(promEvent.labels) > 0 {
eventList[promEvent.labelHash]["labels"] = promEvent.labels
eventList[promEvent.labelHash]["label"] = promEvent.labels
}

}
Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/prometheus/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/elastic/beats/libbeat/common"

"github.com/golang/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -93,8 +94,8 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) {
value: common.MapStr{
"count": uint64(10),
"sum": float64(10),
"percentiles": common.MapStr{
"p99": float64(10),
"percentile": common.MapStr{
"99": float64(10),
},
},
labelHash: "#",
Expand Down Expand Up @@ -125,7 +126,7 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) {
value: common.MapStr{
"count": uint64(10),
"sum": float64(10),
"buckets": common.MapStr{
"bucket": common.MapStr{
"0.99": uint64(10),
},
},
Expand Down
12 changes: 7 additions & 5 deletions metricbeat/module/prometheus/collector/data.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package collector

import (
"github.com/elastic/beats/libbeat/common"
dto "github.com/prometheus/client_model/go"
"math"
"strconv"

"github.com/elastic/beats/libbeat/common"

dto "github.com/prometheus/client_model/go"
)

type PromEvent struct {
Expand Down Expand Up @@ -61,13 +63,13 @@ func GetPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent {
key := strconv.FormatFloat((100 * quantile.GetQuantile()), 'f', -1, 64)

if math.IsNaN(quantile.GetValue()) == false {
percentileMap["p"+key] = quantile.GetValue()
percentileMap[key] = quantile.GetValue()
}

}

if len(percentileMap) != 0 {
value["percentiles"] = percentileMap
value["percentile"] = percentileMap
}
}

Expand All @@ -82,7 +84,7 @@ func GetPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent {
bucketMap[key] = bucket.GetCumulativeCount()
}

value["buckets"] = bucketMap
value["bucket"] = bucketMap
}

event.value = value
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/prometheus/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package prometheus

import (
"fmt"
"net/http"

dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"net/http"
)

func GetMetricFamiliesFromResponse(resp *http.Response) ([]*dto.MetricFamily, error) {
Expand Down

0 comments on commit a5ee39f

Please sign in to comment.